Prerequisites
Access logging must be enabled in your Tyk Gateway configuration. Setaccess_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 singletools/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.
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. Addapi_type and the four mcp_ fields to the template to keep the MCP detail.
Example log records
A successfultools/call request produces a record similar to the following:
mcp_error_code set. Tyk reads the JSON-RPC body before it checks the key, so the record also has the primitive fields:
initialize lifecycle call produces a record with no mcp_primitive_type. Its mcp_primitive_name is the method name: