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

@unhandled/instrumentation-mcp-server

v0.1.15

Published

Model Context Protocol server tracing for Unhandled

Readme

@unhandled/instrumentation-mcp-server

Traces the MCP server your app exposes, built on @modelcontextprotocol/sdk 1.x or @modelcontextprotocol/server 2.x. It is a standalone package: there is no agent integration entry, so install it explicitly.

pnpm add @unhandled/instrumentation-mcp-server

Usage

Initialize the Unhandled agent (or any OpenTelemetry SDK) first, then instrument the server before it connects.

import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
import { instrumentMcpServer } from '@unhandled/instrumentation-mcp-server'

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

server.registerTool('search', { inputSchema: { query: z.string() } }, handler)
await server.connect(new StdioServerTransport())

Call instrumentMcpServer before connect(). Calling it afterwards emits a UNHANDLED_MCP_LATE_INSTRUMENTATION process warning; only messages received after the call are traced. A low-level Server is accepted as well as McpServer, from either SDK. On 2.x, createMcpHandler connects a new transport per request; instrument the server in the handler's factory and each request is traced. Instrumenting the same server twice is a no-op.

The server is observed at its transport, so every message is covered, including unknown methods and requests handled by the SDK itself.

Options

| Option | Default | Effect | | --------------- | ------------- | -------------------------------------------------------------- | | recordInputs | false | Record tool and prompt arguments as attributes | | recordOutputs | false | Record tool results and prompt messages as attributes | | serverName | auto-detected | Overrides the name from the McpServer / Server constructor | | serverVersion | auto-detected | Overrides the version from the constructor |

Spans

| Event | Kind | Name | | ------------------------- | -------- | --------------------------------------------------------------------------- | | Incoming JSON-RPC request | SERVER | <method> <target>, or the bare method (tools/call search, initialize) | | Incoming notification | SERVER | The method, for example notifications/initialized | | Outgoing notification | CLIENT | The method, for example notifications/tools/list_changed | | Transport error | INTERNAL | mcp.transport.error, with the exception recorded |

Targets: the tool name for tools/call, the prompt name for prompts/get, the URI for resources/read, resources/subscribe and resources/unsubscribe.

Handlers run inside the request span, so spans you create in a tool handler are its children. A notification sent from a handler is a child of that request span.

A JSON-RPC error response does not get its own span. The request span gets rpc.jsonrpc.error_code and rpc.jsonrpc.error_message and ERROR status. A tool that returns isError: true (which includes thrown handler errors and unknown tool names, because the SDK converts them) gets ERROR status too. Requests still pending when the transport closes end with ERROR.

Attributes

Always set:

| Attribute | Where | | ----------------------------------------------------- | ------------------------------------------------------- | | mcp.method.name | every span (the transport error span uses its own name) | | mcp.server.name, mcp.server.version | every span | | mcp.client.name, mcp.client.version | after initialize (the initialize span itself too) | | mcp.tool.name | tools/call | | mcp.tool.result.is_error | tools/call responses | | rpc.jsonrpc.error_code, rpc.jsonrpc.error_message | requests answered with an error |

With recordInputs:

  • mcp.request.argument.<key>: JSON string of each argument of tools/call and prompts/get.

With recordOutputs:

  • mcp.tool.result.content_count, mcp.tool.result.<i>.content_type, mcp.tool.result.<i>.content
  • mcp.prompt.result.description, mcp.prompt.result.message_count, mcp.prompt.result.<i>.role, mcp.prompt.result.<i>.content

Text content is recorded as the raw text; any other content item is recorded as its JSON.

For AI agents

A coding agent can install this package, check that its data arrives and fix the errors it reports through the Unhandled MCP server at https://unhandled.net/mcp. In Claude Code, the Unhandled plugin adds that server plus skills for instrumenting a service, fixing a production error with a failing test first and verifying a deploy:

claude plugin marketplace add treboryx/unhandled
claude plugin install unhandled@unhandled

Codex, Cursor, Gemini CLI and other agents connect to the same URL. Coding agents has the setup for each one and an AGENTS.md section to add to your repository.