Feature Request: Pass _meta through to MCP `callTool()` in `@langchain/mcp-adapters`

Problem

There is a _meta filed per MCP _meta specification:

The `_meta` property/parameter is reserved by MCP to allow clients and servers to attach additional metadata to their interactions.

Currently @langchain/mcp-adapters does NOT expose a way to attach MCP protocol _metaon tool invocations.

It makes it hard to cover the following use cases:

Proposal

  1. Extend beforeToolCall / tool-call modification to allow _meta (e.g. return { args?, headers?, _meta? } or meta)
    • const client = new MultiServerMCPClient({
        mcpServers: { /* ... */ },
        beforeToolCall: ({ name, args }, _state, config) => ({
          args,
          // protocol-level metadata — must NOT require fork()
          _meta: {
            "com.example/correlation_id": config?.configurable?.correlation_id,
            "com.example/trace_id": config?.configurable?.session_id,
          },
        }),
      });
      
  2. Forward that value into the underlying MCP SDK callTool params as protocol _meta
  3. Optionally surface response _meta on the tool result / artifact (as Python PR #423 does).

Hey @star67. Welcome to Langchain Community.

Today beforeToolCall in @langchain/mcp-adapters only supports { args?, headers? }. Headers go through client.fork() (HTTP/SSE only), and the actual callTool payload is just { name, arguments }, no request _meta gets forwarded. Response _meta is already surfaced as an mcp_meta artifact, but that doesn’t help for request-side correlation / session / tenant context.

One small correction on parity: Python isn’t fully there yet either. PR #423 adds this via interceptors (metaParams), but it’s still open and waiting on maintainers. So JS isn’t uniquely behind, both need this.

Your proposal looks right though. Extending beforeToolCall to return _meta and forwarding it into the MCP SDK callTool params keeps that data out of tool args (so the model never sees it) and works for stdio too, unlike headers.

Best next step: open a feature request / PR on langchain-ai/langchainjs for @langchain/mcp-adapters, mirroring the Python interceptor approach.

Hey @keenborder786 , thanks for your reply!
Here is the PR feat(mcp-adapters): forward _meta from beforeToolCall to MCP callTool requests by star67 · Pull Request #11251 · langchain-ai/langchainjs · GitHub