Skip to main content

Metrics Collection

MCP Gatekeeper automatically collects performance metrics from all MCP servers.

Collected Metrics

STDIO Servers

  • Tool Call Count: Number of times each tool is called
  • Latency: Response time per tool call
  • Success Rate: Percentage of successful calls
  • Error Count: Failed tool calls
  • Agent Attribution: Which agent made the call

HTTP Servers

  • Request Count: Total HTTP requests proxied
  • Response Codes: Status code distribution
  • Latency: Request/response time
  • Error Rate: Failed requests percentage
  • Agent Attribution: Extracted from URL path

Collection Methods

STDIO Wrapper

When packages are installed, MCP Gatekeeper:

  1. Replaces the binary entry point with a wrapper
  2. Wrapper intercepts STDIO communication
  3. Metrics extracted from JSON-RPC messages
  4. Metrics sent to /api/metrics/record
  5. Original execution continues transparently

HTTP Proxy

For HTTP servers:

  1. All requests pass through the proxy
  2. Proxy measures request/response timing
  3. Status codes and errors captured
  4. Metrics stored in database
  5. Real-time broadcast via WebSocket

Viewing Metrics

Metrics Page

Navigate to Metrics to view:

  • Tool call distribution charts
  • Latency histograms
  • Error rate trends
  • Time series data
  • Agent breakdown

Server Activity Page

Per-server metrics:

  • Individual server statistics
  • Tool-by-tool breakdown
  • Performance trends
  • Recent activity

Dashboard

High-level overview:

  • Total tool calls
  • Average latency
  • Error count
  • Active servers

Metrics Storage

Metrics are stored in SQLite database:

  • Retention: All metrics kept indefinitely
  • Aggregation: Pre-computed summaries for performance
  • Cleanup: Manual cleanup available

API Access

Metrics available via REST API:

  • GET /api/metrics/summary - Overall summary
  • GET /api/http-servers/{id}/metrics - HTTP server metrics
  • Real-time updates via WebSocket

For details, see Metrics API.

Privacy

Metrics collection:

  • Local only (stored in SQLite)
  • No external transmission
  • Full data control
  • Can be disabled by not using the wrapper