@arizeai/openinference-instrumentation-mcp
v0.2.12
Published
OpenInference instrumentation for MCP
Keywords
Readme
OpenInference Instrumentation for MCP Typescript SDK
This module provides automatic instrumentation for the MCP Typescript SDK. which may be used in conjunction with @opentelemetry/sdk-trace-node.
Installation
npm install --save @arizeai/openinference-instrumentation-mcpUsage
To load the MCP instrumentation, manually instrument the @modelcontextprotocol/sdk/client/index and/or @modelcontextprotocol/sdk/server/index module.
The client and server must be manually instrumented due to the non-traditional module structure in @modelcontextprotocol/sdk. Additional instrumentations can
be registered as usual using the registerInstrumentations function.
For example, if using stdio transport,
import { NodeTracerProvider } from "@opentelemetry/sdk-trace-node";
import { MCPInstrumentation } from "@arizeai/openinference-instrumentation-mcp";
import * as MCPClientStdioModule from "@modelcontextprotocol/sdk/client/stdio";
import * as MCPServerStdioModule from "@modelcontextprotocol/sdk/server/stdio";
const provider = new NodeTracerProvider();
provider.register();
const mcpInstrumentation = new MCPInstrumentation();
// MCP must be manually instrumented as it doesn't have a traditional module structure
mcpInstrumentation.manuallyInstrument({
clientStdioModule: MCPClientStdioModule,
serverStdioModule: MCPServerStdioModule,
});For more information on OpenTelemetry Node.js SDK, see the OpenTelemetry Node.js SDK documentation.
