Trace each tool an MCP server runs.
Accepts an McpServer or a low-level Server. Each tools/call becomes a
tool run with the tool's arguments as inputs and its result as outputs.
Tools registered before or after this call are traced. On a stateful
transport, a run that starts its own trace gets a thread_id derived from
the session, so a session's calls group into one thread. The server is
changed in place and returned.
wrapMcpServer<T extends object>(server: T, options: WrapMcpOptions = {}): T| Name | Type | Description |
|---|---|---|
server* | T | |
options | WrapMcpOptions | Default: {} |
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { wrapMcpServer } from "langsmith/wrappers/mcp";
const server = wrapMcpServer(new McpServer({ name: "weather", version: "1.0.0" }));