-
Couldn't load subscription status.
- Fork 2.7k
Expose RequestParams._meta in ClientSession.call_tool #1231
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
Expose RequestParams._meta in ClientSession.call_tool #1231
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am okay with this change, but I think we should make the ordering such that it's BC compatbile, and create a follow up for the SDK version 2.0 to reconsider the ordering and force named arguments.
|
This feature looks great and would be a valuable addition. Nice work! Would it be possible to get this approved for merge @dsp-ant |
|
Hey, @dsp-ant! Are there any other changes I need to make? |
|
I'd also be interested in this, is there anything further that needs changing? |
|
I'd also be interested in this! Requesting maintainers to merge it if there are no unwanted side effects of this change. |
|
Great work @samchenatti! This feature would be really valuable for the MCP ecosystem. I hope the conflicts can be resolved soon and this PR gets merged. The community clearly supports this addition based on all the positive feedback. Keep up the excellent work! 🚀 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feedback looks addressed to me but still requires some conflict resolution (apologies for the time it took to get back to this).
If you have time @samchenatti to update PR here and resolve conflicts that'd be greatly appreciated, otherwise I'll aim to get to it later this week!
|
Thanks for the feedback, @maeryo and @felixweinberger! I'll fix the conflicts by the end of the day |
82f9320 to
f021dec
Compare
|
@felixweinberger, @maeryo conflicts solved! |
|
cool! I also checked today and noticed that the kotlin-sdk didn’t have this implementation yet, so I submitted a PR with a similar approach to yours. In addition to just adding the meta parameter, I paid extra attention to improving validation logic as well. |
|
@felixweinberger @ihrpr let me know if there's anything else i need to change! |
|
Hey @samchenatti Do you have an ETA on when this might be in? |
|
Hey @Jaorow! I'm waiting on the maintainers’ feedback... This feature has become even more important since OpenAI announced the App SDK. By merging this PR, we’d allow other MCP Clients to do the same. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look good! Although, I'd want to see some unit tests for this. You could add them in tests/server/test_session.py
@samchenatti Awesome, It will definitely open the door for more complex and structured functionality. |
|
Hey, @maxisbey! I made the requested changes and implemented the unit test.
After a good night’s sleep, I was able to properly implement the unit test (commit 2b61abba). Now the client and server exchange all the necessary messages just like they would in a real scenario. |
0315b04 to
701611d
Compare
3643b62 to
2b61abb
Compare
dismissing my own review
Motivation and Context
This change allow clients to send metadata through the
_metafield as specified by the protocol.It is important to expose
_metasince there might be some metadata required by the server to control how the tool works (such as client preferences, its localization and so on). In some cases we also don't want the Agent/LLM to be aware of such data; it should be known by the MCP Host and Server only; therefore it cannot be exposed as tool usual arguments.This feature has already been requested by me and another user - so it might benefit another people as well.
I also started a discussion about
_metabeing exposed by FastMCP Client, but they will wait until its implemented in here.How Has This Been Tested?
I tested it on my local environment using a self-made MCP Server.
Since
_metais currently being used for progress report tokens, I also ensured this feature doesn't breakprogress_callback.I'd be happy to implement the required unit-tests if someone can point the best test-file for it.
Breaking Changes
There are no breaking changes. The
python-sdkalready considers that_metacan carry data other thanprogressToken.Also
types.RequestParams.Metamodel is already configured to allow extra key-values.Types of changes
Checklist
Additional context
I decided to expose
metaas a plain dict instead oftypes.RequestParams.Metasince, from my understanding,mcp.typesshouldn't be exposed to final users.Metadata could be exposed by another interfaces as well, such as
list_tools,list_promptsand etc. I'm sticking withtool_callfor now, but would be happy to replicate it to the other interfaces.