python-sdk icon indicating copy to clipboard operation
python-sdk copied to clipboard

Passing client context to tools

Open samirbajaj opened this issue 1 year ago • 6 comments

(This may be related to https://github.com/modelcontextprotocol/python-sdk/issues/373)

I would like to be able to pass some "out of band" context to a tool in an MCP server. This would be separate from the arguments that are extracted by the LLM and provided to the tool function.

How do I pass this "extra" data to the tool?

Thank you for any help.

samirbajaj avatar Mar 26 '25 14:03 samirbajaj

(This may be related to #373)

I would like to be able to pass some "out of band" context to a tool in an MCP server. This would be separate from the arguments that are extracted by the LLM and provided to the tool function.

How do I pass this "extra" data to the tool?

Thank you for any help.

I ran into the same issue. Instead of struggling to figure it out, I ended up writing my own MCP from scratch — it was much faster and way more optimized.

QuangTQV avatar Apr 01 '25 07:04 QuangTQV

(This may be related to #373)

I would like to be able to pass some "out of band" context to a tool in an MCP server. This would be separate from the arguments that are extracted by the LLM and provided to the tool function.

How do I pass this "extra" data to the tool?

Thank you for any help.

I also had this problem because my app needs to add user data to the tool

juny76 avatar Apr 02 '25 02:04 juny76

Can one of the contributors / maintainers comment, please?

Perhaps there is a way to do this, that I haven't discovered?

Thank you.

samirbajaj avatar Apr 06 '25 15:04 samirbajaj

I've opened a PR to hopefully solve this issue https://github.com/modelcontextprotocol/python-sdk/pull/574

martina-zxy avatar Apr 25 '25 10:04 martina-zxy

@martina-zxy PR was closed but its not clear to me how to provide a tool an argument which has not been generated by the language model in the request to the tool. The answer from the bot was to use the context object - but afaict there's no way to get content from the request into the context object.

mikeedjones avatar May 14 '25 08:05 mikeedjones

Now tracked in #2098.

maxisbey avatar Feb 19 '26 13:02 maxisbey