-
Notifications
You must be signed in to change notification settings - Fork 283
InjectedState in MCP tools #287
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
Conversation
@eyurtsev for review. |
@eyurtsev |
This feature needs more up front design before we can add an implementation Could you explain the motivation and use case? |
@eyurtsev Now, there is a potential security issue here were a MCP requesting agent state would get it from the client by just asking for it this way. We might need a flag to prevent propagating state by default. |
Why is a tool that is working with agent state being defined in an MCP server that should not know any specifics about the caller (e.g., not know that the caller uses langgraph, and should ideally not be aware that langgraph even exists)? Why is this tool not defined along side the agent? Could you describe a bit more of what use case you're solving? (not the solution / implementation) |
because we want to maintain tools as a separate entity. as for the suggestion of having some local tool calling on the MCP, then there is no point of having these tools in MCP; they might as well be an API server, called by those local tools. The point of MCP is that it can be called by the LLM directly. In our particular use case, we add auth/RBAC to the MCP to authorize tools that the user can use, via existing middleware for MCP. Doing this locally would mean reinventing all that logic on the agent and tool node. |
Basically there is the only reason: when you don't want to rely on LLM to pass some data (because of undeterministic nature), which can be critical in some contexts, like money numbers for example, but event the user ID or tenant ID could be critical. |
re-opened here #321 |
usage:
On the MCP server side, specify the key to map to the state with annotations:
On the client side, it is handled automatically by the added code.
Caveat: