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:
services:
meshmonitor:
environment:
- ENABLE_MCP_SERVER=trueThe 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.
| Variable | Default | Meaning |
|---|---|---|
ENABLE_MCP_SERVER | false | Mount the MCP server at /mcp. Without it the route does not exist. |
RATE_LIMIT_MCP | 120 (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:
- 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.
- 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 β
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):
{
"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):
{
"mcpServers": {
"meshmonitor": {
"url": "https://mesh.example.com/mcp",
"headers": { "Authorization": "Bearer mm_v1_..." }
}
}
}VS Code (Copilot agent mode) β
.vscode/mcp.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 β
| Tool | What it returns | Needs (on that source) |
|---|---|---|
whoami | The token's user and its permissions per source | any token |
list_sources | Sources the user can read | β |
get_status | Connection state and local node | info read |
list_nodes, get_node | Nodes (active in the last N days, or all) | nodes read, plus channel visibility |
list_channels | Channel index, name and role (never keys) | messages read |
list_messages, search_messages | Channel messages and DMs | messages read, plus per-channel read |
get_telemetry | Telemetry for a source or one node | nodes read |
list_traceroutes | Recorded traceroutes (history only) | traceroute read |
list_neighbors | Nodes heard directly (zero hops) | nodes read |
list_packets | Packet log rows (when the packet log is on) | packetmonitor read |
get_recent_activity | Recent messages across every readable source | per 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=truethere is no/mcproute. - 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/v1endpoint, 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
AuthorizationandMcp-Session-Idheaders through, and - does not buffer responses on
/mcp(nginx:proxy_buffering off;), since replies may stream.
Troubleshooting β
| Symptom | Cause |
|---|---|
404 on /mcp | ENABLE_MCP_SERVER is not true, or you need <BASE_URL>/mcp. |
401 | Missing, wrong or revoked token. |
Tool returns 403 | The token's user has no grant for that resource on that source. Run whoami. |
| Empty node or message lists | The user can read the source but not those channels (channel read / view-on-map grants). |
429 | RATE_LIMIT_MCP reached; wait a minute or raise it. |
