You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There does not appear to be a way to access that in the McpTool method.
Describe the solution you'd like
I think there should be a way to have an argument to the McpTool method that is bound to the request context (or the equivalent _meta property from TypeScript), in the same way you can have a HttpRequest on minimal API.
Describe alternatives you've considered
I've looked at the CallToolRequestParams when creating your own CallToolHandler callback but I don't think you can get to it through that either.
Just playing around with the changes in #89 and it's not exposing the _meta property from the incoming request.
Here's a screenshot of the request running:
In the jsonString variable we can see the _meta is available, along with the progressToken, but the CallToolRequestParams doesn't deserialize that property.
The JSONRPCRequest type defines the _meta property on params as expected, and the description of it matches the description in the TypeScript SDK and Python SDK implementations (probably the others, I didn't dig that far).
Going through the Python SDK, it seems that they use a base class for many of the request types (which has that property on it), so would it make sense to create a base class in C# that has the _meta property deserialized to it?
Created a local branch where I deserialize the _meta property and this code now works:
[McpServerToolType]publicstaticclassLongRunningTool{[McpServerTool,Description("Demonstrates a long running operation with progress updates")]publicstaticasyncTask<string>LongRunningOperation(IMcpServerserver,RequestContext<CallToolRequestParams>requestParams,intduration=10,intsteps=5){varstepDuration=duration/steps;varprogressToken=requestParams?.Params?.Meta?.ProgressToken;for(inti=1;i<steps+1;i++){awaitTask.Delay(stepDuration*1000);if(progressTokenis not null&&serveris not null){// Send progress updateawaitserver.SendMessageAsync(newJsonRpcNotification{Method="notifications/progress",Params=new{progressToken,total=steps,progress=i}});}}// Return the resultreturn$"Operation completed in {duration} seconds with {steps} steps.";}}
Would you like me to PR that on top of #89 (the deserialization, not the whole "everything server")?
Activity
stephentoub commentedon Mar 23, 2025
I'm in the progress of addressing this.
stephentoub commentedon Mar 24, 2025
The CallToolRequestParams is available to an McpServerTool now as of #89, so if _meta is exposed on that, this issue will be addressed.
aaronpowell commentedon Mar 25, 2025
Just playing around with the changes in #89 and it's not exposing the
_metaproperty from the incoming request.Here's a screenshot of the request running:
In the
jsonStringvariable we can see the_metais available, along with theprogressToken, but theCallToolRequestParamsdoesn't deserialize that property.If we added it there we can expose it.
aaronpowell commentedon Mar 25, 2025
If I'm reading the JSON schema correctly, part of this is coming from here: https://github.com/modelcontextprotocol/specification/blob/main/schema/2024-11-05/schema.json#L771-L806
The
JSONRPCRequesttype defines the_metaproperty onparamsas expected, and the description of it matches the description in the TypeScript SDK and Python SDK implementations (probably the others, I didn't dig that far).Going through the Python SDK, it seems that they use a base class for many of the request types (which has that property on it), so would it make sense to create a base class in C# that has the
_metaproperty deserialized to it?aaronpowell commentedon Mar 25, 2025
Created a local branch where I deserialize the
_metaproperty and this code now works:Would you like me to PR that on top of #89 (the deserialization, not the whole "everything server")?
Adding a base class for request params that exposes the progressToken
stephentoub commentedon Mar 26, 2025
Would it make sense to add the everything server, in samples or tests or something?
Adding a base class for request params that exposes the progressToken (…