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

@monocle.sh/instrumentation-mcp

v1.0.2

Published

OpenTelemetry instrumentation for MCP servers

Readme

@monocle.sh/instrumentation-mcp

OpenTelemetry instrumentation for MCP (Model Context Protocol) servers. Automatically traces JSON-RPC requests, responses, notifications, and handler errors with zero configuration.

Installation

Preferred — via the AdonisJS agent (already includes this package):

npm install @monocle.sh/adonisjs-agent
import { instrumentMcpServer } from '@monocle.sh/adonisjs-agent/mcp'

Standalone:

npm install @monocle.sh/instrumentation-mcp
import { instrumentMcpServer } from '@monocle.sh/instrumentation-mcp'

Usage

Call instrumentMcpServer once on your MCP server instance before connecting transports:

import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
import { instrumentMcpServer } from '@monocle.sh/instrumentation-mcp'

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

instrumentMcpServer(server, {
  recordInputs: true,
  recordOutputs: true,
})

server.tool('search', { query: z.string() }, async ({ query }) => {
  return { content: [{ type: 'text', text: `Results for ${query}` }] }
})

// Connect transport as usual — instrumentation hooks in automatically
const transport = new StdioServerTransport()
await server.connect(transport)

The function is idempotent — calling it twice on the same server returns the same instance.

Options

| Option | Type | Default | Description | | --------------- | --------- | ----------- | --------------------------------------------------------------- | | recordInputs | boolean | false | Capture tool/prompt arguments as span attributes | | recordOutputs | boolean | false | Capture tool results and prompt messages as span attributes | | serverName | string | auto-detect | Server name added to all spans (auto-detected from McpServer) | | serverVersion | string | auto-detect | Server version added to all spans |

Span Attributes

Core

| Attribute | Description | Example | | ----------------- | -------------------- | ---------------------- | | mcp.method.name | JSON-RPC method name | tools/call | | mcp.request.id | JSON-RPC request ID | 1 | | mcp.session.id | Transport session ID | abc-123 | | mcp.transport | Transport class name | StdioServerTransport |

Client & Server

| Attribute | Description | Example | | ---------------------- | -------------------------------- | ------------- | | mcp.client.name | Client name from initialize | Claude Code | | mcp.client.version | Client version from initialize | 1.0.0 | | mcp.server.name | Server name | my-server | | mcp.server.version | Server version | 2.0.0 | | mcp.protocol.version | MCP protocol version | 2025-06-18 |

Method-Specific

| Attribute | Description | Example | | ------------------ | ------------------------------ | ------------------- | | mcp.tool.name | Tool name for tools/call | search | | mcp.resource.uri | Resource URI for resources/* | file:///readme.md | | mcp.prompt.name | Prompt name for prompts/get | code-review |

Tool Result (when recordOutputs: true)

| Attribute | Description | Example | | ------------------------------- | ------------------------------ | ------- | | mcp.tool.result.is_error | Whether tool returned an error | true | | mcp.tool.result.content_count | Number of content items | 2 | | mcp.tool.result.content | Text content (single item) | hello | | mcp.tool.result.{i}.content | Text content (multiple items) | hello |

Prompt Result (when recordOutputs: true)

| Attribute | Description | Example | | ----------------------------------- | ------------------------ | ----------- | | mcp.prompt.result.description | Prompt description | Review... | | mcp.prompt.result.message_count | Number of messages | 2 | | mcp.prompt.result.message_role | Message role (single) | assistant | | mcp.prompt.result.message_content | Message content (single) | Hello |

Request Arguments (when recordInputs: true)

| Attribute | Description | Example | | ----------------------------- | ------------------------- | --------- | | mcp.request.argument.{name} | Serialized argument value | "hello" |

JSON-RPC Errors

| Attribute | Description | Example | | --------------------------- | ---------------------- | ---------------- | | rpc.jsonrpc.error_code | JSON-RPC error code | -32603 | | rpc.jsonrpc.error_message | JSON-RPC error message | Internal error |

What Gets Traced

  • Incoming requeststools/call, resources/read, prompts/get, etc. create SERVER spans that remain open until the response is sent
  • Outgoing responses — complete the corresponding request span with result attributes
  • Incoming notificationsnotifications/initialized, etc. create short-lived SERVER spans
  • Outgoing notificationsnotifications/tools/list_changed, etc. create CLIENT spans
  • Transport errors — connection errors create INTERNAL spans with ERROR status
  • Handler errors — exceptions in tool/resource/prompt handlers are recorded on the active span
  • Transport close — cancels any pending request spans with ERROR/cancelled status