Skip to main content
When Tyk Gateway processes an MCP request, it adds four MCP-specific fields to the structured access log record for that request. These fields let you filter, aggregate, and analyze MCP traffic in your log management tooling using the same access log pipeline you use for REST APIs. For an overview of all MCP observability signals, see MCP observability.

Prerequisites

Access logging must be enabled in your Tyk Gateway configuration. Set access_logs.enabled to true in tyk.conf. See Enabling Access Logs.

MCP fields

The following fields are added to access log records for MCP requests. Each field is only included when it has a non-empty value; fields are omitted from the record entirely when not applicable. The mcp_error_code field reflects errors that occur within the gateway: authentication failures, rate limit rejections, and upstream errors. It never carries error codes from within the upstream MCP server’s JSON-RPC response body. A gateway error always has a 4xx or 5xx HTTP status, never 200. Tyk maps the HTTP status of a gateway error to a JSON-RPC error code: The codes -32005 and -32006 are reserved. Tyk does not currently return them.

Access logs when the proxy fronts a Tyk-managed REST API

When an MCP proxy is generated directly from a Tyk-managed REST API rather than fronting a remote MCP server, a single tools/call request produces two separate access log entries when access logs are enabled on the Gateway. The first entry is for the MCP proxy request itself, and carries the MCP fields described above. The second is for Tyk’s internal call into the paired source REST API, dispatched through the gateway’s standard request handling. That second entry has no MCP fields at all: its api_type reflects the source API’s own type (oas for a Tyk OAS API), and it is otherwise indistinguishable from a request made directly against that API.
If OpenTelemetry tracing is enabled alongside access logging, both entries carry the same trace_id: Tyk dispatches the internal call to the source API within the same trace as the originating MCP request, so the two entries are spans of one trace rather than unrelated hits. Without tracing enabled, there is no shared identifier between the two entries, so correlate them by timestamp. The proxy’s own latency_total includes the time spent on the source API call, so it is always the larger of the two figures.
This dual-record pattern isn’t unique to access logs. The Dashboard’s MCP analytics charts, and the Tyk Pump analytics pipeline underneath them, follow the same rule: only the MCP proxy’s own record is recorded as MCP traffic, so the source API’s analytics include this internal traffic indistinguishably alongside any direct hits it receives. See Tyk Pump for how analytics records are processed and stored.

Configuring which fields to include

By default, each record includes all available fields. To log only some fields, use an access log template. See Access Log Templates. Add api_type and the four mcp_ fields to the template to keep the MCP detail.

Example log records

A successful tools/call request produces a record similar to the following:
A request that fails at the gateway due to a missing or invalid key produces a record with mcp_error_code set. Tyk reads the JSON-RPC body before it checks the key, so the record also has the primitive fields:
An initialize lifecycle call produces a record with no mcp_primitive_type. Its mcp_primitive_name is the method name: