Skip to content

[Feature]: Add per-tool metrics for MCP tool invocations #8201

@rite7sh

Description

@rite7sh

Requirement

As a Jaeger operator, I want metrics for each MCP tool call,so that I can understand tool usage, latency, and errors.

Problem

The jaegermcp extension does not expose metrics for individual MCP tools.

Current logging works at the JSON-RPC level. It tracks methods like tools/call, but it does not show which tool ran.

Because of this, we cannot see:

  • which tools are used most
  • which tools are slow
  • which tools fail often

This makes it hard to debug and improve MCP behavior.

Image

Proposal

Add per-tool metrics for MCP tool calls in jaegermcp.

Start with two metrics:

  • request count
  • latency

Each metric should include:

  • tool name
  • result (ok or error)

Design:

Wrap each tool handler at registration time.

Example:

instrumentTool(toolName, handler)

The wrapper will:

  • count each call
  • measure latency
  • record result (ok or error)

Send metrics through OpenTelemetry to the backend. Keep the logic in one place. Do not change individual handlers.

Follow-up work can include:

  • request and response size
  • more result types
  • protocol-level metrics
Image

(the diagram is simplified for ease of understanding )

Open questions

  • Should we use Jaeger metric names like requests and latency under jaeger.mcp?

  • Do we also want metrics at the method level (tools/call)?

  • Should we split result into handler error and protocol error?

  • Should we also add request and response size, more result types, and protocol-level metrics in a later step? ( I think yes this can give better visibility into tool behavior.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions