Model Context Protocol (MCP) Server
The CollectorCtrl MCP Server exposes your OpenTelemetry fleet to AI assistants (such as Claude Desktop, Cursor, and custom LLM agents) over the open-standard Model Context Protocol. AI agents can query live fleet health, analyze telemetry cardinality, inspect packages, and safely propose configuration changes using natural language.
Phase 1 MCP tools are strictly read-only by default. Every MCP request is authenticated via API tokens, authorized through existing CollectorCtrl RBAC permissions, and recorded to the immutable audit log with the actor attribute mcp:<username>.
1. Protocol Architecture & Endpoints
The MCP server is implemented natively in the Go backend (internal/collectorctrl/uisrv/mcp.go) and supports both Streamable HTTP and stdio transport modes:
AI Client (Claude Desktop / Cursor / Custom LLM)
│
│ MCP Protocol (JSON-RPC 2.0 over HTTPS POST or Stdio)
▼
CollectorCtrl Server (Port 4321) ➔ https://<server>:4321/api/mcp
│
├─ 1. Authentication: Bearer Token (SHA-256 hashed API token)
├─ 2. Authorization: Per-Tool RBAC Permission Check (requirePermission)
├─ 3. Rate Limiter: Per-Token Sliding Window (Read & Mutate budgets)
├─ 4. Guardrails: Blast-Radius Selector Cap & Two-Person Approval
└─ 5. Audit Logging: Every call logged (actor: mcp:<username>)
│
▼
CollectorCtrl Engine (Fleet State, Packages, Governor Analytics, OTel Sinks)
Protocol Specifications
| Property | Specification |
|---|---|
| Endpoint | POST https://<server>:4321/api/mcp |
| Protocol | JSON-RPC 2.0 over HTTP POST |
| Authentication | Authorization: Bearer cc_<token> (API Token or Session JWT) |
| Audit Actor | mcp:<username> or mcp:token:<token_name> |
| Read Rate Limit | Default: 120 calls / hour per token |
| Mutate Rate Limit | Default: 20 calls / hour per token |
2. API Token Setup & Role Scoping
Every MCP client authenticates with a CollectorCtrl API token. Tools automatically inherit the permissions granted to the token's role:
1. Open API Token Settings
In the CollectorCtrl web dashboard, navigate to Settings → SSO & Tokens → API Tokens.
2. Generate Scoped Token
Click Generate Token, provide a descriptive name (e.g., claude-desktop-sre), and select an appropriate role (e.g., Viewer for read-only access, or a custom role).
3. Save Token Securely
Copy the generated token string (cc_...). Tokens are stored as one-way SHA-256 hashes in the database and cannot be retrieved again after creation.
3. Comprehensive MCP Tools Reference
The tool surface is organized into three progressive security phases:
Phase 1: Read-Only Fleet Visibility (Active by Default)
Phase 1 tools are enabled out of the box and cannot alter system state:
| Tool Name | Parameters | Scope & Output | Required Permission |
|---|---|---|---|
fleet_list_agents | status, environment, os | Lists connected collectors matching status filters (healthy, degraded, unhealthy). | fleet:view |
fleet_get_agent | instance_id (required) | Full real-time metadata, effective config hash, uptime, and assigned policies for a node. | fleet:view |
fleet_get_samples | limit (optional) | Recent captured telemetry records across logs, metrics, and traces. | fleet:view |
fleet_list_packages | — | Available supervisor and collector binaries in the package repository with architecture flags. | packages:view |
fleet_get_build_status | — | Status of recent custom collector builds compiled with the integrated OCB builder. | builder:view |
governor_volume | — | Live telemetry ingestion rates, volume by service, and throughput analytics. | governor:view |
governor_cardinality | — | High-cardinality label and attribute breakdown across active pipelines. | governor:view |
governor_templates | — | Active Telemetry Governor pipeline templates, regex drop rules, and sampling policies. | governor:view |
governor_engine_status | — | Status summary of the Governor engine, ClickHouse/SQLite health, and tapped agent counts. | governor:view |
audit_query | limit (optional) | Chronological system audit entries with actor attribution, action type, and duration. | audit:view |
discovery_reports | — | Service discovery inventory: running ports, services, and network endpoints detected per node. | discovery:analyze |
supervisors_list | — | Registered Supervisor agents, versions, host OS, and service daemon status. | supervisors:view |
instrumentation_list_apps | — | Applications detected by ZeroTouch auto-instrumentation (Java, .NET, Node.js, Python). | discovery:analyze |
instrumentation_get_version_policy | — | Central instrumentation baseline catalog and group version pinning rules. | fleet:view |
instrumentation_get_rollout_status | — | Canary rollout status and bytecode injection verification counters across the fleet. | fleet:view |
Telemetry optimization tools
Read-only, also available to the in-app Copilot. They run the same generator as the Telemetry Insights optimizer, scoped to the token's environment. Examples and patterns pass through secret redaction; a pattern that contained a secret is returned with redacted: true.
| Tool Name | Scope & Output | Required Permission |
|---|---|---|
governor_top_patterns | Most frequent log patterns (signal: logs) or span routes (signal: traces) in the received sample, with count, share, severity or error rate, a redacted example and a suggested_strategy. Counts are received records, not the full stream. Warnings, errors and unknown log severities are suggested normalize (keeps every record), never filter or sample; routes with errors are suggested tail_sampling. | governor:view |
governor_optimize_preview | Measured impact of a drop (filter), sample, tail_sampling or normalize rule on the newest 5,000 stored records in scope: matched, protected, removed and bytes. Describes only the analyzed samples; no monthly or production projection. | governor:view |
governor_optimize_config | Collector processors YAML, OTTL statements, check results, tested compatibility and how to apply it (nothing is deployed). | governor:view |
governor_optimize_explain_checks | Plain-language explanation of each check: what it verifies, its result and what it does not cover. | governor:view |
Phase 2: Configuration Validation & Safe Proposals
Phase 2 introduces safe validation and mutating actions behind a mandatory Human-in-the-Loop approval workflow. Enable on the server with:
COLLECTORCTRL_MCP_PHASE2=true
| Tool Name | Parameters | Action & Security Behavior | Permission Required |
|---|---|---|---|
fleet_validate_ottl | statements (array) | Validates OpenTelemetry Transformation Language (OTTL) syntax against strict AST grammar without changing configs. | governor:view |
fleet_preview_config | signal, condition | Runs a dry-run What-If simulation against captured telemetry samples and reports how many sampled records match and the share they make up. | governor:view |
fleet_push_config | selector, config_yaml | Generates a pending proposal. Resolves blast radius (capped at 10 nodes by default). Returns a 15-minute action_id. | fleet:configure |
fleet_rollback_config | selector | Proposes rolling back targeted agents to their previous authorized policy version. | fleet:control |
governor_set_sampling | rate, selector | Proposes adjusting the sampling rate for matching collectors. | fleet:configure |
governor_toggle_tap | instance_id, enabled | Proposes enabling or disabling non-intrusive telemetry tapping on an agent node. | governor:configure |
fleet_confirm_action | action_id | Executes an approved proposal. Enforces the Two-Person Rule (the proposer cannot confirm their own action). | mcp:approve |
Phase 3: Lifecycle Operations & Rollouts
Phase 3 introduces supervised process lifecycle operations, gated behind COLLECTORCTRL_MCP_PHASE3=true:
| Tool Name | Scope | Permission Required |
|---|---|---|
fleet_restart_agent / fleet_restart_sidecar | Restarts the managed collector or isolated sidecar process. | fleet:control |
fleet_start_agent / fleet_stop_agent | Spawns or gracefully shuts down the managed collector process. | fleet:control |
fleet_canary_rollout | Proposes percentage-based canary rings (e.g. 10%) with automated health gates. | fleet:configure |
fleet_upgrade_agent | Triggers a collector binary upgrade governed by the 3-minute Upgrade Watchdog. | fleet:control |
supervisor_upgrade | Upgrades the edge Supervisor daemon with automatic crash rollback. | supervisors:control |
4. Connecting Client Applications
A. Claude Desktop (Stdio Adapter)
Use the lightweight collectorctrl-mcp bridge CLI to connect Claude Desktop to your server:
1. Build or Download Bridge Binary
Compile the bridge adapter from source:
# Linux / macOS
$go build -o collectorctrl-mcp ./cmd/collectorctrl-mcp
# Windows (PowerShell)
$go build -o collectorctrl-mcp.exe ./cmd/collectorctrl-mcp
2. Configure Claude Desktop
Add the server definition to your claude_desktop_config.json:
{
"mcpServers": {
"collectorctrl": {
"command": "/usr/local/bin/collectorctrl-mcp",
"args": [
"--server-url", "https://your-collectorctrl-server:4321",
"--api-token", "cc_your_api_token_here"
]
}
}
}3. Restart & Verify
Restart Claude Desktop. In the chat interface, look for the electrical plug icon showing collectorctrl connected, and type: "List my connected OpenTelemetry agents."
B. Cursor IDE Integration
Add CollectorCtrl as a project or global MCP server in Cursor:
- Navigate to Cursor Settings → Features → MCP.
- Click + Add New MCP Server.
- Set Type:
command. - Set Command:
/path/to/collectorctrl-mcp --server-url https://your-server:4321 --api-token cc_your_token.
C. Direct JSON-RPC over HTTP
Any HTTP client can communicate directly with the /api/mcp endpoint:
$curl -sk -X POST https://your-server:4321/api/mcp -H "Authorization: Bearer cc_your_token" -H "Content-Type: application/json" -d '{
$ "jsonrpc": "2.0",
$ "id": 1,
$ "method": "tools/list"
$}'
$curl -sk -X POST https://your-server:4321/api/mcp -H "Authorization: Bearer cc_your_token" -H "Content-Type: application/json" -d '{
$ "jsonrpc": "2.0",
$ "id": 2,
$ "method": "tools/call",
$ "params": {
$ "name": "fleet_list_agents",
$ "arguments": {
$ "status": "unhealthy",
$ "environment": "production"
$ }
$ }
$}'
5. Enterprise Guardrails & Approval Workflow
CollectorCtrl enforces strict protocol-level safeguards to guarantee that autonomous AI agents cannot compromise production telemetry:
[ AI Agent ] ➔ fleet_push_config(selector, YAML)
│
▼
[ Server ] ➔ 1. Validates YAML & OTTL syntax
➔ 2. Calculates blast radius (enforces SelectorCap <= 10)
➔ 3. Stages proposal with 15-minute TTL
➔ 4. Generates action_id: "act-8f902b1c"
│
▼
[ Web Dashboard ] ➔ Settings ➔ Pending AI Actions
Operator inspects visual diff & blast radius
│
├─ Option A: Human clicks "Approve" (requires mcp:approve)
└─ Option B: Human clicks "Reject" (proposal purged)
Safety Rules
- Two-Person Security Rule: The human operator confirming an action must be distinct from the identity that created the proposal. A user cannot self-approve their own AI-generated changes.
- Blast Radius Limits: The server rejects proposals targeting more than
SelectorCapnodes (default: 10) in a single operation, preventing catastrophic fleet-wide misconfigurations. - Automatic Expiry: All pending action proposals expire automatically after 15 minutes if not approved.
- Auto-Approve Guard: Unattended auto-approval is disabled for all roles including administrators. Enabling requires both
COLLECTORCTRL_MCP_AUTO_APPROVE=trueand explicit assignment of themcp:auto-approveRBAC permission.
6. Example Prompts for AI Assistants
Here are practical prompts you can use with Claude Desktop or Cursor once connected:
- Incident Triaging: "Which collectors in the production cluster are currently degraded, and what are their error messages?"
- Recurring Pattern Review: "Which log patterns occur most often in the checkout service's sample over the last 24 hours, and which of them look like noise worth reviewing?"
- Compliance & Audit: "Show me the last 15 audit events. Were any configurations modified or collector binaries upgraded today?"
- Dry-Run What-If Simulation: "Simulate dropping logs where severity is INFO and body contains 'healthcheck'. What share of the sampled records would it remove?"
- Package Inspection: "List all available collector binary packages. Do we have an arm64 build for v0.108.0?"
7. Troubleshooting & Error Codes
| JSON-RPC Error | Cause | Recommended Action |
|---|---|---|
401 Unauthorized | Missing, malformed, or expired API token. | Check the Authorization: Bearer cc_... header; regenerate token under Settings → API Tokens. |
-32003 Forbidden | Token role lacks the permission required by the tool. | Grant the required permission to the token's role (see table in §3). |
-32601 Tool Not Found | Requested tool does not exist or requires Phase 2/3 flags. | Run tools/list to inspect active tools. Set COLLECTORCTRL_MCP_PHASE2=true if using mutating tools. |
-32602 Invalid Params | Missing required parameter (e.g. missing instance_id). | Check tool argument schema and provide all required parameters. |
429 Too Many Requests | Token exceeded sliding-window rate limit budget. | Wait for the rate limit window to refresh or adjust limits in MCP Settings. |
Self-confirmation rejected | Proposer attempted to confirm their own action. | The approval must be confirmed by an independent operator holding mcp:approve. |
CollectorCtrl