Skip to content

MCP Quick Start (for AI agents) ​

This page is for the consumer side — you're pointing an MCP-aware client (Claude Desktop, MCP Inspector, a custom LLM agent, an MCP-aware ops bot) at a running CritterWatch BFF and want to discover + invoke its tools.

For the server side (mount path, tool catalog, RBAC enforcement, licensing, composition with per-store MCP servers), see MCP integration.

1. Confirm the server is mounted ​

The BFF mounts MCP at /api/mcp over streamable HTTP. Confirm with a POST (an empty body is enough for the transport handshake):

bash
curl -i -X POST http://localhost:5173/api/mcp

A 406 Not Acceptable or 400 Bad Request is the correct response to a hand-rolled POST without MCP framing — it confirms the route exists and a real MCP client should connect.

If you instead get a 404, the MCP server isn't mounted. Verify app.MapCritterWatchMcp() runs in the host's Program.cs.

2. Connect a client ​

Option A — MCP Inspector (no code, fastest path to confirm) ​

The official @modelcontextprotocol/inspector gives you a browser UI for browsing tools and invoking them:

bash
npx @modelcontextprotocol/inspector

In the Inspector UI:

  1. Set Transport to Streamable HTTP.
  2. Set URL to http://localhost:5173/api/mcp (or wherever your BFF runs).
  3. If the host enforces auth, add your bearer token / cookie under Headers.
  4. Click Connect.

The tool catalog populates the left-hand panel.

Option B — Claude Desktop ​

Configure the MCP server in Claude Desktop's config (~/Library/Application Support/Claude/claude_desktop_config.json on macOS; equivalent on Windows / Linux). The transport is streamable HTTP, not stdio:

jsonc
{
  "mcpServers": {
    "critterwatch": {
      "url": "http://localhost:5173/api/mcp",
      "transport": "streamableHttp",
      "headers": {
        "Authorization": "Bearer <your token>"
      }
    }
  }
}

Restart Claude Desktop. The CritterWatch tools become available to the model with no further prompting.

Option C — Custom client (.NET / Python / TypeScript) ​

Any MCP SDK that speaks streamable HTTP works. The minimum is:

  • POST to /api/mcp with Accept: application/json, text/event-stream.
  • Carry the Authorization header (or cookie) the host's auth scheme expects.
  • Follow the standard MCP framing: initialize → tools/list → tools/call.

3. Discover the tool catalog ​

After connecting, the MCP tools/list call returns the live catalog — which is the authoritative list, and the one to read rather than any count written down here. It has two families:

  • Read tools — list_active_alerts, summarize_cluster_health, get_backlog_state, query_recent_traces, summarize_dead_letters, query_dead_letters, etc. License-gated; no RBAC, except the reads that return business data (see below).
  • Action tools — replay_dead_letters, rebuild_projection, pause_listener, add_tenant, etc. License + RBAC-gated.

The reads that return business data are the exception to "read tools are RBAC-free": the dead-letter reads (mcp.dlq.read), the projection stepper and diagnostic (mcp.projection.step), query_events (mcp.events.query), query_sql (mcp.sql.query), the document reads query_documents / get_document (mcp.documents.read), the conversation reads list_conversations / get_conversation (mcp.conversations.read) and the saga reads list_sagas / list_saga_instances / get_saga_instance (mcp.sagas.read).

summarize_dead_letters and query_dead_letters return message bodies and exception detail, so mcp.dlq.read is granted separately from the dlq.replay / dlq.discard actions. Together they close the investigate → explain → replay loop: summarize to triage, query to get the envelope ids, then hand those ids to replay_dead_letters or discard_dead_letters, with an optional reason. The action answers with an operationId, the operation the console's Dead Letters page follows on its Operations tab until every database has answered.

Both report databasesAnnounced / databasesAnswered alongside their results. Check them. On a multi-database deployment a store that fails to answer is otherwise indistinguishable from a store with no rows — the failure mode that had the console asserting an empty queue over 42 dead letters. An empty result with partial: true means "some stores did not report", not "there is nothing here".

See the full catalog for the exact list and capability mappings.

4. Invoke a read tool ​

Read tools are the safest place to start — they're idempotent, license-gated (and RBAC-free apart from the business-data reads above), and return immediately useful diagnostic data.

list_active_alerts example via Inspector:

Tool:      list_active_alerts
Arguments: {}

Returns:

jsonc
{
  "content": [
    {
      "type": "text",
      "text": "{ \"filter\": { \"serviceName\": null, \"severity\": null, \"limit\": 100 }, \"count\": 1, \"alerts\": [ { \"id\": \"alert:trip-service:MetricsExecTime:StartTrip\", \"serviceName\": \"trip-service\", \"alertType\": \"MetricsExecTime\", \"severity\": \"Critical\", \"subject\": \"StartTrip\", \"message\": \"…\", \"raisedAt\": \"2026-06-04T14:23:00Z\", \"acknowledgedAt\": null, \"snoozedUntil\": null, \"nodeNumber\": null } ] }"
    }
  ]
}

(The MCP convention is to return JSON-as-text in the content[].text field; the agent parses it back.)

