> ## Documentation Index
> Fetch the complete documentation index at: https://docs.opsmatic.io/llms.txt
> Use this file to discover all available pages before exploring further.

# MCP Server

> Connect AI assistants like Claude, Cursor, and VS Code to your Opsmatic monitoring data using the Model Context Protocol

## Overview

Opsmatic ships a built-in [Model Context Protocol](https://modelcontextprotocol.io) (MCP) server, so AI assistants can query your monitoring data directly in conversation. Ask Claude "is my production n8n healthy?" or "how much did OpenClaw spend this week?" and it pulls live answers from your Opsmatic account.

All tools are **read-only** — the MCP server can inspect connections, health, executions, usage, anomalies, and alerts, but it can never modify your account.

## Server URL

```
https://opsmatic.io/api/mcp
```

The server uses the **Streamable HTTP** transport. The legacy SSE transport is not supported.

## Authentication

The MCP server uses **OAuth 2.1** — no API keys needed. When you add the server to an MCP client:

1. The client discovers the authorization server automatically via `/.well-known/oauth-protected-resource` (RFC 9728)
2. It registers itself using dynamic client registration
3. You're redirected to sign in with your Opsmatic account and approve access
4. The client receives a token scoped to your user

Every tool call is scoped to the connections **you own or can access through an organization membership** — the same visibility you have in the dashboard.

<Note>
  Authorization uses your regular Opsmatic sign-in. API keys from your profile settings are for the [REST API](/api-reference/introduction) and do not work with the MCP server.
</Note>

## Connecting a Client

<Tabs>
  <Tab title="Claude Code">
    Add the server from your terminal:

    ```bash theme={null}
    claude mcp add --transport http opsmatic https://opsmatic.io/api/mcp
    ```

    The first time a tool is used, Claude Code opens your browser to complete the OAuth sign-in. Run `/mcp` inside Claude Code to check connection status or re-authenticate.
  </Tab>

  <Tab title="Claude.ai / Desktop">
    <Steps>
      <Step title="Open Connector Settings">
        Go to **Settings → Connectors** in Claude.ai or the Claude desktop app
      </Step>

      <Step title="Add Custom Connector">
        Click **Add custom connector** and enter `https://opsmatic.io/api/mcp`
      </Step>

      <Step title="Authorize">
        Sign in with your Opsmatic account when prompted and approve access
      </Step>
    </Steps>
  </Tab>

  <Tab title="Cursor">
    Add the server to `.cursor/mcp.json` (project) or `~/.cursor/mcp.json` (global):

    ```json theme={null}
    {
      "mcpServers": {
        "opsmatic": {
          "url": "https://opsmatic.io/api/mcp"
        }
      }
    }
    ```

    Cursor prompts you to sign in the first time it connects.
  </Tab>

  <Tab title="VS Code">
    Add the server to `.vscode/mcp.json` in your workspace:

    ```json theme={null}
    {
      "servers": {
        "opsmatic": {
          "type": "http",
          "url": "https://opsmatic.io/api/mcp"
        }
      }
    }
    ```

    VS Code handles the OAuth flow when the server first starts.
  </Tab>
</Tabs>

## Available Tools

### list\_connections

List the monitored connections (n8n, Make.com, OpenClaw) you have access to, with their current status.

**Parameters:** none

```json theme={null}
[
  {
    "id": "8f14e45f-...",
    "name": "Production n8n",
    "platform": "n8n",
    "status": "active",
    "lastSyncAt": "2026-07-06T09:12:00Z",
    "checkIntervalMinutes": 5
  }
]
```

### get\_connection\_health

Uptime percentage, average response time, and the latest check and failure for one connection over a recent window.

| Parameter       | Type   | Required | Description                             |
| --------------- | ------ | -------- | --------------------------------------- |
| `connection_id` | string | Yes      | Connection id from `list_connections`   |
| `hours`         | number | No       | Window size in hours, 1–48 (default 24) |

```json theme={null}
{
  "connection": { "id": "8f14e45f-...", "name": "Production n8n", "platform": "n8n" },
  "windowHours": 24,
  "totalChecks": 288,
  "uptimePercent": 99.65,
  "avgResponseTimeMs": 142,
  "latestCheck": { "at": "2026-07-06T09:10:00Z", "available": true, "responseTimeMs": 131 },
  "latestFailure": { "at": "2026-07-05T22:40:00Z", "error": "Request timed out" }
}
```

### list\_recent\_executions

Recent workflow executions across your connections, optionally filtered by connection or status.

| Parameter       | Type   | Required | Description                                                  |
| --------------- | ------ | -------- | ------------------------------------------------------------ |
| `connection_id` | string | No       | Limit results to one connection                              |
| `status`        | string | No       | One of `success`, `error`, `running`, `waiting`, `cancelled` |
| `limit`         | number | No       | Max rows, 1–100 (default 25)                                 |

### get\_openclaw\_usage

Token usage and estimated USD spend for an OpenClaw connection, broken down by model.

| Parameter       | Type   | Required | Description                                   |
| --------------- | ------ | -------- | --------------------------------------------- |
| `connection_id` | string | Yes      | An OpenClaw connection id                     |
| `period`        | string | No       | One of `day`, `week`, `month` (default `day`) |

```json theme={null}
{
  "connection": { "id": "3c59dc04-...", "name": "OpenClaw Prod" },
  "period": "week",
  "since": "2026-06-29T09:00:00Z",
  "totalSpendUsd": 42.318,
  "byModel": [
    {
      "model": "claude-sonnet-5",
      "inputTokens": 18400000,
      "outputTokens": 2100000,
      "spendUsd": 38.12,
      "requests": 5210
    }
  ]
}
```

<Note>
  This tool only works for OpenClaw connections. Calling it with an n8n or Make.com connection returns an error.
</Note>

### list\_anomalies

Statistical anomalies detected across your connections — response-time spikes, failure-rate spikes, and unusual OpenClaw token spend. See [availability monitoring](/analytics/availability-monitoring) for how baselines are computed.

| Parameter | Type   | Required | Description                                      |
| --------- | ------ | -------- | ------------------------------------------------ |
| `status`  | string | No       | Filter by lifecycle status: `open` or `resolved` |
| `limit`   | number | No       | Max rows, 1–100 (default 25)                     |

### get\_alert\_history

Recent alert notifications sent for your connections — failures, recoveries, audits, budget warnings, and anomalies.

| Parameter | Type   | Required | Description                  |
| --------- | ------ | -------- | ---------------------------- |
| `limit`   | number | No       | Max rows, 1–100 (default 25) |

## Example Prompts

Once connected, try asking your assistant:

* "Which of my connections are currently down?"
* "What was the uptime of my production n8n over the last 48 hours?"
* "Show me the failed executions from today and summarize the errors."
* "How much have I spent on OpenClaw this month, per model?"
* "Are there any open anomalies I should look at?"

## Security

* **Read-only** — no tool can create, modify, or delete anything in your account
* **User-scoped** — tools only return data for connections you own or can reach through an organization; there is no way to widen the scope from the client
* **HTTPS only** — the server is only reachable over TLS
* **Revocable** — remove the connector from your MCP client (or revoke the app from your Opsmatic account settings) to cut off access at any time

## Troubleshooting

<AccordionGroup>
  <Accordion title="The OAuth sign-in never completes">
    Make sure your client supports OAuth 2.1 with dynamic client registration (recent versions of Claude, Cursor, and VS Code all do). If the browser window was closed mid-flow, remove and re-add the server to restart authorization.
  </Accordion>

  <Accordion title="Tools return 'Connection not found or not accessible'">
    The connection id doesn't belong to your user or any organization you're a member of. Call `list_connections` first and use an id from its output.
  </Accordion>

  <Accordion title="The server returns 404">
    Check the URL is exactly `https://opsmatic.io/api/mcp` and the client is configured for HTTP (Streamable HTTP) transport — the legacy SSE transport is not supported.
  </Accordion>

  <Accordion title="Empty results from every tool">
    Your account has no connections yet, or they belong to an organization you haven't joined. Set one up first — see [connections overview](/connections/overview).
  </Accordion>
</AccordionGroup>
