@arizeai/openinference-instrumentation-mcp
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

OpenInference Instrumentation for MCP Typescript SDK

npm version

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-mcp

Usage

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.

Readme

Keywords

none

Package Sidebar

Install

npm i @arizeai/openinference-instrumentation-mcp

Weekly Downloads

37

Version

0.2.0

License

Apache-2.0

Unpacked Size

300 kB

Total Files

45

Last publish

Collaborators

  • mikeldking
  • eunicode
  • koonal
  • parker-stafford
  • nickleach22
  • jackyxcs
  • cephalization