Prometheus MCP server

Bridges Prometheus metrics data to enable easy retrieval and analysis of monitoring information for automated system health checks, performance tracking, and anomaly detection.
Back to servers
Provider
LogLM
Release date
Dec 06, 2024
Language
TypeScript
Stats
14 stars

This MCP server provides a bridge between Claude and your Prometheus monitoring system through the Model Context Protocol. It allows Claude to access and analyze metrics from your Prometheus instance, enabling natural language interactions with your monitoring data.

Installation

To use the MCP Prometheus server with Claude Desktop, you'll need to add the server configuration to your Claude Desktop config file.

Prerequisites

  • Claude Desktop installed
  • Node.js and npm installed
  • Access to a Prometheus instance

Setup Configuration

Add the server configuration to your Claude Desktop config file:

On MacOS:

~/Library/Application Support/Claude/claude_desktop_config.json

On Windows:

%APPDATA%/Claude/claude_desktop_config.json

Edit the configuration file to include:

{
  "mcpServers": {
    "mcp-server-prometheus": {
      "command": "/path/to/mcp-server-prometheus/build/index.js",
      "env": {
        "PROMETHEUS_URL": "http://your-prometheus-instance:9090"
      }
    }
  }
}

Environment Variables

Configure the server with these environment variables:

  • Required:

    • PROMETHEUS_URL: The base URL of your Prometheus instance
  • Optional (for authenticated Prometheus instances):

    • PROMETHEUS_USERNAME: Username for basic auth
    • PROMETHEUS_PASSWORD: Password for basic auth

Usage

Once configured, Claude can interact with your Prometheus metrics through natural language.

Available Resources

The MCP server provides access to:

  • Metric listings: Browse all available Prometheus metrics
  • Metric details: For each metric, access:
    • Name and description
    • Detailed metadata from Prometheus
    • Statistical information (count, min, max values)

Example Interactions

You can ask Claude questions about your Prometheus metrics such as:

  • "What metrics are available in my Prometheus instance?"
  • "Show me details about the CPU usage metric"
  • "What's the current maximum value for memory utilization?"

Debugging

If you encounter issues, you can use the MCP Inspector for debugging:

npm run inspector

This will provide a URL to access debugging tools in your browser, which is helpful since MCP servers communicate over stdio.

API Structure

The server exposes Prometheus metrics through the following URI structure:

  • Base URI: http://your-prometheus-instance:9090
  • Metric URIs: http://your-prometheus-instance:9090/metrics/{metric_name}

Each metric resource returns structured JSON data containing the metric's name, metadata, and current statistics.

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later