Recommended way to use InjectedState with MCP tools loaded via streamable-http server #5410
Unanswered
jonas-debeuk
asked this question in
Q&A
Replies: 1 comment
-
For now I think I have a workaround (thanks to claude code)
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello!
I'm using langgraph to build an agent, which has access to tools defined in our backend server, via an MCP server serving streamable-http.
I'm trying to figure out a way to programmatically set a tenant_id, to ensure no risk of data leaking between users if the agent makes a mistake or is asked to fetch data for a diff tenant.
What is the recommended way to achieve this? I'm at a bit of a loss as I can't see how to specify the state injection into the tool definition.
here's what I have so far, but in
_create_async_tool_func
I'm unsure how or where to specify that tenant_id, if passed, should be an injectedstate arg.The
tool_info.inputSchema
i pass for the schema is a dict, and from the langgraph code it looks like if it's in this format theres no way to specify tenant_id as an injectedstate arg?Any help very appreciated!
I've taken a look at this thread (langchain-ai/langchain#24906) but it seems the result was inconclusive.
Beta Was this translation helpful? Give feedback.
All reactions