@traceloop/instrumentation-mcp
v0.22.6
Published
MCP (Model Context Protocol) Instrumentation
Readme
OpenTelemetry MCP Instrumentation for Node.js
This library allows tracing of agentic workflows implemented with MCP (Model Context Protocol) framework using the @modelcontextprotocol/sdk.
Installation
npm install --save @traceloop/instrumentation-mcpUsage
const { McpInstrumentation } = require("@traceloop/instrumentation-mcp");
const { registerInstrumentations } = require("@opentelemetry/instrumentation");
registerInstrumentations({
instrumentations: [new McpInstrumentation()],
});Privacy
By default, this instrumentation logs prompts, completions, and embeddings to span attributes. This gives you a clear visibility into how your LLM application is working, and can make it easy to debug and evaluate the quality of the outputs.
However, you may want to disable this logging for privacy reasons, as they may contain highly sensitive data from your users. You may also want to disable this logging to reduce the size of your traces.
To disable logging, set the traceContent config option to false:
const { McpInstrumentation } = require("@traceloop/instrumentation-mcp");
const mcpInstrumentation = new McpInstrumentation({
traceContent: false,
});Instrumented Operations
This instrumentation tracks the following MCP operations:
Client Operations
- Session lifecycle management
- Tool invocations
- Resource access
- Prompt templates
- MCP protocol methods
Server Operations
- Request handling
- Tool execution
- Resource serving
- Server-side spans
License
Apache 2.0 - See LICENSE for more information.
