Skip to main content

Module mcp_metrics

Module mcp_metrics 

Source
Expand description

Prometheus metrics for the MCP HTTP endpoints.

Tracks request counts, tool call counts, and tool call durations, labeled by endpoint type (agent / developer) and either the JSON-RPC method name or the MCP tool name. The status label is one of the McpCallStatus variants: ok, a lifecycle outcome, or the McpRequestError error type (e.g. ToolNotFound) for failures.

Structs§

McpMetrics
Metrics emitted by the MCP HTTP handlers.
ToolCallGuard
RAII guard for a single tools/call invocation. On drop, increments tool_calls_total with the current status and observes tool_call_duration_seconds via the embedded HistogramTimer’s own drop. Designed so that if the surrounding future is dropped before completion (e.g. by tokio::time::timeout), the metric still records with the default "cancelled" status instead of being silently lost.

Enums§

McpCallStatus
Closed set of outcomes recorded in the MCP status label. Keeping these as an enum (rather than free-form strings at the call sites) pins the metric’s label cardinality and stops typos from silently creating new label values. Mirrors oauth_metadata::MetricStatus.