- Explore MCP Servers
- ModelContextProtocolUnityEmbedIO
Modelcontextprotocolunityembedio
What is Modelcontextprotocolunityembedio
ModelContextProtocolUnityEmbedIO is an implementation of a Server-Sent Events (SSE) server using EmbedIO that can be run within Unity, including the Unity Editor and Play Mode. It provides a lightweight HTTP server tailored for Unity projects, overcoming compatibility issues with ASP.NET Core.
Use cases
Use cases include developing multiplayer games that require server communication, real-time data streaming applications, and any Unity project that needs to implement the Model Context Protocol for managing data interactions.
How to use
To use ModelContextProtocolUnityEmbedIO, clone or copy the repository into your Unity project’s Assets folder. Install the required dependencies using NuGet for Unity, and then create a new GameObject in your scene. Attach the EmbedIOServerHost and EchoToolWithInstance scripts to this GameObject. The MCP server will start automatically in a background thread when you press Play.
Key features
Key features include native Unity integration, lightweight HTTP/SSE transport using EmbedIO, running the HTTP server in a separate thread to avoid blocking the Unity main thread, a MainThreadDispatcher for safe Unity object interaction, automatic tool discovery, and updates to match the latest MCP type/name changes.
Where to use
ModelContextProtocolUnityEmbedIO is suitable for use in Unity game development projects, particularly those that require real-time data communication or server-client interactions within the Unity environment.
Overview
What is Modelcontextprotocolunityembedio
ModelContextProtocolUnityEmbedIO is an implementation of a Server-Sent Events (SSE) server using EmbedIO that can be run within Unity, including the Unity Editor and Play Mode. It provides a lightweight HTTP server tailored for Unity projects, overcoming compatibility issues with ASP.NET Core.
Use cases
Use cases include developing multiplayer games that require server communication, real-time data streaming applications, and any Unity project that needs to implement the Model Context Protocol for managing data interactions.
How to use
To use ModelContextProtocolUnityEmbedIO, clone or copy the repository into your Unity project’s Assets folder. Install the required dependencies using NuGet for Unity, and then create a new GameObject in your scene. Attach the EmbedIOServerHost and EchoToolWithInstance scripts to this GameObject. The MCP server will start automatically in a background thread when you press Play.
Key features
Key features include native Unity integration, lightweight HTTP/SSE transport using EmbedIO, running the HTTP server in a separate thread to avoid blocking the Unity main thread, a MainThreadDispatcher for safe Unity object interaction, automatic tool discovery, and updates to match the latest MCP type/name changes.
Where to use
ModelContextProtocolUnityEmbedIO is suitable for use in Unity game development projects, particularly those that require real-time data communication or server-client interactions within the Unity environment.
Content
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:
EmbedIO
3.5.2ModelContextProtocol
0.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
EmbedIOServerHost
andEchoToolWithInstance
scripts 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.