Skip to content

MCP Tools Cannot Receive RunnableConfig Parameters in LangGraph React AgentΒ #271

@Jasper-zh

Description

@Jasper-zh

Problem

When using langchain-mcp-adapters with LangGraph's create_react_agent, MCP tools cannot access RunnableConfig parameters that are automatically passed to local LangChain tools.

Current Behavior

Local LangChain Tools (Working):

@tool
def get_user_info(config: RunnableConfig) -> Dict[str, Any]:
    token = config.get("metadata").get("token")  # βœ… Works
    return {"user_id": "current_user"}

MCP Tools (Not Working):

@mcp.tool()
def event_query(bot_name=None, status: int=None):
    # ❌ Cannot access config.get("metadata").get("token")
    return {"event_query": {...}}

Impact

  • Authentication blocked: MCP tools cannot access user tokens
  • Multi-tenant impossible: No way to pass user context
  • Production limitation: Forces developers to avoid MCP for authenticated scenarios

Root Cause

LangGraph's create_react_agent manages tool invocation internally, and langchain-mcp-adapters doesn't preserve the ability to pass RunnableConfig to MCP tools.

Environment

  • langchain-mcp-adapters: 0.1.7
  • langgraph: 0.2.20
  • mcp: 1.9.4

Request

Add support for passing RunnableConfig parameters to MCP tools, similar to how local LangChain tools receive them.

Priority: High (blocks production use cases requiring authentication)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions