Skip to main content

Activity Log

MCPProxy provides comprehensive activity logging to track AI agent tool calls, policy decisions, and system events. This enables debugging, auditing, and compliance monitoring.

What Gets Logged

The activity log captures:

Event TypeDescription
tool_callEvery tool call made through MCPProxy
policy_decisionTool calls blocked by policy rules
quarantine_changeServer quarantine/unquarantine events
server_changeServer enable/disable/restart events

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,
"timestamp": "2025-01-15T10:30:00Z",
"session_id": "mcp-session-abc123",
"intent": {
"operation_type": "write",
"data_sensitivity": "internal",
"reason": "Creating bug report per user request"
}
}

Intent Tracking

Every tool call includes intent information for security auditing:

FieldDescription
tool_variantWhich tool was used: call_tool_read, call_tool_write, call_tool_destructive
intent.operation_typeAgent's declared intent: read, write, destructive
intent.data_sensitivityData classification: public, internal, private, unknown
intent.reasonAgent's explanation for the operation

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.

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

CommandDescription
activity listList activity records with filtering and pagination
activity watchWatch real-time activity stream via SSE
activity show <id>Show full details of a specific activity
activity summaryShow aggregated statistics for a time period
activity exportExport 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:

ParameterTypeDescription
typestringFilter by type: tool_call, policy_decision, quarantine_change, server_change
serverstringFilter by server name
toolstringFilter by tool name
session_idstringFilter by MCP session ID
statusstringFilter by status: success, error, blocked
start_timestringFilter after this time (RFC3339)
end_timestringFilter before this time (RFC3339)
limitintegerMax records (1-100, default: 50)
offsetintegerPagination offset (default: 0)

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 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"

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:

ParameterTypeDescription
formatstringExport 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:

EventDescription
activity.tool_call.startedTool call initiated
activity.tool_call.completedTool call finished (success or error)
activity.policy_decisionTool 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": 100000,
"activity_max_response_size": 65536,
"activity_cleanup_interval_min": 60
}
SettingDefaultDescription
activity_retention_days90Days to retain activity records
activity_max_records100000Maximum records before pruning oldest
activity_max_response_size65536Max response size stored (bytes)
activity_cleanup_interval_min60Background cleanup interval (minutes)

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.

Performance

Activity logging is non-blocking and uses an event-driven architecture to minimize impact on tool call latency.