npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@respan/instrumentation-mcp

v1.1.0

Published

Respan instrumentation plugin for the Model Context Protocol TypeScript SDK

Downloads

128

Readme

@respan/instrumentation-mcp

Trace real Model Context Protocol client and server operations through Respan. The adapter supports @modelcontextprotocol/sdk v1 (>=1.0.0 <2) and the stable split @modelcontextprotocol/client / @modelcontextprotocol/server v2 packages (>=2.0.0 <3). Install the SDK generation your application uses. Node.js 18 or later is required for v1; the split v2 SDK requires Node.js 20.

npm install @respan/respan @respan/instrumentation-mcp @modelcontextprotocol/client @modelcontextprotocol/server
import { Client, InMemoryTransport } from "@modelcontextprotocol/client";
import { McpServer } from "@modelcontextprotocol/server";
import { Respan } from "@respan/respan";
import { MCPInstrumentor } from "@respan/instrumentation-mcp";

const respan = new Respan({ instrumentations: [new MCPInstrumentor()] });
await respan.initialize();
const server = new McpServer({ name: "example-server", version: "1.0.0" });
server.registerTool(
  "hello",
  { description: "Return a greeting" },
  async () => ({
    content: [{ type: "text", text: "Hello from MCP" }],
  }),
);
const client = new Client({ name: "example-client", version: "1.0.0" });
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
await server.connect(serverTransport);
await client.connect(clientTransport);
try {
  await respan.withWorkflow({ name: "mcp-example" }, async () => {
    await client.listTools();
    console.log(await client.callTool({ name: "hello", arguments: {} }));
  });
} finally {
  await client.close();
  await server.close();
  await respan.shutdown();
}

For v1, install @modelcontextprotocol/sdk and import its client/server subpaths. The adapter detects installed v1 and v2 modules. Pass clientModule and serverModule, or clientModules and serverModules, when using a bundler or independently loaded SDK copies. For v1 high-level servers, include both server/index.js and server/mcp.js exports in serverModule to capture all protocol handlers. A high-level-only module retains legacy tool callback support.

The adapter captures native request() and notification() operations and registered handlers. This includes tools, resource and prompt pagination, resource subscriptions, completion, roots, logging, sampling, elicitation, progress and cancellation. On v1 versions exposing experimental tasks, native task creation, status, result, list and cancel requests are captured without wrapping or replacing the returned async iterator. The v1.0.0 minimum has no high-level McpServer, elicitation or experimental tasks API. The stable v2 SDK does not expose v1 experimental tasks. In SDK1.0.0, aborting a client request rejects its promise, but the SDK sends a legacy cancellation method that its server does not handle; the server callback continues until its actual result. The adapter preserves that native boundary.

tools/call emits a tool execution span with {name, arguments} and the actual result. Other protocol operations emit task spans with their actual method, parameters and result. Sampling is protocol work: the adapter does not infer a provider, model, token usage, or an LLM child span. Native JSON-RPC IDs are retained as mcp.request.id; they are not model tool-call IDs. Complete tool definitions, multimodal blocks, structured results, _meta, pagination cursors and falsy values are retained in canonical JSON input and output without adapter length, depth or collection caps.

Content capture occurs after the actual OpenTelemetry sampler admits the span. Set traceContent: false, TRACELOOP_TRACE_CONTENT=false, or the canonical Traceloop content context to disable it. Tracing suppression calls through to the SDK. Constructor settings, observed context vetoes and denied ancestors remain ceilings for the operation. recordInputs and recordOutputs independently disable their canonical payload lane. Denied spans also reject late payload attributes, events, exceptions and status messages on the original SDK span. Application getters, toJSON hooks and proxy objects are not evaluated by serialization.

captureClientOperations and captureServerTools control client and server capture respectively; the latter includes server protocol callbacks as well as tools. activate() coalesces concurrent activation. deactivate() restores owned patches, keeps foreign wrappers, stops registered callback tracing and allows spans already in flight to finish. isActive() reports plugin state.

The existing public serialization and client-name utility exports remain available. Serialization now retains complete enumerable data properties, including _meta, rather than truncating at 16,000 characters or six levels.