Skip to content

MCP Server (AI agents) ​

MeshMonitor can expose a Model Context Protocol (MCP) server, so an AI assistant (Claude Desktop, Claude Code, Cursor, VS Code, or any MCP client) can answer questions about your mesh: "who was active on LongFast in the last hour?", "summarize today's messages", "which nodes have low batteries?", "what does the path to !a1b2c3d4 look like?".

The MCP server is off by default and read-only. It cannot send messages, request traceroutes or positions, or change any setting, so nothing an agent does through it puts a packet on the air.

Turn it on ​

Set one environment variable and restart MeshMonitor:

yaml
services:
  meshmonitor:
    environment:
      - ENABLE_MCP_SERVER=true

The server listens on the same port as the web UI, at /mcp (or <BASE_URL>/mcp when you run under a BASE_URL). The log shows MCP server enabled at /mcp at startup.

VariableDefaultMeaning
ENABLE_MCP_SERVERfalseMount the MCP server at /mcp. Without it the route does not exist.
RATE_LIMIT_MCP120 (600 in development)MCP requests per minute per client IP. 0 disables the limit.

Create a token ​

The MCP server uses the same API tokens as the REST API:

  1. Create a user for the agent (recommended), and grant it only what it should read, per source. A dedicated user keeps the agent's access separate from yours and lets you revoke it on its own.
  2. Sign in as that user, open the user menu, choose API Token, and generate a token. It starts with mm_v1_ and is shown once.

The agent is that user. It sees exactly what that user sees in the UI and the v1 API, on exactly the sources that user can read.

Connect your AI tool ​

Replace https://mesh.example.com with your MeshMonitor address and mm_v1_... with the token.

Claude Code ​

bash
claude mcp add --transport http meshmonitor https://mesh.example.com/mcp \
  --header "Authorization: Bearer mm_v1_..."

Claude Desktop ​

Claude Desktop reaches remote servers through mcp-remote (needs Node.js). In Settings β†’ Developer β†’ Edit Config (claude_desktop_config.json):

json
{
  "mcpServers": {
    "meshmonitor": {
      "command": "npx",
      "args": ["-y", "mcp-remote", "https://mesh.example.com/mcp",
               "--header", "Authorization:${MESHMONITOR_AUTH}"],
      "env": { "MESHMONITOR_AUTH": "Bearer mm_v1_..." }
    }
  }
}

(The header value goes through an environment variable because some platforms split arguments on the space in Bearer mm_v1_....)

Cursor ​

~/.cursor/mcp.json (or .cursor/mcp.json in a project):

json
{
  "mcpServers": {
    "meshmonitor": {
      "url": "https://mesh.example.com/mcp",
      "headers": { "Authorization": "Bearer mm_v1_..." }
    }
  }
}

VS Code (Copilot agent mode) ​

.vscode/mcp.json:

json
{
  "servers": {
    "meshmonitor": {
      "type": "http",
      "url": "https://mesh.example.com/mcp",
      "headers": { "Authorization": "Bearer mm_v1_..." }
    }
  }
}

Other clients ​

Any client that speaks MCP over Streamable HTTP and can send an Authorization header works. Point it at /mcp with Authorization: Bearer mm_v1_....

claude.ai web and mobile

Custom connectors in the claude.ai web and mobile apps sign in with OAuth, which this server does not offer yet (it takes API tokens only). Use Claude Desktop or Claude Code, or put an OAuth-capable MCP proxy in front.

What the agent can read ​

ToolWhat it returnsNeeds (on that source)
whoamiThe token's user and its permissions per sourceany token
list_sourcesSources the user can readβ€”
get_statusConnection state and local nodeinfo read
list_nodes, get_nodeNodes (active in the last N days, or all)nodes read, plus channel visibility
list_channelsChannel index, name and role (never keys)messages read
list_messages, search_messagesChannel messages and DMsmessages read, plus per-channel read
get_telemetryTelemetry for a source or one nodenodes read
list_traceroutesRecorded traceroutes (history only)traceroute read
list_neighborsNodes heard directly (zero hops)nodes read
list_packetsPacket log rows (when the packet log is on)packetmonitor read
get_recent_activityRecent messages across every readable sourceper source, as list_messages

Resources: meshmonitor://sources, meshmonitor://status, meshmonitor://nodes/{sourceId}, meshmonitor://messages/{sourceId}.

Most tools take a sourceId; default means the user's default source, as in the v1 API.

Security model ​

  • Off by default. Without ENABLE_MCP_SERVER=true there is no /mcp route.
  • The token is the user. The agent can never do more than the token's user. Each tool runs the same code as the matching /api/v1 endpoint, behind the same per-source permission check, so channel filtering, private-position redaction and hidden nodes behave exactly as they do in the API.
  • Checked on every request. The token is re-validated on every MCP request, not just when the session opens. Revoke or regenerate the token and the agent loses access on its next call.
  • Sessions are bound to their user. A session opened with one user's token cannot be used with another's.
  • Read-only. No tool sends a packet, so the MCP server adds no airtime.
  • Rate-limited by its own limiter (RATE_LIMIT_MCP), separate from the web UI's.
  • Audited. Every request shows up in the audit log as API token use.

Message text and node names come from other people on the mesh. A well-behaved agent treats them as data, but if you let an agent act on what it reads (in other tools you give it), keep that in mind.

Reverse proxies ​

If MeshMonitor sits behind nginx, Caddy or a tunnel, make sure the proxy:

  • passes the Authorization and Mcp-Session-Id headers through, and
  • does not buffer responses on /mcp (nginx: proxy_buffering off;), since replies may stream.

Troubleshooting ​

SymptomCause
404 on /mcpENABLE_MCP_SERVER is not true, or you need <BASE_URL>/mcp.
401Missing, wrong or revoked token.
Tool returns 403The token's user has no grant for that resource on that source. Run whoami.
Empty node or message listsThe user can read the source but not those channels (channel read / view-on-map grants).
429RATE_LIMIT_MCP reached; wait a minute or raise it.