# MCP Call Log

URL: https://www.elchi.io/docs/ai-gateway/mcp/call-log

> The MCP calls tab and the ClickHouse tables behind it: per-tool calls, failures and p95, every request the edges sent to an MCP server, and what is never recorded.

Every request the AI gateway's MCP proxy sends to an MCP server is recorded: who sent it, through which gateway, to which server and tool, what the server answered and how long it took. The record comes from Envoy's MCP egress, so it is what actually reached (or failed to reach) the server.

![The MCP calls tab](https://www.elchi.io/docs/img/docs/aigw-mcp-calls-light.webp)

## The MCP calls tab

**AI Gateway → MCP calls** (visible to project Owners and Admins only).

**Filters:** the window (**Last 15 minutes** … **Last 30 days**, default **Last 1 hour**), **MCP server**, **Gateway** (gateways serving MCP), **Consumer**, **Outcome**, and **Refresh**. The window is fixed when you pick it or press **Refresh**: paging does not move it.

### Tools

Per tool (`<server>__<tool>`) in the window, `tools/call` requests only:

| Column | Meaning |
|---|---|
| **Calls** | `tools/call` requests sent to the server. |
| **Failed** | Calls whose outcome is not `ok`, with their share; red from 5%. |
| **p95** | 95th percentile of the call's duration (ms). |
| **Sensitive data** | `blocked` and `flagged` sensitive-data decisions on the tool's arguments and results in the window. |

*"Tool calls in the window: refusals by the gateway (a tool not granted, a quota) never reach a server and are in the decision log, not here."* A tool that only has sensitive-data decisions (all its calls refused) is listed with 0 calls.

### Calls

Every request the edges sent to a server, newest first, 50 per page: tool calls, listings and the session's own requests (`initialize`, the GET stream).

| Column | Meaning |
|---|---|
| **Time** | When the request started. |
| **Consumer** | The consumer that sent it (empty: shown as —). |
| **Gateway** | The gateway serving it. |
| **Call** | `<server>__<tool>` for a tool call; `<server> · <method>` otherwise; `<server> · stream` for the session's GET stream. |
| **Outcome** | The HTTP status for `ok`; otherwise status and class (below). |
| **Duration** | Until the last byte went back (ms). |
| **Edge** | The client (edge) that sent it. |

A GET stream the server answers with 405 shows as *no stream (the server offers none)*: MCP allows a server without one, so it is not a failure.

### Outcome classes

| Class | UI label | When |
|---|---|---|
| `ok` | the status | The server answered below 400. |
| `auth_error` | refused the credential | The server answered 401 or 403. |
| `rate_limited` | rate limited | The server answered 429. |
| `client_error` | refused the request | Another 4xx from the server. |
| `server_error` | server error | 5xx from the server. |
| `unreachable` | unreachable | No connection: refused, DNS failure, TLS failure. |
| `timeout` | no answer in time | Envoy's request, duration or idle timeout. |
| `reset` | connection reset | The connection broke mid-answer, or a protocol error. |
| `egress_error` | egress error | The egress itself failed (no route for the server, the client gone). |

The first five are what the server answered (Envoy saw the response come from upstream); the next three are Envoy's view of the connection.

## API

```bash
curl -s "$ELCHI/api/v3/ai-gateway/mcp-calls?project=$PROJECT&from=2026-12-05T00:00:00Z&to=2026-12-05T12:00:00Z&server=github&class=auth_error&limit=50&offset=0" \
  -H "Authorization: Bearer $TOKEN"
```

| Parameter | |
|---|---|
| `from`, `to` | RFC 3339. Defaults: the last 24 hours. At most 90 days. |
| `gateway`, `consumer`, `server`, `tool`, `class` | Exact filters. |
| `limit`, `offset` | Page of calls; `limit` 1–500 (default 50). |

Answer: `data.calls[]` (`ts`, `instance_id`, `gateway`, `consumer`, `server`, `method`, `tool`, `status`, `class`, `duration_ms`), `data.total`, and `data.tools[]` (`server`, `tool`, `calls`, `errors`, `p95_ms`, `blocked`, `flagged`; at most 200 tools). Owners and Admins only.

## ClickHouse tables

The edges write the log; the control plane reads it.

**`elchi_ai_gateway_mcp_calls`**: one row per request to a server.

| Column | Type | |
|---|---|---|
| `ts` | DateTime64(3) | Start of the request |
| `instance_id` | LowCardinality(String) | The edge |
| `project` | LowCardinality(String) | |
| `gateway` | LowCardinality(String) | |
| `consumer` | LowCardinality(String) | |
| `server` | LowCardinality(String) | |
| `method` | LowCardinality(String) | `tools/call`, `tools/list`, `initialize`, …; empty for the GET stream |
| `tool` | LowCardinality(String) | The tool's own name (without the server prefix) |
| `status` | UInt16 | HTTP status |
| `class` | LowCardinality(String) | Outcome class (above) |
| `duration_ms` | UInt32 | |

Partitioned by day, ordered by `(project, server, ts)`. Retention: the AI gateway's `usage.clickhouse_ttl_days` (default 90, at most 365). The table name can be changed with `--mcp-calls-table` (env `ELCHI_AI_GATEWAY_MCP_CALLS_TABLE`); the backend reads `elchi_ai_gateway_mcp_calls`.

**`elchi_ai_gateway_mcp_calls_1h`**: an hourly rollup (SummingMergeTree filled by a materialized view on every insert): per UTC hour, project, gateway, consumer, server, method, tool, class and latency bucket (`floor(log_1.15(duration_ms))`, the request log's buckets), a count `n`. Kept 90 days. Never backfilled: it starts counting when the view is first created.

The edge also reads the call log: the **Tool calls per day** quota adds the other edges' `tools/call` rows of the UTC day.

Edge metrics (`/metrics` of the AI gateway): `elchi_ai_gateway_mcp_calls_total{server, class}`, `elchi_ai_gateway_mcp_call_rows_written_total`, `elchi_ai_gateway_mcp_call_rows_dropped_total`.

## What is recorded, and what is not

**Recorded:** time, edge, project, gateway, consumer, server, JSON-RPC method, tool name, HTTP status, outcome class, duration.

**Never recorded:**

- Tool **arguments** and **results**, prompts, resources, any message body.
- The consumer key, the shared credential, users' personal tokens, any header value.
- The server's URL.
- Calls the gateway refused (not granted, over quota, malformed, blocked by the sensitive-data policy): they never reached a server and are in the decision log (`elchi_ai_gateway_decisions`, phase `mcp` or `mcp_result`) instead. See [Grants and quotas](https://www.elchi.io/docs/ai-gateway/mcp/grants-and-quotas#what-a-refused-call-returns).

MCP traffic does not appear in the [request log](https://www.elchi.io/docs/ai-gateway/request-log) or the token usage: it is not a model request.

## When the log is empty

- No ClickHouse DSN on the edge: nothing is written (the gateway keeps serving; observability is best-effort).
- ClickHouse unreachable: rows are queued and failed batches retried with backoff; a row is dropped when the queue is full or its batch keeps failing, and counted in `elchi_ai_gateway_mcp_call_rows_dropped_total`. The gateway never waits for ClickHouse.
- No call reached a server: check the decision log for refusals, and the **MCP servers** tab for *"MCP is not served yet"*.
