Bug
When an MCP tool has an input parameter named config, convert_mcp_tool_to_langchain_tool produces a StructuredTool that silently replaces the user's config value with LangChain's internal RunnableConfig dict at invocation time.
Reproduction
from mcp.types import Tool as MCPTool
from langchain_mcp_adapters.tools import convert_mcp_tool_to_langchain_tool
tool = MCPTool(
name="my_tool",
description="A tool with a config param",
inputSchema={
"type": "object",
"properties": {
"config": {"type": "string", "description": "User config value"},
"query": {"type": "string"},
},
"required": ["config", "query"],
},
)
lc_tool = convert_mcp_tool_to_langchain_tool(session, tool)
# When invoked with {"config": "my_value", "query": "hello"},
# the coroutine receives config={"callbacks": ..., "tags": ..., ...} (a RunnableConfig)
# instead of "my_value"
Root cause
The execution path in BaseTool.arun (langchain-core):
_to_args_and_kwargs unpacks the tool input dict into tool_kwargs — so tool_kwargs["config"] = "my_value"
- Then LangChain checks
_get_runnable_config_param(func_to_check) against StructuredTool._arun, which has config: RunnableConfig in its signature
- This returns
"config", and the code does tool_kwargs["config"] = config — overwriting the user's value with the internal RunnableConfig
The same applies to run_manager and callbacks (via FILTERED_ARGS).
Version
- langchain-mcp-adapters: 0.2.2
- langchain-core: 0.3.x
Bug
When an MCP tool has an input parameter named
config,convert_mcp_tool_to_langchain_toolproduces aStructuredToolthat silently replaces the user'sconfigvalue with LangChain's internalRunnableConfigdict at invocation time.Reproduction
Root cause
The execution path in
BaseTool.arun(langchain-core):_to_args_and_kwargsunpacks the tool input dict intotool_kwargs— sotool_kwargs["config"] = "my_value"_get_runnable_config_param(func_to_check)againstStructuredTool._arun, which hasconfig: RunnableConfigin its signature"config", and the code doestool_kwargs["config"] = config— overwriting the user's value with the internalRunnableConfigThe same applies to
run_managerandcallbacks(viaFILTERED_ARGS).Version