ModelContextProtocolUnityEmbedIO
An implementation of a SSE server in EmbedIO that can be run within unity, unity editor, unity editor (in play mode)
Ask AI about ModelContextProtocolUnityEmbedIO
Powered by Claude · Grounded in docs
I know everything about ModelContextProtocolUnityEmbedIO. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Reviews
Documentation
Deprecated. use https://github.com/WHedlund/csharp-sdk instead
Unity EmbedIO Extensions for the MCP C# SDK
Unstable: This package tracks the evolving Model Context Protocol (MCP) and is subject to breaking changes as the MCP package updates.
About
This package enables Unity projects to run a fully functional Model Context Protocol (MCP) server using EmbedIO as a lightweight HTTP server. It is designed specifically for Unity, since ASP.NET Core is not fully compatible with the Unity runtime (Mono).
Key features:
- Native Unity integration for MCP servers.
- Uses EmbedIO for lightweight HTTP/SSE transport.
- Runs the HTTP server in a separate thread to avoid blocking the Unity main thread.
- A MainThreadDispatcher may be added for safe Unity object interaction.
- Automatic tool discovery: Finds tools on the same GameObject (see
EchoToolWithInstance). - Updated to match latest MCP type/name changes.
This is a community-driven project and not officially maintained by the MCP core team.
🚀 Installation & Getting Started
1. Add This Package to Your Unity Project
Simply clone or copy this repository into your project’s Assets folder.
Assets/
└── ModelContextProtocol/
└── EmbedIO/
... (all scripts here)
2. Install Dependencies
Use NuGet for Unity to install the required packages:
EmbedIO3.5.2ModelContextProtocol0.1.0-preview.10
Enable "Show Prerelease Packages" in NuGet for Unity’s settings to find the correct MCP version.
3. Add Components to Your Scene
- Create a new GameObject in your Unity scene.
- Attach both
EmbedIOServerHostandEchoToolWithInstancescripts to this GameObject.
When you press Play, the MCP server starts automatically (in a background thread) and is available at:
http://localhost:8888/api/sse
You can test your server using the MCP Inspector tool from MCP[cli].
To add more tools, just add additional tool scripts as components on the same GameObject for automatic discovery!
🧩 Usage & Examples
Tools are automatically discovered when added as components to the same GameObject as the server host.
Here’s an example of an instance tool using MonoBehaviour:
using UnityEngine;
using ModelContextProtocol.Tools;
public class EchoToolWithInstance : MonoBehaviour
{
[McpServerTool(Description = "Echoes the input message (instance)")]
public string Echo(string message)
{
return $"Echo: {message}";
}
}
- Attach your tool script (like
EchoToolWithInstance) to the same GameObject asEmbedIOServerHost. - All
[McpServerTool]methods will be registered and available to MCP clients. - You can test tool calls using MCP Inspector or any MCP-compatible client.
