Injecting Tool Args into MCP Tools #33499
Unanswered
Blake-Martin-code
asked this question in
Q&A
Replies: 0 comments
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.
-
I may have an unique use case.
As an overview, I am trying to inject tool arguments into my models mcp tool calls. Basically I have a vector Search tool that accepts
'source_filters': list[str]
. This argument narrows down the vector search to chunks that have this meta data. It allows the user to specify which sources they want to look at.This
source_filters
is a tool argument which the model can fill out but I override to the users selection and ensure the user has permissions to the sources incase of prompt injection. The way I override this is by passing the user selectedsources
and allowedsources
to the RunnableConfig inside my custom agent graph. I then created a custom Tool Node which inherits from tool node which replaces the tool args before the tool is invoked.I did it this way because my mcp servers are using langchain_mcp_adapters and I cannot use the InjectedArgs through mcp.
With langchain v1 I was hoping I could just use the default create_agents with no custom agent or custom tool node. Then I could wrap my tool calls in a wrap_tool_call middle ware, grab the config and update the tool args. However It appears that I cannot get the config in the below code:
Is anyone aware of how to implement this or can guide me?
Beta Was this translation helpful? Give feedback.
All reactions