# MCP setup (/docs/mcp)

> Connect Cursor, Claude, and other MCP clients to ServerMetry for AI-assisted monitoring.



ServerMetry exposes an [MCP](https://modelcontextprotocol.io/) endpoint so AI assistants can query servers, alerts, and related resources — and perform selected write actions.

## Endpoint [#endpoint]

| Environment | MCP URL                           |
| ----------- | --------------------------------- |
| Production  | `https://api.servermetry.com/mcp` |
| Local API   | `http://localhost:3601/mcp`       |

Use the **direct API URL** for MCP clients. Do not point Cursor/Claude at the frontend origin.

## Create an MCP key [#create-an-mcp-key]

1. Sign in to the dashboard
2. Open **Settings → MCP Keys** (or API Keys)
3. Create a key — it is shown **once**; store it securely

Keys are organization-scoped (`sp_mcp_…`).

## Cursor [#cursor]

Add to `~/.cursor/mcp.json` or a project `.cursor/mcp.json`:

```json
{
  "mcpServers": {
    "servermetry": {
      "url": "https://api.servermetry.com/mcp",
      "headers": {
        "Authorization": "Bearer sp_mcp_YOUR_KEY"
      }
    }
  }
}
```

Reload Cursor so the MCP connection refreshes.

## Claude Desktop / Claude Code [#claude-desktop--claude-code]

Use the same URL and `Authorization: Bearer …` header in the Claude MCP server config (see the dashboard page for a ready-made JSON snippet).

## Example tools [#example-tools]

| Tool                                                           | Purpose                 |
| -------------------------------------------------------------- | ----------------------- |
| `get_dashboard`                                                | Aggregated overview     |
| `list_servers` / `get_server`                                  | Fleet and server detail |
| `list_alerts` / `resolve_alert`                                | Alert triage            |
| `list_alert_rules` / `create_alert_rule` / `delete_alert_rule` | Rule management         |
| `list_notification_channels`                                   | Channels                |
| `list_services` / `create_service` / …                         | Service monitoring      |
| `list_projects` / `create_project` / …                         | Projects                |
| `list_backup_plans` / `create_backup_plan`                     | Backup plans            |
| `list_maintenance_windows` / …                                 | Maintenance             |
| `list_templates`                                               | Templates               |

The full tool list is returned by the MCP `tools/list` handshake.

## Example prompts [#example-prompts]

```
Use ServerMetry MCP: list all servers with status OFFLINE or CRITICAL and summarize what is going on.
```

```
Via ServerMetry MCP: list open CRITICAL alerts, group by server, and suggest which alert rules to review.
```

```
Create a global alert rule via ServerMetry MCP: name "High CPU", metric cpuUsagePercent, operator GT, threshold 90, severity CRITICAL, evaluation window 5 minutes.
```

## Security [#security]

* Never commit MCP keys to git
* Rotate keys regularly (delete + recreate in the dashboard)
* On compromise, delete the key immediately

## Troubleshooting [#troubleshooting]

| Problem            | Fix                                     |
| ------------------ | --------------------------------------- |
| `401 Unauthorized` | Check key and `Bearer ` prefix          |
| No connection      | Use API URL (not frontend), valid HTTPS |
| No tools listed    | Reload MCP panel; verify key org access |
| Empty server list  | Key belongs to a different organization |