If the host doesn't have a license, you'll see a LicenseMissing envelope instead — same shape as the deny envelope below, with error: "LicenseMissing".

5. Invoke an action tool (with RBAC) ​

Action tools require both license + RBAC. Try rebuild_projection:

Tool:      rebuild_projection
Arguments: { "serviceName": "trip-service", "projectionShardName": "TripSummary:All" }

The shard name is the one the read tools report (get_projection_lag, list_shard_health). On allow:

jsonc
{
  "content": [
    {
      "type": "text",
      "text": "{ \"accepted\": true, \"operation\": \"Rebuild\", \"serviceName\": \"trip-service\", \"projectionShardName\": \"TripSummary:All\", \"agentUri\": \"event-subscription://trip-service/TripSummary:All\", \"tenantId\": null }"
    }
  ]
}

The command is published; the projection rebuild runs in the monitored service. The MCP call returns immediately on accept — completion comes via the normal telemetry channel (the Projections page in the SPA, or a follow-up get_projection_lag poll from the agent).

Irreversible tools answer with a preview first ​

A tool whose call cannot be undone (discarding dead letters, deleting a tenant, ejecting a projection, and the rest listed under confirmation tokens) changes nothing on its first call. It returns confirmationRequired: true, a preview of what would happen, and a confirmationToken:

Tool:      discard_dead_letters
Arguments: { "serviceName": "trip-service", "messageIds": ["…"] }
→ { "confirmationRequired": true, "preview": { … }, "confirmationToken": "…", "expiresAt": "…" }

Show the user the preview. If they agree, call the same tool with exactly the same arguments plus "confirmationToken": "…", and it runs. The token works once, for five minutes, for the caller it was issued to.

6. The deny envelope ​

When the principal isn't authorized for the capability:

jsonc
{
  "content": [
    {
      "type": "text",
      "text": "{ \"error\": \"Forbidden\", \"message\": \"Caller is not authorized for capability 'projection.rebuild' on resource 'event-subscription://trip-service/TripSummary:All'.\", \"capability\": \"projection.rebuild\", \"resource\": \"event-subscription://trip-service/TripSummary:All\" }"
    }
  ]
}

The agent should surface this back to the user verbatim — the capability field is the exact grant the user is missing. Don't retry on deny; the agent can't escalate its own privileges.

When the host has no license:

jsonc
{ "error": "LicenseMissing", "message": "…" }

(No capability field — the license check runs ahead of RBAC.)

When the server is read-only, an action tool is not in tools/list at all. If one is reachable anyway, it answers:

jsonc
{ "error": "McpReadOnly", "message": "'discard_dead_letters' changes state, and this CritterWatch MCP server is read-only …" }

Tell the user the server is read-only and the action has to be taken in the console. Don't retry.

A confirmed call refuses with ConfirmationMismatch (different arguments, tool or caller), ConfirmationExpired or ConfirmationConsumed. In each case call again without the token for a fresh preview, and ask the user again. ConfirmationUnavailable means the host has no confirmation store, so the tool refuses rather than run unconfirmed; that is a host configuration problem, not something to retry.

7. Tenant-scoped invocations ​

The three projection action tools (pause_projection, restart_projection, rebuild_projection) accept an optional tenantId. When supplied, the action runs against only that tenant's projection shard, and the RBAC resource — the projection's agent URI — gains @{tenantId}:

Tool:      rebuild_projection
Arguments: {
  "serviceName": "trip-service",
  "projectionShardName": "TripSummary:All",
  "tenantId":    "acme-corp"
}

The deny envelope on this scope:

jsonc
{
  "error": "Forbidden",
  "message": "Caller is not authorized for capability 'projection.rebuild' on resource 'event-subscription://trip-service/TripSummary:All@acme-corp'.",
  "capability": "projection.rebuild",
  "resource":   "event-subscription://trip-service/TripSummary:All@acme-corp"
}

This is the same resource the relay asks about when an operator presses the SPA's per-tenant Rebuild button, so your authorizer sees one shape from the console and from MCP. It changed in 1.1: before, the MCP tools asked about {serviceName} / {serviceName}:{tenantId} and the relay about the agent URI. See MCP integration › Per-tenant scoping and the Upgrade Notes.

8. When read tools come back empty ​

A read tool that returns an empty list is usually one of:

  • Nothing matches. list_active_alerts returns "count": 0 and "alerts": [] when no alerts are firing.
  • License missing. Read tools are license-gated; an unlicensed host returns the LicenseMissing envelope, not an empty result.
  • Per-service binding misconfigured. Trace tools (query_recent_traces, get_trace) depend on the service having a ITraceProvider binding in CritterWatch's Trace Providers settings. An unbound service returns an empty trace list with a hint in the response — bind a provider in the SPA's Settings → Trace Providers.

See also ​

  • MCP integration — server-side reference (mount path, full tool catalog, RBAC enforcement, license, composition).
  • RBAC — the capability ↔ tool mapping, deny envelope shape, off-mode semantics.
  • RBAC Recipes — worked examples for wiring ICritterWatchAuthorizer, including the per-tenant scoping shape MCP action tools use.