Activity Log
MCPProxy records AI agent tool calls, policy decisions, and system events in a local activity log. This supports debugging and after-the-fact inspection. Records are kept subject to configurable retention (age, record count and total size) and a per-record response size cap (see Configuration), so the log is not a complete or tamper-proof audit trail and is not a regulatory compliance certification.
What Gets Logged
The activity log captures:
| Event Type | Description |
|---|---|
tool_call | Every tool call made through MCPProxy |
system_start | MCPProxy server startup events |
system_stop | MCPProxy server shutdown events |
internal_tool_call | Internal proxy tool calls (retrieve_tools, call_tool_*, code_execution, etc.) |
config_change | Configuration changes (server added/removed/updated) |
policy_decision | Tool calls blocked by policy rules |
quarantine_change | Server quarantine/unquarantine events |
server_change | Server enable/disable/restart events |
credential_broker | Per-user oauth_connect consent/callback outcomes (connect is the only action ever recorded; the credential is stored, never injected) — server edition only |
System Lifecycle Events
System lifecycle events track when MCPProxy starts and stops:
{
"id": "01JFXYZ123DEF",
"type": "system_start",
"status": "success",
"timestamp": "2025-01-15T10:00:00Z",
"metadata": {
"version": "v0.5.0",
"listen_address": "127.0.0.1:8080",
"startup_duration_ms": 150,
"config_path": "/Users/user/.mcpproxy/mcp_config.json"
}
}
Internal Tool Call Events
Internal tool calls log when internal proxy tools are used:
{
"id": "01JFXYZ123GHI",
"type": "internal_tool_call",
"status": "success",
"duration_ms": 45,
"timestamp": "2025-01-15T10:05:00Z",
"metadata": {
"internal_tool_name": "call_tool_read",
"target_server": "github-server",
"target_tool": "get_user",
"tool_variant": "call_tool_read",
"intent": {
"operation_type": "read",
"data_sensitivity": "public"
}
}
}
By default, all call_tool_* internal tool calls (call_tool_read, call_tool_write, call_tool_destructive) are excluded from activity listings — every dispatch (successful, failed, or shed) has a corresponding upstream tool_call or rejection record carrying the same request_id, so showing both would double-count the call.
To include the call_tool_* records anyway, use include_call_tool=true in the API query parameter.
Config Change Events
Configuration changes are logged for audit trails:
{
"id": "01JFXYZ123JKL",
"type": "config_change",
"server_name": "github-server",
"status": "success",
"timestamp": "2025-01-15T10:10:00Z",
"request_id": "req_01JFXYZ",
"metadata": {
"action": "server_added",
"affected_entity": "github-server",
"source": "api",
"actor_kind": "api_key",
"surface": "web",
"new_values": {
"protocol": "http",
"enabled": true,
"quarantined": true,
"url": "https://api.github.com/mcp"
}
}
}
One row is written per server change on every door — the REST API and the CLI
(which calls it), the Web UI and macOS app, and the upstream_servers MCP tool:
server_added, server_updated (with changed_fields and the before/after
values of those fields only), server_removed (with what the removal purged,
see purged), server_enabled / server_disabled. Credentials in url,
headers and env values are redacted the same way on every row.
Who changed it. A row written for an authenticated request carries the
caller under the same keys a profile_change row uses: actor_kind (api_key,
socket for the tray / CLI socket bypass, agent_token, bearer_jwt,
cookie, anonymous), actor_name (the agent token name or user email, when
there is one) and surface (web, macos, cli, mcp, api); request_id
joins the row to the HTTP request (X-Request-Id) or MCP call that made it.
quarantine_change rows carry the same three keys and request_id when an
operator or agent quarantined or approved the server. A change with no caller
behind it — a config file edited on disk and hot-reloaded, the admission gate
quarantining a server at load — carries none of them, so an absent actor means
"no request", never an unknown one. Filter the administrative rows with
type=config_change,quarantine_change,profile_change and read the actor keys
from metadata.
Tool Call Records
Each tool call record includes:
{
"id": "01JFXYZ123ABC",
"type": "tool_call",
"server_name": "github-server",
"tool_name": "create_issue",
"tool_variant": "call_tool_write",
"arguments": {"title": "Bug report", "body": "..."},
"response": "Issue #123 created",
"status": "success",
"duration_ms": 245,
"duration_us": 245310,
"timestamp": "2025-01-15T10:30:00Z",
"session_id": "mcp-session-abc123",
"request_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"intent": {
"operation_type": "write",
"data_sensitivity": "internal",
"reason": "Creating bug report per user request"
}
}
Duration: duration_ms and duration_us
duration_ms is the run time in whole milliseconds; it is left out when it
is 0. duration_us is the run time in microseconds, present only when the
call was measured (it can be 0). A call that took under a millisecond has
duration_us and no duration_ms; the Web UI and the CLI show it as <1ms.
A row with neither field was not measured: the call was refused before it was
sent (a blocking policy decision, an invalid_params refusal, a sandbox
sub-call the policy gate blocked), it failed before any request reached the
upstream (cancelled while queued, server disconnected), the row is not a
call, or it is a fast call
stored before duration_us existed (old rows are not rewritten). The Web UI
shows nothing for such a row.
Sub-calls made by code_execution
Every upstream tool call a sandboxed code_execution script makes that reaches
authorization or dispatch is recorded (a call_tool() refused with
MAX_TOOL_CALLS_EXCEEDED writes nothing; ordinary records travel through the
event bus and can be lost when it is saturated, while admission sheds are written
directly) as a first-class tool_call record with its own request_id and a parent_id
equal to the parent code_execution record's request_id (a sub-call shed
at admission, queue_full or queue_timeout on a queue or rate_limited by a
per-token limit, is recorded without parent_id, while a queue that closed
under a waiting sub-call gives a linked error row (server_unavailable is
the limiter's internal reason there, not a stored error_class); source is
internal; a sub-call the proxy refuses to send, or to retry after a first
attempt reached the upstream, is recorded with status blocked when one of
these checks refused it: an authorization, profile or policy denial before
dispatch, a review that was not recorded (re-checked after the slot wait and
again as the request goes out), a connection that changed under a call pinned
to a connection generation (also while it waited for a slot), and a tool whose
identity no longer matches the snapshot the call took after admission when the
proxy verifies it just before the first send (pinned or not, whether a
tools/list refresh or a restored upstream session changed it; a tools/list update on
the same session published after that verification does not by itself trigger
another identity comparison, though the review re-check as the request goes
out still applies,
while a session re-initialized in that gap makes the proxy verify again before
anything is sent) or,
after an expired session was restored, before a retry of a pinned call. Any refusal raised inside the send itself (the review-state re-check
made as the request goes out, or the identity and pinned-generation checks) is
an error row instead when the server's connection instance was retired (the
server replaced, removed, quarantined or disabled) while that send was in flight; refusals from the
checks made right after the slot wait stay blocked. A send given up
because the upstream session was re-initialized repeatedly before it could go
out, and a retry the proxy skips after restoring an expired upstream session
because the tool is not read-only or because an unpinned call's tool identity
changed, are error rows, and a call whose upstream response output
sanitisation blocks is a linked error row next to a separate blocked policy
decision; when
the refusal comes from the caller's profile it also carries block_reason:
profile_tier, profile_rule or profile_unannotated; a sub-call to a
server outside the caller's profile carries profile_server_scope. The
refusal text the script sees is unchanged, and a legacy token refused only by
its own server list carries no block_reason).
Filter with parent_id=<parent request_id> to list a script's sub-calls, or
request_id=<child's parent_id> to find the parent if its row was stored
(administrators only: the parent row has no server, so a scoped token's list
never includes it; the parent row travels through the same event bus, so a
child's parent_id still lists its stored siblings when the parent row was lost;
request_id= also matches a REST row whose X-Request-Id reused that id, so
the Web UI drawer and the macOS Activity window take only an internal_tool_call
row with tool code_execution whose own request_id is that id, and page past
other matches, up to 2,000 of them; past that, page through
mcpproxy activity list --request-id <id> --type internal_tool_call --tool code_execution --limit 100 --offset <n> -o json
and take the row whose own request_id is that id) — the Web UI drawer, the
macOS Activity window, and mcpproxy activity list --parent-id all expose the
same navigation (see the "Drill into a code_execution" workflow in the CLI
activity commands reference).
Failure classification: error_class and fault_domain
A failed tool call tells you what failed and whose fault it is. Every
tool_call record with status: "error" (and a limiter shed or profile
refusal) carries three optional fields, in the REST API, the SSE
activity.tool_call.completed payload and mcpproxy activity list|show -o json|yaml:
| Field | Meaning |
|---|---|
error_class | What failed, one of the classes below |
fault_domain | upstream (the server or the network to it), proxy (mcpproxy refused or failed) or client (the caller sent something invalid or went away) |
upstream_http_status | The HTTP status of the upstream response, when known (non-2xx only) |
error_class | Typical fault_domain | When |
|---|---|---|
tool_error | upstream | The tool answered isError: true. The record keeps status: "error"; this class tells it apart from a transport failure. |
jsonrpc | upstream | The upstream answered with a JSON-RPC error, including server-specific codes such as -32001. |
http | upstream | The upstream answered with a non-2xx HTTP status (for example 502 with an HTML body); upstream_http_status is set. |
network | upstream | Connection refused or reset, DNS failure, EOF, closed transport, or the server is not connected. |
timeout | upstream or proxy | A deadline passed: upstream if the request had been sent, proxy if it expired before dispatch. |
session_terminated | upstream | The upstream no longer knows the MCP session (HTTP 404). |
auth | upstream | HTTP 401/403 or an OAuth authorization-required error. |
proxy_policy | proxy or client | mcpproxy refused the call: a profile policy, the concurrency limiter, or a stale connection generation (proxy); arguments that failed pre-dispatch validation (client). |
proxy_internal | proxy | A failure inside mcpproxy that no other class explains. |
cancelled | client | The caller cancelled the request. Not counted as an upstream fault. |
The fields are absent on successful calls and on records written before this
feature, which decode and display exactly as before. Filter with
error_class=<class> and fault_domain=<domain> (REST), or
--error-class and --fault-domain (CLI). The Spec 107 audit line keeps its
own error_class vocabulary; it is derived from this classification so the
two never disagree.
Intent Tracking
Every tool call includes intent information for security auditing:
| Field | Description |
|---|---|
tool_variant | Which tool was used: call_tool_read, call_tool_write, call_tool_destructive |
variant_duration_ms, variant_duration_us | On a tool_call row carried by a call_tool_* variant: how long that variant call took end to end (the time the agent waited), next to the row's own upstream duration_ms. The same duration the call_tool_* row records. Absent on rows written by v0.76.0 and earlier, and on calls no variant carried (REST, code_execution sub-calls). |
intent.operation_type | Agent's declared intent: read, write, destructive |
intent.data_sensitivity | Data classification: public, internal, private, unknown |
intent.reason | Agent's explanation for the operation |
Sensitive Data Detection
Activity records automatically include sensitive data detection metadata when MCPProxy detects potentially sensitive information in tool arguments or responses. This helps identify data handling patterns. Detection only flags records; it does not block the call by default (see what detection does and does not do).
{
"id": "01JFXYZ123ABC",
"type": "tool_call",
"server_name": "github-server",
"tool_name": "create_issue",
"status": "success",
"metadata": {
"sensitive_data_detection": {
"detected": true,
"categories": ["api_key", "email"],
"argument_detections": [
{
"field": "body",
"category": "api_key",
"confidence": 0.95
}
],
"response_detections": [
{
"field": "author.email",
"category": "email",
"confidence": 0.99
}
]
}
}
}
| Field | Description |
|---|---|
detected | Whether any sensitive data was detected |
categories | List of detected sensitive data categories |
argument_detections | Detections in tool call arguments |
response_detections | Detections in tool call responses |
Filter activity by sensitive data:
# Show only activity with detected sensitive data
mcpproxy activity list --has-sensitive-data
# Filter by specific category
mcpproxy activity list --sensitive-category api_key
# REST API
curl -H "X-API-Key: $KEY" "http://127.0.0.1:8080/api/v1/activity?has_sensitive_data=true"
curl -H "X-API-Key: $KEY" "http://127.0.0.1:8080/api/v1/activity?sensitive_category=api_key"
See Sensitive Data Detection for details on detection categories, configuration options, and compliance use cases.
Filter by intent type:
# Show only destructive operations
mcpproxy activity list --intent-type destructive
# REST API
curl -H "X-API-Key: $KEY" "http://127.0.0.1:8080/api/v1/activity?intent_type=destructive"
See Intent Declaration for details on the intent-based permission system.
Request ID Correlation
Most activity records written for a request carry a request_id; system events such as system_start have none, and some request-caused rows store no id at all (a tool_quarantine_change written by a REST tool approval, for one), so no id lookup finds them. For a tool call dispatched through call_tool_* (MCP or REST) it is the id of that attempt, minted by MCPProxy: every row the attempt wrote (the tool_call, a blocking policy_decision, the call_tool_* row) carries it. Tool-call rows written for a REST request (from this release on; older rows are not backfilled) also carry that request's X-Request-Id as transport_request_id; a caller-sent X-Request-Id that contains a credential the same request presents (any non-empty Authorization token, X-API-Key or ?apikey= value, whatever its length, or a cookie value of 16 bytes or more), contains the admin API key on a socket connection (TCP has no separate admin-key check: there the key counts only when the request presents it), or is credential-shaped (the shapes the audit log masks) is replaced by a fresh UUID when the request arrives, as is one sent with more than 32 such values or whose raw query string plus every Authorization, X-API-Key and Cookie header field (each field counted at its raw length plus 64 bytes, and every ; in a Cookie field at another 62, so HTTP/2's ; -joined Cookie field costs exactly what separate fields do) exceed 16 KiB (the REST reference has the full rule), so always look up the X-Request-Id the response returned; some other REST-written rows (a preflight, a configuration change) use the X-Request-Id as their request_id directly. The request_id filter matches either field, so the X-Request-Id of a REST response finds the rows that request wrote and the reader may see (a request refused before anything was recorded, such as a malformed body, wrote none; call_tool_* rows are listed only with include_call_tool=true). On /mcp an X-Request-Id the client sends is not recorded as transport_request_id, so it plays no part in activity lookups; use the row's request_id for MCP calls. A non-administrator caller sees and matches transport_request_id only on rows its own token wrote, and the filter never widens the rows it may see (a refused call on a server outside its reach can leave a row it cannot list). A caller that sends its own X-Request-Id and reuses a value can match rows from more than one request. This is useful for:
- Error debugging: When an API error occurs, the error response includes the
request_id. Use it to find related activity:
# Error response includes request_id
# { "error": "tool call failed", "request_id": "abc123..." }
# Find activity for that request
mcpproxy activity list --request-id abc123...
-
Request tracing: Find the stored tool-call activity you may see for a request. The sub-calls of a
code_executionrun are found withparent_id=<the run's request_id>, which finds only the linked sub-calls: a sub-call shed at admission (queue_fullorqueue_timeouton a concurrency queue, per upstream or proxy-wide, orrate_limitedby a per-token rate limit) is recorded withoutparent_id. For a run started over REST,GET /api/v1/activity?request_id=<the X-Request-Id the response returned>(oractivity list --request-id) also finds the stored sub-calls it caused whosetransport_request_idthe reader may see (an administrator: all of them; a scoped token: only those its own token wrote, so it cannot find another token's run this way even where it lists that run's sub-calls): each stores that value as itstransport_request_id, while its ownrequest_idstays the sub-call's attempt id. Acall_tool()the sandbox refuses before authorization or dispatch (MAX_TOOL_CALLS_EXCEEDED) writes no row at all, unlike an admission shed, which writes arejectedrow. A run started over MCP, or written before this release, has no transport id:parent_idthen finds its linked sub-calls, and a sub-call shed at admission carries neither link, so no activity-log id lookup ties it to the run (look for it by time and server instead, since the refusal row carries no MCPsession_id; when the audit log is enabled, itstool_callline for that refusal keepsparent_id). -
Log correlation: Server log lines written through a REST request's own logger carry its
X-Request-Idasrequest_id(theHTTP API Requestaccess line inhttp.logand some warnings, such as a rate-limit shed, do not), which is the row'stransport_request_idwhen stored and visible to the reader (or itsrequest_idfor rows that use theX-Request-Iddirectly).
Filter by request ID:
# CLI
mcpproxy activity list --request-id a1b2c3d4-e5f6-7890-abcd-ef1234567890
# REST API
curl -H "X-API-Key: $KEY" "http://127.0.0.1:8080/api/v1/activity?request_id=a1b2c3d4-e5f6-7890-abcd-ef1234567890"
CLI Commands
MCPProxy provides dedicated CLI commands for activity log access. See the full Activity Commands Reference for details.
Quick Examples
# List recent activity
mcpproxy activity list
# List last 10 tool call errors
mcpproxy activity list --type tool_call --status error --limit 10
# Watch activity in real-time
mcpproxy activity watch
# Show activity statistics
mcpproxy activity summary --period 24h
# View specific activity details
mcpproxy activity show 01JFXYZ123ABC
# Export for compliance
mcpproxy activity export --output audit.jsonl
Available Commands
| Command | Description |
|---|---|
activity list | List activity records with filtering and pagination |
activity watch | Watch real-time activity stream via SSE |
activity show <id> | Show full details of a specific activity |
activity summary | Show aggregated statistics for a time period |
activity export | Export activity records to file (JSON/CSV) |
All commands support --output json, --output yaml, or --json for machine-readable output.
REST API
List Activity
GET /api/v1/activity
Query Parameters:
| Parameter | Type | Description |
|---|---|---|
type | string | Filter by type (comma-separated for multiple): tool_call, system_start, system_stop, internal_tool_call, config_change, policy_decision, quarantine_change, server_change, credential_broker (server edition; connect-flow outcomes only) |
server | string | Filter by server name |
tool | string | Filter by tool name |
session_id | string | Filter by MCP session ID |
request_id | string | Filter by request ID: matches a row's request_id (for a call_tool_* dispatch, the attempt id) or its transport_request_id (the REST X-Request-Id). A non-administrator caller matches transport_request_id only on rows its own token wrote; the filter never widens the rows a caller may see |
status | string | Filter by status: success, error, blocked |
start_time | string | Filter after this time (RFC3339) |
end_time | string | Filter before this time (RFC3339) |
limit | integer | Max records (1-100, default: 50) |
offset | integer | Pagination offset (default: 0) |
include_call_tool | boolean | Include call_tool_* internal tool calls (default: false). Excluded by default because every dispatch has a paired tool_call (or rejection) record with the same request_id. |
parent_id | string | Return only the sub-calls one code_execution issued (value = the parent record's request_id). Child→parent is the reverse lookup: request_id=<child's parent_id>. |
error_class | string | Return only failed calls of this class: network, timeout, http, jsonrpc, tool_error, session_terminated, auth, proxy_policy, proxy_internal, cancelled. See Failure classification. |
fault_domain | string | Return only failed calls with this fault domain: upstream, proxy, client |
exclude_payloads | boolean | Omit the bulky fields — arguments, response — and narrow metadata to a contextual whitelist (default: false). See below. |
exclude_payloads and the contextual metadata whitelist
exclude_payloads=true is a projection, not a filter: it never changes which
records match, only how much of each record is serialized. It exists for clients
that poll frequently and render summary fields only (the macOS tray glance polls
the newest 100 records on every menu open). Measured against a real log those
100 records are ~848 KB whole and ~30 KB projected.
The projection drops arguments and response entirely, and keeps only these
metadata keys:
| Kept key | Why |
|---|---|
intent.reason | The caller's stated reason, rendered as the row subtitle |
intent.operation_type | read / write / destructive |
decision | blocked, warned, … for policy_decision records |
reason | Why a policy decision blocked or warned |
client_name | Which MCP client made the call |
client_version | Its version |
Everything else in metadata — sensitive-data detection payloads, toon
renderings, classifier scores, raw intent objects — is dropped. Whitelisted keys
that a record does not have are simply omitted, and a record whose metadata is
entirely non-whitelisted serializes with no metadata object at all.
Every kept key is kept only when its value is a string. A whitelisted key is
not a promise about its value: a producer that writes a structured error under
reason would otherwise smuggle that whole payload through the projection, so
non-string values are dropped like any other non-whitelisted content.
Two things survive the projection deliberately:
has_sensitive_datais derived frommetadatabefore it is narrowed, so the flag outlives its source.request_idis a top-level field, not metadata, so correlation still works on projected responses.
Fetch the full record with GET /api/v1/activity/{id} when a client needs the
arguments, the response, or any non-whitelisted metadata.
Example:
# List recent tool calls
curl -H "X-API-Key: $KEY" "http://127.0.0.1:8080/api/v1/activity?type=tool_call&limit=10"
# Filter by multiple types (comma-separated)
curl -H "X-API-Key: $KEY" "http://127.0.0.1:8080/api/v1/activity?type=tool_call,internal_tool_call,config_change"
# List system lifecycle events
curl -H "X-API-Key: $KEY" "http://127.0.0.1:8080/api/v1/activity?type=system_start,system_stop"
# Filter by server
curl -H "X-API-Key: $KEY" "http://127.0.0.1:8080/api/v1/activity?server=github-server"
# Filter by time range
curl -H "X-API-Key: $KEY" "http://127.0.0.1:8080/api/v1/activity?start_time=2025-01-15T00:00:00Z"
# Summary-only poll: no arguments/response, metadata narrowed to the whitelist
curl -H "X-API-Key: $KEY" "http://127.0.0.1:8080/api/v1/activity?type=tool_call,internal_tool_call,policy_decision&limit=100&exclude_payloads=true"
Response:
{
"success": true,
"data": {
"activities": [
{
"id": "01JFXYZ123ABC",
"type": "tool_call",
"server_name": "github-server",
"tool_name": "create_issue",
"status": "success",
"duration_ms": 245,
"timestamp": "2025-01-15T10:30:00Z"
}
],
"total": 150,
"limit": 50,
"offset": 0
}
}
Get Activity Detail
GET /api/v1/activity/{id}
Returns full details including request arguments and response data.
Export Activity
GET /api/v1/activity/export
Export activity records for compliance and auditing.
Query Parameters:
| Parameter | Type | Description |
|---|---|---|
format | string | Export format: json (JSON Lines) or csv |
| (filters) | Same filters as list endpoint |
Example:
# Export as JSON Lines
curl -H "X-API-Key: $KEY" "http://127.0.0.1:8080/api/v1/activity/export?format=json" > activity.jsonl
# Export as CSV
curl -H "X-API-Key: $KEY" "http://127.0.0.1:8080/api/v1/activity/export?format=csv" > activity.csv
# Export specific time range
curl -H "X-API-Key: $KEY" "http://127.0.0.1:8080/api/v1/activity/export?start_time=2025-01-01T00:00:00Z&end_time=2025-01-31T23:59:59Z"
Real-time Events
Activity events are streamed via SSE for real-time monitoring:
curl -N "http://127.0.0.1:8080/events?apikey=$KEY"
Events:
| Event | Description |
|---|---|
activity.tool_call.started | Tool call initiated |
activity.tool_call.completed | Tool call finished (success or error) |
activity.policy_decision | Tool call blocked by policy |
Example Event:
event: activity.tool_call.completed
data: {"id":"01JFXYZ123ABC","server":"github-server","tool":"create_issue","status":"success","duration_ms":245}
Configuration
Activity logging is enabled by default. Configure via mcp_config.json:
{
"activity_retention_days": 90,
"activity_max_records": 400000,
"activity_max_size_mb": 256,
"session_retention_days": 7,
"activity_max_response_size": 65536,
"activity_cleanup_interval_min": 60
}
| Setting | Default | Description |
|---|---|---|
activity_retention_days | 90 | Days to retain activity records |
activity_max_records | 400000 | Maximum records before pruning. The default was 100000 in earlier releases; a config file that already holds an explicit 100000 keeps it. |
session_retention_days | 7 | How long a work session is listed and kept whole. Read at start. Independent of activity_retention_days. |
activity_max_size_mb | 256 | Maximum total activity-log size in MB before pruning oldest (0 disables). Runs alongside the age and count caps to bound config.db growth when records carry large payloads. An explicit 0 now survives a config save — before #1175 it was silently deleted on the next write and the 256MB cap came back. |
activity_max_response_size | 65536 | Max response text stored per record (bytes). Applies to tool_call, internal_tool_call and prompt_get; 0 or absent falls back to 65536 and it cannot be disabled. Read at startup only, like its retention siblings. Truncated text keeps a ...[truncated] suffix. Already-stored records are not rewritten, and (as with pruning) the BBolt file does not shrink on disk. Sensitive-data detection still scans the untruncated response, under its own sensitive_data_detection.max_payload_size_kb cap. |
activity_cleanup_interval_min | 60 | Background cleanup interval (minutes) |
Why the size cap? The age and count caps alone do not bound disk: with large per-record payloads the log can reach hundreds of MB while still under the record cap and 90 days.
activity_max_size_mbbrings the log back within the byte budget (always keeping the newest record). Note: pruning frees pages for reuse but does not shrink the database file on disk (BBolt does not return freed pages to the OS).
What is removed when a cap is reached
The caps are unchanged; what they remove is chosen so that a work session inside the retention window stays whole for as long as possible:
- Summaries older than
session_retention_daysare dropped. Their rows stay readable through the ordinary activity filters until the log prunes them. - The age cap (
activity_retention_days) removes old rows as before. A session that loses rows this way is marked as truncated and keeps its lifetime counts. - Over the size or record cap, in this order:
- the argument and response bodies of the oldest rows are removed and the rows are kept, so the time, result, error class and order of every call survive (
bodies_removed: trueon the row); - rows that belong to no session inside the window are removed, oldest first;
- whole sessions inside the window are removed, the one with the oldest last activity first. A session is removed whole or not at all;
- if a single session is all that is left and it alone exceeds the caps, it is trimmed from its oldest end.
- the argument and response bodies of the oldest rows are removed and the rows are kept, so the time, result, error class and order of every call survive (
The size cap counts the activity rows together with the session summaries and their indexes.
When step 2 or 3 removes rows of a session inside the window, MCPProxy records a retention shortfall. mcpproxy doctor and GET /api/v1/diagnostics (activity_retention) then say which cap was reached, where complete history starts, and which setting to raise. The warning stays until a full window has passed without further loss.
Work sessions and the failure timeline
A work session is one agent's run of work: one credential, one client, one project, until it has been idle for 30 minutes. Every tool call belongs to one, including calls that have no MCP connection behind them:
| Call | How its work session is derived |
|---|---|
| MCP connection (legacy revisions) | The connection's credential, client name and project. The session survives reconnects. Two tokens that share one connection get two sessions. |
| MCP request on the 2026-07-28 revision | The credential and the client name the request carries. |
REST POST /api/v1/tools/call | The credential and the calling surface (cli, webui, tray, or rest for a script). |
A regenerated token, and a rotated client credential, start a new work session: a session never spans two secrets.
Naming a run. Two agents that share one token and report the same client name cannot be told apart, and their calls form one work session. Give each agent its own token, or send a run name with each request:
curl -X POST -H "X-API-Key: $TOKEN" -H "X-MCPProxy-Run: nightly-2026-11-15" \
http://127.0.0.1:8080/api/v1/tools/call \
-d '{"tool_name":"call_tool_read","arguments":{"name":"github:list_issues","args_json":"{\"owner\":\"acme\",\"repo\":\"api\"}"}}'
X-MCPProxy-Run is accepted on REST tool calls and on MCP over HTTP. It is a label of 1 to 128 printable characters, combined with the credential, so it can never join two tokens' work. An invalid value is ignored and never fails the call. It is not forwarded to upstream servers. One credential can open at most 1,000 named sessions a day; past that the name is ignored.
What a session records. Each session keeps the number of attempts, failures and policy blocks, the time of its first and last failure, and the error class, server, tool and a short reason of the last one. A call that MCPProxy itself refused (quarantine, a profile, a rate limit) is a failure counted apart as a policy block, so that a flood of blocks cannot bury a real failure. A call whose arguments did not match the tool's input schema (invalid_params, error class proxy_policy with fault domain client) is an ordinary failure, not a policy block: the caller sent invalid arguments, no policy refused it. The same rule splits a server's 24-hour numbers on GET /api/v1/activity/summary (per_server[].errors and per_server[].blocked) and the Server detail line. These are lifetime facts: they stay exact after retention has removed rows. Sessions recorded before v0.76.0 counted a validation refusal as a policy block; the first start of v0.76.0 corrects every one whose row is still stored.
Upstream events. A failed call says "connection refused". The reason one level up is recorded as an activity row of type upstream_event, at the time it happened:
metadata.kind | Meaning |
|---|---|
connection_lost | The server's connection was lost or closed |
process_exited | A stdio server's process exited |
oauth_refresh_failed | A token refresh was sent and failed |
login_required | The server needs a new login, including after mcpproxy auth logout and after a restart that finds no usable token |
connection_restored | The connection came back after a recorded loss |
A connection MCPProxy closes on purpose records no row: a server that was quarantined, disabled or removed, a client replaced after a configuration change, and every server at shutdown. Its next connect is then not a connection_restored either, unless a real loss was recorded before it. A logout's disconnect is still recorded as login_required. A connection that broke (the process exited, the transport failed) keeps its connection_lost or process_exited row.
A row carries the server, the kind, the diagnostic code (MCPX_*) and its fixed message, never the raw error text. Repeats within a minute are one row with metadata.count, first_at and last_at; one server adds at most 120 rows an hour. The rows appear in the System view (--type upstream_event) and in the timeline of every session that called the server while the event happened. A session in which a call to a server failed because the server could not be reached (network), and which started while that server was already down, also shows the cause from before its start, marked precedes_session: one row per server, the server's latest connection_lost or process_exited row, when no connection_restored came after it before the session started and it was recorded since MCPProxy last started. A row stands for its repeats, so a loss repeated during the session counts at its last repeat, and a recovery repeated after the session started does not count as one before it. A call that waited for a login is not given an earlier row: its own row says the server needs a login.
Requests from an upstream to the client. When a server asks the calling client for an approval (elicitation), a model completion (sampling) or its roots, the request is recorded as a client_request row: the server, the method as the tool name, what was asked (capped and scanned for sensitive data) and metadata.outcome (forwarded, unanswered or failed). What came back is not stored, only its shape (action, field names and sizes, response_bytes, root_count). Administrators only. See Upstream requests to the client.
Why a call to a server that is not connected failed. Such a call is never sent. When the server waits for a login (logged out, parked for sign-in, or its last connect failed on OAuth) the call is recorded with error class auth and the reason "The upstream server needs a login."; otherwise it is network, "The upstream server could not be reached." A network failure, and an HTTP answer that says nothing about credentials (5xx, 429, 404), is never read as a login requirement.
Reading a session. GET /api/v1/work-sessions lists sessions (?failed=true for the ones that failed), and GET /api/v1/work-sessions/{id}/timeline returns one session's rows and upstream events in time order, positioned at its first failure with the 20 rows before it. See the REST API reference.
One row per call. A call made through call_tool_read, call_tool_write or call_tool_destructive is stored as two rows that share a request_id: the upstream tool_call row and an internal_tool_call row for the variant. The timeline shows the call once, as its tool_call row named server:tool; the call_tool_* row is not a row of the timeline (it is not shown or counted, and at=row:<id> of it opens at the call's row). The two rows are paired by request_id and server when the call_tool_* row is stored, so concurrent calls on one server are told apart. A call_tool_* row whose tool_call row was never stored, or was removed by retention (which removes a session's rows oldest first), is the only record of its call: it stays on the timeline, named by the tool it called (server:tool). Its facts are not lost: the door folds it into the call's row as call_tool (the variant, the time the whole call took, and with include_bodies its arguments and response, which can be the fuller upstream result; its arguments are masked like the call's; the call_tool_* row is not scanned for sensitive data itself, so its response is served only when the masker finds nothing in it, and is otherwise replaced by a [withheld: …] note while the call's own response is served masked), and new tool_call rows also carry metadata.tool_variant and metadata.variant_duration_ms / _us. The Web UI shows them as "Called through", "End to end" and "Response recorded by call_tool_…"; the CLI starts the row's detail with via call_tool_write 385ms. A call refused before dispatch (invalid arguments, a quarantined or disconnected server, a profile) never had a call_tool_* row: it is its own tool_call or policy_decision row, already named server:tool. Other built-ins (retrieve_tools, describe_tool, code_execution, upstream_servers, skills tools, profiles) stay rows of their own; a code_execution script's upstream calls are tool_call rows with parent_id and have no call_tool_* row. The counts never counted the call_tool_* row, so they do not change. Sessions recorded by v0.76.0 and earlier (also by an older version run again later) are paired the same way at the next start.
From the terminal. mcpproxy activity sessions --failed lists the sessions that failed, and mcpproxy activity session <id> prints one session's timeline at its first failure that is still stored (at its first row when none is); --failures prints every stored failure with the rows before it. See Activity commands.
In the Web UI. Activity → Sessions lists work sessions with a "Failed only" filter, and a row's Timeline button opens the session at its first failure that is still in the log (at the earliest remaining row when retention has removed every failed row), with upstream events shown as their own rows. When retention has removed the start of a session or some of its failures, the timeline says so at the top and keeps the lifetime counts. The note about a removed start is shown to administrators: an agent token or a signed-in user who is not one is not told that the first rows of a session are gone. See Sessions and the failure timeline.
Sessions do not continue across a restart of MCPProxy: a long run that spans one shows as two sessions.
Tool-call history
The activity log is not the only per-call store. GET /api/v1/tool-calls is served from separate per-server buckets (server_<id>_tool_calls) that hold a recent debugging window: the full arguments and the upstream result, per server. On one deployment these held ~432MB of a 940MB config.db because nothing bounded them at all (#1176).
{
"tool_call_max_response_size": 65536,
"tool_call_max_records_per_server": 1000
}
| Setting | Default | Description |
|---|---|---|
tool_call_max_response_size | 65536 | Cap on the marshalled response stored per tool-call record, in bytes. Over the cap the stored response is replaced by {"truncated": true, "original_bytes": N, "preview": "…"} and the record carries response_truncated: true with response_bytes: N. The caller still received the response whole — only the stored copy is shortened. |
tool_call_max_records_per_server | 1000 | Calls retained per server. The oldest are evicted in the same transaction as the write, so the bucket can never exceed the cap. |
A non-positive value means "use the default", not "disable" — this store has no off switch. Removing a server now drops its call history with it, and histories belonging to servers that are no longer configured are swept on startup (the synthetic code_execution history is never swept).
Reclaiming the space. All of the above bounds future growth. BBolt does not return freed pages to the operating system, so an already-large
config.dbstays large. Usemcpproxy db statsto see how much is reclaimable andmcpproxy db compact— with mcpproxy stopped — to shrink the file. See docs/cli/db-commands.md.
Use Cases
Debugging Tool Calls
View recent tool calls to debug issues:
curl -H "X-API-Key: $KEY" \
"http://127.0.0.1:8080/api/v1/activity?type=tool_call&status=error&limit=10"
Compliance Auditing
Export activity for compliance review:
curl -H "X-API-Key: $KEY" \
"http://127.0.0.1:8080/api/v1/activity/export?format=csv&start_time=2025-01-01T00:00:00Z" \
> audit-q1-2025.csv
Session Analysis
Track all activity for a specific AI session:
curl -H "X-API-Key: $KEY" \
"http://127.0.0.1:8080/api/v1/activity?session_id=mcp-session-abc123"
Real-time Monitoring
Monitor tool calls in real-time:
curl -N "http://127.0.0.1:8080/events?apikey=$KEY" | grep "activity.tool_call"
Storage
Activity records are stored in BBolt database at ~/.mcpproxy/config.db. The background cleanup process automatically prunes old records based on retention settings.
Most runtime activity events are persisted by the background event worker, so publishing them does not wait for the database write. Some records are synchronous: for example, every executed tools-preflight check persists its audit record before the result returns (details).