MCP observability
Review MCP-specific metrics, logs, and traces.
Before you begin
Complete an MCP guide, such as the stdio guide. This guide uses the agentgateway playground to interact with an MCP tool server, which generates metrics, logs, and traces.
View MCP metrics
You can access the agentgateway metrics endpoint to view MCP-specific metrics, such as the number of tool calls that were performed.
- Open the agentgateway metrics endpoint.
- Look for the
list_calls_total
metric. This metric shows the number of tool calls that were performed and includes important information about the call, such as:server
: The MCP server that was used for the tool call.name
: The name of the tool that was used.
View traces
-
Use
docker compose
to spin up a Jaeger instance with the following components:- An OpenTelemetry collector that receives traces from the agentgateway. The collector is exposed on
http://localhost:4317
. - A Jaeger agent that receives the collected traces. The agent is exposed on
http://localhost:14268
. - A Jaeger UI that is exposed on
http://localhost:16686
.
docker compose -f - up -d <<EOF services: jaeger: container_name: jaeger restart: unless-stopped image: jaegertracing/all-in-one:latest ports: - "127.0.0.1:16686:16686" - "127.0.0.1:14268:14268" - "127.0.0.1:4317:4317" environment: - COLLECTOR_OTLP_ENABLED=true EOF
- An OpenTelemetry collector that receives traces from the agentgateway. The collector is exposed on
-
Configure your agentgateway proxy to emit traces and send them to the built-in OpenTelemetry collector agent.
cat <<EOF > config.yaml config: tracing: otlpEndpoint: http://localhost:4317 randomSampling: true binds: - port: 3000 listeners: - routes: - policies: cors: allowOrigins: - "*" allowHeaders: - mcp-protocol-version - content-type - cache-control backends: - mcp: targets: - name: everything stdio: cmd: npx args: ["@modelcontextprotocol/server-everything"] EOF
-
Run your agentgateway proxy.
agentgateway -f config.yaml
-
Open the agentgateway playground and click Connect. Then, select a tool, such as
echo
, enter any message, and click Run Tool. -
Open the Jaeger UI and select the
call_tool
operation. Then, verify that you can see traces for your MCP tool call.
View logs
Agentgateway automatically logs information to stdout. When you run agentgateway on your local machine, you can view a log entry for each request that is sent to agentgateway in your CLI output.
Example for a successful MCP tool call:
2025-09-04T20:01:40.493660Z info mcp::sse new client message for /sse
session_id="6b497ee9-3710-428a-96d2-31ebeab73dcd"Request(JsonRpcRequest
{ jsonrpc: JsonRpcVersion2_0, id: Number(4), request: CallToolRequest(Request
{ method: CallToolRequestMethod, params: CallToolRequestParam { name: "echo",
arguments: Some({"message": String("hello world")}) }, extensions: Extensions }) })