Skip to content

ASP.NET Core SSE server is incompatible with Unity — reimplementation available using EmbedIO #324

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
WHedlund opened this issue Apr 17, 2025 · 3 comments
Labels
enhancement New feature or request

Comments

@WHedlund
Copy link

Is your feature request related to a problem? Please describe.
Yes. ASP.NET is currently incompatible with the Unity Editor, which prevents hosting an SSE (Server-Sent Events) server using this framework. This limitation makes it difficult to implement real-time communication features in Unity projects using ASP.NET.

Describe the solution you'd like
I’ve implemented an SSE server for Unity using ModelContextProtocol (MCP) with EmbedIO. You can check out the implementation here:
https://github.com/WHedlund/ModelContextProtocolUnityEmbedIO
I’d love to see something like this officially supported or incorporated into the main MCP repository.

Describe alternatives you've considered
I initially tried using ASP.NET-based approaches, but the lack of compatibility with the Unity Editor was a blocker. Other solutions either required external services or added unnecessary complexity.

Additional context
Feel free to adopt or improve on my implementation if it fits within the project’s goals!

@WHedlund WHedlund added the enhancement New feature or request label Apr 17, 2025
@stephentoub
Copy link
Contributor

currently incompatible with the Unity Editor

Incompatible how? What is the issue?

@WHedlund
Copy link
Author

I'm still fairly new to these frameworks, so I might not have the full technical details, but from my experience and what I’ve gathered, Unity has limited support for ASP.NET Core. Specifically, it doesn't seem possible to run ASP.NET Core web services directly within a Unity game or the Unity Editor.

I asked ChatGPT for some clarification, and here's a helpful summary:

As of April 2025, Unity and ASP.NET Core continue to operate on separate runtime environments, and direct integration remains unsupported. Unity primarily uses its own runtime (Mono or IL2CPP), while ASP.NET Core is built on the .NET Core runtime. This separation means that running an ASP.NET Core project directly within the Unity Editor or referencing ASP.NET Core libraries in Unity scripts is not feasible. However, you can establish communication between Unity and an ASP.NET Core backend through standard networking protocols.

So essentially, while Unity can talk to an ASP.NET Core backend, it can’t host one internally. That’s why I reimplemented the SSE server using EmbedIO, which works inside Unity.

@halter73
Copy link
Contributor

I doubt we'd ship an official package with an EmbedIO dependency, but you should be able to leverage the SseResponseStreamTransport and StreamableHttpServerTransport to make an EmbedIO-based implementation easier. These are the types used by MapMcp to write SSE responses implement the SSE and Streamable HTTP transports respectively.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants