MCP integration

Custom (stdio + HTTP)

Embed Prometheus into your own MCP host or agent runtime. Covers stdio launch and the planned HTTP transport.

If you build your own agent runtime (Claude Code, OpenHands, an in-house CLI, …), Prometheus speaks plain stdio MCP and — from Phase 3 onward — HTTP/SSE for remote-only setups.

stdio (works today)

Spawn the server as a child process and pipe MCP JSON-RPC over its stdin/stdout. The package binary is prometheus-context-mcp.

import { spawn } from "node:child_process";

const server = spawn("npx", ["-y", "@prometheus/context-mcp@latest"], {
  env: {
    ...process.env,
    PROMETHEUS_API_KEY: process.env.PROMETHEUS_API_KEY!,
    PROMETHEUS_WORKSPACE_ID: process.env.PROMETHEUS_WORKSPACE_ID!,
  },
  stdio: ["pipe", "pipe", "inherit"],
});

// Wire server.stdin / server.stdout into your MCP client transport.

Any compliant MCP client transport works. The reference Node SDK uses StdioClientTransport from @modelcontextprotocol/sdk.

Environment variables

VariableRequiredDefaultPurpose
PROMETHEUS_API_KEYyesTenant-scoped bearer token.
PROMETHEUS_WORKSPACE_IDyesUUID of the workspace to query.
PROMETHEUS_WORKER_URLnohosted Railway URLOverride for self-hosted workers or staging.
PROMETHEUS_REGION_MODEnodefaultOne of default, eu-permissive, eu-strict. See Region mode.
PROMETHEUS_LOG_LEVELnoinfodebug, info, warn, error.

HTTP transport (Phase 3, in design)

For remote-only setups (browser-side agents, serverless functions, multi-tenant SaaS hosts) Prometheus will expose an HTTP/SSE transport at api.prom.codes/mcp. The wire protocol is the standard MCP streamable-HTTP binding — same tool surface, different framing.

Self-hosting the worker

The indexer worker is an Express + Node 22 service published as appworkers/prometheus-indexer-worker on Docker Hub. Point PROMETHEUS_WORKER_URL at your own deployment and you keep the entire pipeline in your VPC. See the GitHub repo for the Railway template once the worker is open-sourced.