Skip to content
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

Allow Integration with ASP.Net Core #119

Open
wertzui opened this issue Mar 27, 2025 · 6 comments
Open

Allow Integration with ASP.Net Core #119

wertzui opened this issue Mar 27, 2025 · 6 comments
Labels
enhancement New feature or request

Comments

@wertzui
Copy link

wertzui commented Mar 27, 2025

Is your feature request related to a problem? Please describe.
Many teams have already working APIs in place which are built using ASP.Net Core Controllers or Minimal APIs. It would be good to provide an easy way to leverage these APIs and expose them through the MCP.

Describe the solution you'd like
Since ASP.Net Core already has the API Explorer built in which allows looking at the metadata of endpoints, it could be as easy as providing a Middleware which would then generate the MCP description at the /resources/list endpoint.
Another Middleware could then listen at the /message endpoint and dispatch the calls to the appropriate Controller / Minimal Endpoint.

Describe alternatives you've considered
None

Additional context
The MCP spec has just introduces "normal" HTTP calls without SSE
modelcontextprotocol/specification#206

@wertzui wertzui added the enhancement New feature or request label Mar 27, 2025
@twenzel
Copy link

twenzel commented Mar 27, 2025

Should be resolved by #25

@wertzui
Copy link
Author

wertzui commented Mar 27, 2025

I'd say #25 is the base for this feature.

@stephentoub
Copy link
Contributor

@halter73, is this something we want to do as part of ModelContextProtocol.AspNetCore?

@halter73
Copy link
Contributor

halter73 commented Apr 4, 2025

dispatch the calls to the appropriate Controller / Minimal Endpoint.

This does sound appealing, but the HttpContext is a bad fit to represent an MCP JSON-RPC invocation, and controllers and minimal route handlers expect a conventional HTTP request where you can do things like set HTTP response headers, stream HTTP request and response bodies, etc.

@BrennanConroy showed me a very early prototype he has exposing SignalR hub methods as tools, but says it would take a lot more effort to make it production quality. While this might be an interesting approach, SignalR's HubCallerContext is not a much better fit than an HttpContext for a tool invocation, so this really only makes sense if you also have conventional SignalR clients connected to your application that you can send and broadcast messages to. And there's really no SignalR client "Caller" that the HubCallerContext alludes too, so we have some tough questions left to figure out.

The core HTTP Streaming MCP API is going to be built around the MapMcp method at least in the short term. We will give you access to the HttpContexts used to initiate sessions and send individual or batched JSON-RPC messages, but we will not automatically translate tool invocations into controller action invocations or minimal route handler invocations, at least not in the short term. It might be an interesting idea for a community add-on package. It could probably be implemented already using a combination of MapGroup, an endpoint filter factory, and MapMcp, but it'd be a lot work.

@halter73
Copy link
Contributor

halter73 commented Apr 4, 2025

The MCP spec has just introduces "normal" HTTP calls without SSE

For server developers who only want to support stateless HTTP calls without SSE, we will provide an API that's similar to minimal route handlers, but it won't dispatch to existing minimal APIs even in an opt-in nature. Minimal APIs are too unconstrained.

@stephentoub
Copy link
Contributor

cc: @captainsafia

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

4 participants