PR

Prometheus MCP Server Golang Single Binary API

Deploy a Golang MCP server single-binary for Prometheus with full API support and STDIO, SSE, and HTTP transports for complex deployments.

Quick Install
npx -y @tjhop/prometheus-mcp-server

Overview

This project provides a single-binary Golang server that implements the Model Context Protocol (MCP) with first-class support for multiple transports (STDIO, Server-Sent Events, and HTTP). It is designed to be embedded into Prometheus-centric environments or used as a lightweight broker between Prometheus components and external tools that need a persistent, stream-oriented API surface.

Because it ships as a single statically linked executable, the server is easy to deploy in containerized, edge, or bare-metal environments. The multi-transport approach allows the same MCP API to be consumed over direct process pipes (STDIO), streaming HTTP (SSE), or traditional request/response HTTP — making it suitable for complex topologies such as sidecars, proxies, central aggregators, and CI-driven testing harnesses.

Features

  • Single static Go binary for simple deployment and distribution
  • Full MCP API support (model/context streaming and request handling)
  • Multiple transport options:
    • STDIO for local piping and sidecar use
    • Server-Sent Events (SSE) for long-lived streaming over HTTP
    • Standard HTTP endpoints for request/response interactions
  • TLS support for HTTP/SSE transports
  • Structured logging and runtime flags for easy integration into scripts and service managers
  • Docker-friendly and suitable for use in Kubernetes or systemd-managed hosts

Installation / Configuration

Build from source (Go 1.18+ recommended):

# Clone and build
git clone https://github.com/tjhop/prometheus-mcp-server.git
cd prometheus-mcp-server
go build -o prometheus-mcp-server ./cmd/prometheus-mcp-server

Install via go install:

go install github.com/tjhop/prometheus-mcp-server/cmd/prometheus-mcp-server@latest
# binary will be in $GOPATH/bin or $GOBIN

Common runtime flags (examples):

# Basic HTTP SSE server on port 8080
./prometheus-mcp-server --sse --addr ":8080"

# HTTP API server with TLS
./prometheus-mcp-server --http --addr ":8443" --tls-cert /path/cert.pem --tls-key /path/key.pem

# STDIO mode (useful for sidecars or piping)
cat events.json | ./prometheus-mcp-server --stdio

Example Dockerfile:

FROM golang:1.20-alpine AS build
WORKDIR /src
COPY . .
RUN go build -o /out/prometheus-mcp-server ./cmd/prometheus-mcp-server

FROM alpine:3.18
COPY --from=build /out/prometheus-mcp-server /usr/local/bin/prometheus-mcp-server
EXPOSE 8080 8443
ENTRYPOINT ["/usr/local/bin/prometheus-mcp-server"]

Example systemd service unit:

[Unit]
Description=Prometheus MCP Server
After=network.target

[Service]
ExecStart=/usr/local/bin/prometheus-mcp-server --sse --addr :8080 --log-level info
Restart=on-failure
User=prometheus

[Install]
WantedBy=multi-user.target

Available Tools / Resources

  • GitHub repository: https://github.com/tjhop/prometheus-mcp-server
  • Use the binary flags --help to enumerate supported transports, TLS options, and logging:
    • Example: ./prometheus-mcp-server --help
  • Logs are typically emitted to stdout/stderr for easy collection with container logging drivers or systemd journal

API surface (typical endpoints and transport mappings — concrete routes may vary; consult --help output):

TransportTypical EndpointNotes
STDIOstdin / stdoutUseful for chaining processes or running as a sidecar
SSE/sse or /streamLong-lived HTTP streaming clients should use curl -N or EventSource
HTTP/api/*Request/response interactions and health checks

Use Cases

  • Sidecar integration with Prometheus exporters: Run the MCP server as a sidecar and connect via STDIO to supply model updates directly to a local exporter process.
  • Central stream broker: Deploy the server as a central MCP broker using SSE to distribute model/context updates to many monitoring consumers across a cluster.
  • CI / E2E testing: Use the STDIO mode to script synthetic model streams for automated tests, without needing a full networked stack.
  • Hybrid deployments: Front the MCP server with an HTTP/SSE transport for remote clients while exposing STDIO for local administrative tooling.
  • Secure edge deployments: Use the single binary with TLS on the SSE or HTTP transport to securely relay Prometheus-related model data from untrusted networks to trusted collectors.

Quick Examples

Subscribe to SSE stream with curl:

# Open a live SSE stream (replace path/port based on flags)
curl -N http://localhost:8080/sse

Post a model/context update over HTTP:

curl -X POST http://localhost:9090/api/mcp \
  -H "Content-Type: application/json" \
  -d '{"model":"example","data":{"metric":"cpu","value":0.42}}'

Pipe input via STDIO:

cat sample-events.json | ./prometheus-mcp-server --stdio

Notes for Developers

  • Check the repository README and CLI --help for exact flag names and route paths, as they can change between releases.
  • The single-binary design favors immutable deployments (containers or artifacts in CI). For dynamic configuration, wrap the binary with a small supervising process or systemd unit that adjusts flags and TLS artifacts.
  • For production use, enable TLS for public-facing SSE/HTTP endpoints and integrate logging with your existing observability stack.

For code, issues, and updates, see the project on GitHub: https://github.com/tjhop/prometheus-mcp-server/