Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.sedata-ai.tech/llms.txt

Use this file to discover all available pages before exploring further.

This guide assumes you already have a working MCP server. You’ll add instrumentServer and verify traces in under a minute.

Add the call

instrumentServer must run before you register tools — it patches server.registerTool and only the calls made afterward are instrumented.
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
import { instrumentServer } from '@sedata-ai/mcp'

const server = new McpServer({ name: 'my-server', version: '1.0.0' })

const telemetry = instrumentServer(server, {
  serverName: 'my-server',
  serverVersion: '1.0.0',
  exporterEndpoint: process.env.OTLP_ENDPOINT ?? 'https://otel.sedata-ai.tech/v1',
  exporterAuth: { type: 'bearer', token: process.env.SEDATA_TOKEN! },
})

// Now register tools — they will all be instrumented.
server.registerTool('hello', { /* ... */ }, async () => /* ... */)
instrumentServer returns an ObservabilityInstance — keep the reference around to record custom spans and to call shutdown().

Pick the right serverName / serverVersion

These map to service.name and service.version in OpenTelemetry. Use stable values that match how you operate the service:
serverName: 'weather-mcp',          // not 'my-server'
serverVersion: process.env.GIT_SHA, // or your release tag

Wire shutdown

The OTel SDK is a long-running thing. Always shut it down on exit so the last batch of metrics flushes (including session duration):
const exit = async (code = 0) => {
  await telemetry.shutdown()
  process.exit(code)
}

process.on('SIGINT', () => exit(0))
process.on('SIGTERM', () => exit(0))

Confirm it works

Three quick checks:
Set exporterType: 'console' and watch spans print on stdout when you call a tool:
instrumentServer(server, {
  serverName: 'my-server',
  serverVersion: '1.0.0',
  exporterType: 'console',
})
See Console debugging.
With the live exporter pointed at https://otel.sedata-ai.tech/v1, run a tool from any MCP client. Open app.sedata-ai.techTraces. Latest trace should appear within a few seconds.
Point exporterEndpoint at your collector and tail its logs:
docker run --rm -p 4318:4318 otel/opentelemetry-collector-contrib \
  --config /etc/otelcol-contrib/config.yaml

Common pitfalls

Calling instrumentServer after registerTool — tools registered before instrumentation are not patched. Always call instrumentServer immediately after new McpServer(...).
Two versions of @opentelemetry/api — if your project pins a different version, your tracer will silently no-op. Run npm ls @opentelemetry/api and dedupe.
Sampling 0 in dev — if samplingRate: 0 is in a shared config you’ll see zero spans. Default is 1.0.

Next

Authentication

Bearer, API key, basic.

Custom spans & metrics

Record domain-specific telemetry.