Feature Branch: 017-activity-cli-commands
Created: 2025-12-26
Status: Draft
Input: User description: "Implement Activity CLI Commands for querying and monitoring activity log (RFC-001 + RFC-003)"
Users and AI agents need to query activity history from the command line to understand what tool calls have been made, debug issues, and monitor agent behavior without using the web UI.
Why this priority: CLI is the primary interface for AI agents and power users. They need to query activity without opening a browser.
Independent Test: Can be fully tested by running mcpproxy activity list after making tool calls and verifying the output shows the activity history.
Acceptance Scenarios:
- Given 10 tool calls have been made, When a user runs
mcpproxy activity list, Then a formatted table shows recent activities with timestamp, type, server, tool, and status - Given tool calls from multiple servers exist, When a user runs
mcpproxy activity list --server github, Then only activities for the "github" server are shown - Given many activities exist, When a user runs
mcpproxy activity list --limit 5, Then only the 5 most recent activities are shown - Given an AI agent needs machine-readable output, When it runs
mcpproxy activity list -o json, Then valid JSON array of activities is returned
Users monitoring agent behavior in real-time need a tail -f style command that streams activity as it happens.
Why this priority: Real-time monitoring is essential for debugging and observing agent behavior during execution.
Independent Test: Can be tested by running mcpproxy activity watch in one terminal and making tool calls in another, verifying events stream live.
Acceptance Scenarios:
- Given the watch command is running, When a tool call is made, Then the activity appears in the output immediately
- Given the watch command is running with
--server github, When tool calls are made to different servers, Then only github server activities are shown - Given the watch command is running, When the user presses Ctrl+C, Then the command exits cleanly
Users investigating a specific tool call need to view its full details including request arguments and response data.
Why this priority: Detail view is important for debugging but less frequently used than list/watch.
Independent Test: Can be tested by running mcpproxy activity show <id> and verifying full details are displayed.
Acceptance Scenarios:
- Given an activity ID from the list command, When a user runs
mcpproxy activity show act_abc123, Then full details including arguments and response are displayed - Given an invalid activity ID, When a user runs
mcpproxy activity show unknown, Then a clear error message is shown
Users need a quick overview of activity statistics for a time period to understand usage patterns and identify issues.
Why this priority: Summary is useful for high-level monitoring but not essential for core functionality.
Independent Test: Can be tested by running mcpproxy activity summary and verifying statistics are displayed.
Acceptance Scenarios:
- Given activities exist for the past 24 hours, When a user runs
mcpproxy activity summary, Then statistics showing total calls, success rate, and top servers are displayed - Given a user wants weekly summary, When they run
mcpproxy activity summary --period 7d, Then the summary covers the last 7 days
Enterprise users need to export activity logs to files for compliance and audit purposes.
Why this priority: Export is an enterprise feature, not needed for core CLI functionality.
Independent Test: Can be tested by running mcpproxy activity export --output activity.json and verifying the file is created.
Acceptance Scenarios:
- Given activities exist, When a user runs
mcpproxy activity export --output activity.json, Then a JSON file with all matching activities is created - Given activities exist, When a user runs
mcpproxy activity export -o csv --output activity.csv, Then a CSV file is created
- What happens when activity list is empty? (Show "No activities found" message for table, empty array for JSON)
- What happens when watch command runs but daemon is not reachable? (Show connection error and retry logic)
- What happens when export file path is not writable? (Show clear permission error)
- How does watch handle very high activity volume? (Buffer and batch output to avoid overwhelming terminal)
- What happens when activity ID format is invalid? (Show format hint in error message)
Activity List Command:
- FR-001: System MUST provide
mcpproxy activity listcommand - FR-002: List command MUST support
--typefilter (tool_call, policy_decision, quarantine) - FR-003: List command MUST support
--serverfilter - FR-004: List command MUST support
--statusfilter (success, error, blocked) - FR-005: List command MUST support
--limitand--offsetfor pagination - FR-006: List command MUST support
--start-timeand--end-timefilters - FR-007: List command MUST use output formatter from spec 014 (table, json, yaml)
Activity Watch Command:
- FR-008: System MUST provide
mcpproxy activity watchcommand - FR-009: Watch command MUST stream activities in real-time via SSE connection
- FR-010: Watch command MUST support
--typeand--serverfilters - FR-011: Watch command MUST handle disconnection with automatic reconnection
- FR-012: Watch command MUST exit cleanly on SIGINT/SIGTERM
Activity Show Command:
- FR-013: System MUST provide
mcpproxy activity show <id>command - FR-014: Show command MUST display full activity details including arguments and response
- FR-015: Show command MUST support
--include-responseflag for very large responses
Activity Summary Command:
- FR-016: System MUST provide
mcpproxy activity summarycommand - FR-017: Summary MUST show: total count, success/error/blocked counts, top servers, top tools
- FR-018: Summary MUST support
--periodflag (1h, 24h, 7d, 30d) - FR-019: Summary MUST support
--byflag for grouping (server, tool, status)
Activity Export Command:
- FR-020: System MUST provide
mcpproxy activity exportcommand - FR-021: Export MUST support
--outputflag for file path - FR-022: Export MUST support
-oformat flag (json, csv) - FR-023: Export MUST support same filters as list command
- FR-024: Export MUST support
--include-bodiesflag for full request/response
CLI Integration:
- FR-025: All commands MUST use REST API backend (not direct storage access)
- FR-026: All commands MUST respect
--quietflag for minimal output - FR-027: All commands MUST work with both running daemon and direct mode
-
ActivityListOptions: CLI options for list command including filters, pagination, and output format.
-
ActivityWatchOptions: CLI options for watch command including filters and reconnection settings.
-
ActivitySummary: Aggregated statistics for activity summary including counts and groupings.
- SC-001: Users can list activities in under 1 second for up to 100 records (verifiable by timing command)
- SC-002: Watch command displays new activities within 200ms of occurrence (verifiable by timing)
- SC-003: AI agents using mcp-eval scenarios can query activity with 95%+ success rate (verifiable by running mcp-eval)
- SC-004: All CLI output is consistent with spec 014 formatting (verifiable by comparing output formats)
- SC-005: Export command creates valid, parseable files (verifiable by parsing exported files)
- SC-006: Commands provide helpful error messages for common mistakes (verifiable by triggering errors)
- Spec 014 (CLI Output Formatting) is implemented and available
- Spec 016 (Activity Log Backend) REST API is implemented and available
- The SSE endpoint for watch is available at
/events - CLI can connect to daemon via socket or HTTP
- Spec 014: CLI Output Formatting (for table/json/yaml output)
- Spec 016: Activity Log Backend (REST API endpoints)
- Existing Components:
cmd/mcpproxy/: CLI command structure- REST API client for daemon communication
- Web UI for activity (existing web UI to be extended separately)
- Risk scoring display (future RFC-004)
- PII detection display (future RFC-004)
- Activity modification/deletion commands
- Interactive activity explorer
When committing changes for this feature, follow these guidelines:
- Use:
Related #[issue-number]- Links the commit to the issue without auto-closing - Do NOT use:
Fixes #[issue-number],Closes #[issue-number],Resolves #[issue-number]
Rationale: Issues should only be closed manually after verification and testing in production.
- Do NOT include:
Co-Authored-By: Claude <noreply@anthropic.com> - Do NOT include: "Generated with Claude Code"
Rationale: Commit authorship should reflect the human contributors.
feat(cli): add activity commands for querying and monitoring
Related #[issue-number]
Implement CLI commands for activity log as per RFC-001 and RFC-003.
Provides list, watch, show, summary, and export commands.
## Changes
- Add mcpproxy activity list command with filtering
- Add mcpproxy activity watch for real-time streaming
- Add mcpproxy activity show for detail view
- Add mcpproxy activity summary for statistics
- Add mcpproxy activity export for compliance export
- Integrate with output formatter from spec 014
## Testing
- Unit tests for command parsing
- E2E tests for all activity commands
- mcp-eval scenarios for AI agent usage