Authorization: Bearer <your_api_key> and Content-Type: application/json.
Access control
Access to metrics is governed by the data access rules configured by your tenant. The server applies these rules automatically based on the caller’s identity—you don’t pass any RBAC or scoping fields in the request. What a caller can query (their own data, their team’s data, or tenant-wide data) depends entirely on the rules an admin has set up. See Configure Data Access for how these rules are defined and evaluated.Authentication
Get your API key
Get your API key
- Personal Access Token (PAT): Go to Access → Personal Access Tokens in your TrueFoundry dashboard
- Virtual Account Token (VAT): Go to Access → Virtual Account Tokens (requires admin permissions)
Quick start
inputTokens, outputTokens, costInUSD, timeToFirstTokenMs, interTokenLatencyMs, timePerOutputTokenLatencyMs) do not apply to MCP metrics; they are model-only signals. Use the Model Metrics datasource if you need them.- Distribution query
- Timeseries query
API reference
Post JSON to the endpoint above withAuthorization: Bearer <your_api_key> and Content-Type: application/json.
Request parameters
"2026-04-21T00:00:00.000Z")."2026-04-22T00:00:00.000Z")."mcpMetrics" for Gateway MCP metrics."distribution": returns aggregated rows (one row pergroupBycombination)."timeseries": returns time-bucketed rows (one row per bucket pergroupBycombination). Requiresinterval.
{ type, column } objects describing the aggregations to compute. When omitted, only the implicit total = COUNT(*) is returned.Supported aggregation types
Supported aggregation types
Supported aggregation columns
Supported aggregation columns
metadata. prefix (e.g. "metadata.environment").Available group-by fields
Available group-by fields
groupBy contains userEmail (without virtualaccount), the server auto-injects WHERE CreatedBySubjectType = 'user'. virtualaccount alone auto-injects 'virtualaccount'. When both appear, scope it yourself with createdBySubjectType if needed.<positive integer> <unit>, where <unit> is one of second, minute, hour, day, week, month, year (with or without a trailing s). Examples: "30 second", "5 minute", "1 hour", "1 day". Compound expressions like "1 hour 30 minute" are rejected.interval. Accepts a positive integer number of seconds (e.g. 3600 for hourly). Prefer interval in new code. If both are provided, interval wins.Filtering
Filters narrow down the rows that go into each aggregation and group. They are AND-combined; there is no OR-group support. The server enforces a per-field operator allow-list, so the exact subset of operators you can use depends on the field.- Field filters
- Metadata filters
fieldName:Filterable fields and allowed operators
Filterable fields and allowed operators
mcpServerName, method, toolName) accept only a narrow set of string operators (IN, NOT_IN, STRING_CONTAINS, STRING_STARTS_WITH, STRING_ENDS_WITH). EQUAL and NOT_EQUAL are only supported on userEmail, virtualAccount, and conversationID.Filter operators reference
Filter operators reference
team)Custom metadata, team unnesting, and combining filters
Custom metadata, team unnesting, and combining filters
- Filter:
{ "metadataKey": "environment", "operator": "EQUAL", "value": "prod" } - Group: include
"metadata.environment"in thegroupByarray (string literal, prefix ismetadata.).
team is in groupBy (or used as the column of an aggregation), the server transparently UNNESTs the Teams array CTE before applying RBAC. Callers don’t need to do anything extra. Rows whose Teams array is NULL or empty drop out naturally.Combining multiple filters. Filters are AND-combined:Query examples
Every example posts a JSON body to the endpoint above. To keep the snippets short, only thejson body is shown; the request wrapper is identical to the Quick start.
{"fieldName": "method", "operator": "IN", "value": ["tools/call"]} so toolName is populated.Distribution examples
Top servers by request count
Top servers by request count
Tool calls grouped by tool name
Tool calls grouped by tool name
tools/call and group by toolName:Method distribution per server
Method distribution per server
Latency percentiles by tool
Latency percentiles by tool
Distinct tools per server
Distinct tools per server
Exclude internal tools
Exclude internal tools
NOT_IN:High-latency tool calls
High-latency tool calls
Group by metadata
Group by metadata
Filter by team
Filter by team
Complex filter combination
Complex filter combination
Timeseries examples
Every timeseries query must includeinterval (or the deprecated intervalInSeconds). Buckets are expressed as <positive integer> <unit> strings like "5 minute", "1 hour", or "1 day".
Hourly request volume
Hourly request volume
Hourly tool-call counts
Hourly tool-call counts
Hourly p99 latency by server
Hourly p99 latency by server
Hourly method mix
Hourly method mix
5-minute traffic on a specific server
5-minute traffic on a specific server
Daily traffic over a week
Daily traffic over a week
Hourly counts by team
Hourly counts by team
Complex timeseries query
Complex timeseries query
Response format
Every successful response has the same outer shape:total: implicitCOUNT(*)for the row. Always present.<aggregationKey>: one key per requested aggregation. The key is<type><Column>in camelCase (e.g.countToolName,p99LatencyMs,countDistinctMcpServerName).<groupByKey>: one key pergroupByentry. The key is the lowerCamelCase form of the underlying column. Two special mappings:userEmailandvirtualaccountboth map tocreatedBySubjectSlugin the response.teammaps toteam(the value is a single unnested scalar, not an array). All othergroupBykeys preserve their lowerCamelCase name.
startTimestamp/endTimestamp: present only for timeseries responses. Bucket start and end as ISO 8601 timestamp strings;endTimestampequals the next bucket’sstartTimestamp. Distribution responses omit both.
Distribution response example
Distribution response example
Timeseries response example
Timeseries response example
groupBy is empty or omitted, the response collapses to a single row (or one row per timeseries bucket) summarising every MCP request inside the window.toolName rows are populated only for method = "tools/call"; rows for other methods will surface toolName: null in the response when grouped by it.Error responses
A malformed query returns400 Bad Request:
Common causes and other status codes
Common causes and other status codes
400:- Operator not allowed on this field, for example,
EQUALonmcpServerName(it supports onlyIN,NOT_IN, andSTRING_*operators). - Missing required
value(or wrong shape, e.g. scalar where array is expected forIN/BETWEEN). - Unknown field name for the datasource (e.g.
inputTokensonmcpMetrics). - Invalid
intervalformat (compound expressions, unrecognised unit, non-positive integer). - Missing required
intervalfor a timeseries query.
401 Unauthorized: missing or invalid bearer token.403 Forbidden: caller does not have permission for the requested scope.500 Internal Server Error: unexpected server error while executing the query.