raihan0824-prometheus-mcp-server


Nameraihan0824-prometheus-mcp-server JSON
Version 1.2.12 PyPI version JSON
download
home_pageNone
SummaryMCP server for Prometheus integration
upload_time2025-08-28 12:06:59
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseNone
keywords prometheus mcp monitoring metrics claude ai
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Prometheus MCP Server

A [Model Context Protocol][mcp] (MCP) server for Prometheus.

This provides access to your Prometheus metrics and queries through standardized MCP interfaces, allowing AI assistants to execute PromQL queries and analyze your metrics data.

<a href="https://glama.ai/mcp/servers/@pab1it0/prometheus-mcp-server">
  <img width="380" height="200" src="https://glama.ai/mcp/servers/@pab1it0/prometheus-mcp-server/badge" alt="Prometheus Server MCP server" />
</a>

[mcp]: https://modelcontextprotocol.io

## Quick Start

### 🚀 **For End Users (PyPI)**
```bash
# Install and run in one command
uvx --from raihan0824-prometheus-mcp-server prometheus-mcp-server
```

### 🛠️ **For Developers (Local)**
```bash
# Clone and install in development mode
git clone https://github.com/raihan0824/prometheus-mcp-server.git
cd prometheus-mcp-server
uv pip install -e .
prometheus-mcp-server
```

## Features

- [x] Execute PromQL queries against Prometheus
- [x] Discover and explore metrics
  - [x] List available metrics
  - [x] Get metadata for specific metrics
  - [x] View instant query results
  - [x] View range query results with different step intervals
- [x] Authentication support
  - [x] Basic auth from environment variables
  - [x] Bearer token auth from environment variables
- [x] Docker containerization support

- [x] Provide interactive tools for AI assistants

The list of tools is configurable, so you can choose which tools you want to make available to the MCP client.
This is useful if you don't use certain functionality or if you don't want to take up too much of the context window.

## Installation

### Option 1: Install from PyPI (Recommended for Users)

```bash
# Using uvx (recommended for Claude Desktop)
uvx --from raihan0824-prometheus-mcp-server prometheus-mcp-server

# Using pip
pip install raihan0824-prometheus-mcp-server

# Using uv
uv add raihan0824-prometheus-mcp-server
```

### Option 2: Install from Source (For Development)

```bash
# Clone the repository
git clone https://github.com/raihan0824/prometheus-mcp-server.git
cd prometheus-mcp-server

# Install with uv (development mode)
uv pip install -e .

# Or install with pip (development mode)
pip install -e .
```

## Usage

### For End Users (Using PyPI Package)

If you want to use the pre-built package from PyPI:

```bash
# Install and run in one command
uvx --from raihan0824-prometheus-mcp-server prometheus-mcp-server

# Or install permanently
pip install raihan0824-prometheus-mcp-server
prometheus-mcp-server
```

### For Developers (Local Development)

If you want to modify the code or contribute:

```bash
# Clone and install in development mode
git clone https://github.com/raihan0824/prometheus-mcp-server.git
cd prometheus-mcp-server
uv pip install -e .

# Run the development version
prometheus-mcp-server
```

---

1. Ensure your Prometheus server is accessible from the environment where you'll run this MCP server.

2. Configure the environment variables for your Prometheus server, either through a `.env` file or system environment variables:

```env
# Required: Prometheus configuration
PROMETHEUS_URL=http://your-prometheus-server:9090

# Optional: Authentication credentials (if needed)
# Choose one of the following authentication methods if required:

# For basic auth
PROMETHEUS_USERNAME=your_username
PROMETHEUS_PASSWORD=your_password

# For bearer token auth
PROMETHEUS_TOKEN=your_token

# Optional: Custom MCP configuration
PROMETHEUS_MCP_SERVER_TRANSPORT=stdio # Choose between http, stdio, sse. If undefined, stdio is set as the default transport.

# Optional: Only relevant for non-stdio transports
PROMETHEUS_MCP_BIND_HOST=localhost # if undefined, 127.0.0.1 is set by default.
PROMETHEUS_MCP_BIND_PORT=8080 # if undefined, 8080 is set by default.

# Optional: For multi-tenant setups like Cortex, Mimir or Thanos
ORG_ID=your_organization_id
```

3. Add the server configuration to your client configuration file. For example, for Claude Desktop:

### Option A: Using uvx with PyPI package (Recommended for Users)

```json
{
  "mcpServers": {
    "prometheus": {
      "command": "uvx",
      "args": [
        "--from",
        "raihan0824-prometheus-mcp-server",
        "prometheus-mcp-server"
      ],
      "env": {
        "PROMETHEUS_URL": "<your-prometheus-url>",
        "PROMETHEUS_USERNAME": "<your-username>",
        "PROMETHEUS_PASSWORD": "<your-password>"
      }
    }
  }
}
```

### Option B: Using uvx with local repository

```json
{
  "mcpServers": {
    "prometheus": {
      "command": "uvx",
      "args": [
        "--directory",
        "/path/to/prometheus-mcp-server",
        "run",
        "prometheus-mcp-server"
      ],
      "env": {
        "PROMETHEUS_URL": "<your-prometheus-url>",
        "PROMETHEUS_USERNAME": "<your-username>",
        "PROMETHEUS_PASSWORD": "<your-password>"
      }
    }
  }
}
```

### Option C: Using uvx with Git repository

```json
{
  "mcpServers": {
    "prometheus": {
      "command": "uvx",
      "args": [
        "run",
        "--from",
        "git+https://github.com/raihan0824/prometheus-mcp-server.git",
        "prometheus-mcp-server"
      ],
      "env": {
        "PROMETHEUS_URL": "<your-prometheus-url>",
        "PROMETHEUS_USERNAME": "<your-username>",
        "PROMETHEUS_PASSWORD": "<your-password>"
      }
    }
  }
}
```

### Option D: Using Docker (Legacy)

```json
{
  "mcpServers": {
    "prometheus": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "PROMETHEUS_URL",
        "ghcr.io/pab1it0/prometheus-mcp-server:latest"
      ],
      "env": {
        "PROMETHEUS_URL": "<url>",
        "PROMETHEUS_MCP_SERVER_TRANSPORT": "http",
        "PROMETHEUS_MCP_BIND_HOST": "localhost",
        "PROMETHEUS_MCP_BIND_PORT": "8080"
      }
    }
  }
}
```


## Development

Contributions are welcome! Please open an issue or submit a pull request if you have any suggestions or improvements.

This project uses [`uv`](https://github.com/astral-sh/uv) to manage dependencies. Install `uv` following the instructions for your platform:

```bash
curl -LsSf https://astral.sh/uv/install.sh | sh
```

You can then create a virtual environment and install the dependencies with:

```bash
uv venv
source .venv/bin/activate  # On Unix/macOS
.venv\Scripts\activate     # On Windows
uv pip install -e .
```

## Project Structure

The project has been organized with a `src` directory structure:

```
prometheus-mcp-server/
├── src/
│   └── prometheus_mcp_server/
│       ├── __init__.py      # Package initialization
│       ├── server.py        # MCP server implementation
│       ├── main.py          # Main application logic
├── Dockerfile               # Docker configuration
├── docker-compose.yml       # Docker Compose configuration
├── .dockerignore            # Docker ignore file
├── pyproject.toml           # Project configuration
└── README.md                # This file
```

### Testing

The project includes a comprehensive test suite that ensures functionality and helps prevent regressions.

Run the tests with pytest:

```bash
# Install development dependencies
uv pip install -e ".[dev]"

# Run the tests
pytest

# Run with coverage report
pytest --cov=src --cov-report=term-missing
```
Tests are organized into:

- Configuration validation tests
- Server functionality tests
- Error handling tests
- Main application tests

When adding new features, please also add corresponding tests.

### Tools

| Tool | Category | Description |
| --- | --- | --- |
| `execute_query` | Query | Execute a PromQL instant query against Prometheus |
| `execute_range_query` | Query | Execute a PromQL range query with start time, end time, and step interval |
| `list_metrics` | Discovery | List all available metrics in Prometheus |
| `get_metric_metadata` | Discovery | Get metadata for a specific metric |
| `get_targets` | Discovery | Get information about all scrape targets |

## License

MIT

---

[mcp]: https://modelcontextprotocol.io

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "raihan0824-prometheus-mcp-server",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "raihan0824 <mraihanafiandi@gmail.com>",
    "keywords": "prometheus, mcp, monitoring, metrics, claude, ai",
    "author": null,
    "author_email": "raihan0824 <mraihanafiandi@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/32/b5/d3e02f1b8cfa74e7a9c4f3ecda549d542e55672eb9234b1b4246301dc148/raihan0824_prometheus_mcp_server-1.2.12.tar.gz",
    "platform": null,
    "description": "# Prometheus MCP Server\n\nA [Model Context Protocol][mcp] (MCP) server for Prometheus.\n\nThis provides access to your Prometheus metrics and queries through standardized MCP interfaces, allowing AI assistants to execute PromQL queries and analyze your metrics data.\n\n<a href=\"https://glama.ai/mcp/servers/@pab1it0/prometheus-mcp-server\">\n  <img width=\"380\" height=\"200\" src=\"https://glama.ai/mcp/servers/@pab1it0/prometheus-mcp-server/badge\" alt=\"Prometheus Server MCP server\" />\n</a>\n\n[mcp]: https://modelcontextprotocol.io\n\n## Quick Start\n\n### \ud83d\ude80 **For End Users (PyPI)**\n```bash\n# Install and run in one command\nuvx --from raihan0824-prometheus-mcp-server prometheus-mcp-server\n```\n\n### \ud83d\udee0\ufe0f **For Developers (Local)**\n```bash\n# Clone and install in development mode\ngit clone https://github.com/raihan0824/prometheus-mcp-server.git\ncd prometheus-mcp-server\nuv pip install -e .\nprometheus-mcp-server\n```\n\n## Features\n\n- [x] Execute PromQL queries against Prometheus\n- [x] Discover and explore metrics\n  - [x] List available metrics\n  - [x] Get metadata for specific metrics\n  - [x] View instant query results\n  - [x] View range query results with different step intervals\n- [x] Authentication support\n  - [x] Basic auth from environment variables\n  - [x] Bearer token auth from environment variables\n- [x] Docker containerization support\n\n- [x] Provide interactive tools for AI assistants\n\nThe list of tools is configurable, so you can choose which tools you want to make available to the MCP client.\nThis is useful if you don't use certain functionality or if you don't want to take up too much of the context window.\n\n## Installation\n\n### Option 1: Install from PyPI (Recommended for Users)\n\n```bash\n# Using uvx (recommended for Claude Desktop)\nuvx --from raihan0824-prometheus-mcp-server prometheus-mcp-server\n\n# Using pip\npip install raihan0824-prometheus-mcp-server\n\n# Using uv\nuv add raihan0824-prometheus-mcp-server\n```\n\n### Option 2: Install from Source (For Development)\n\n```bash\n# Clone the repository\ngit clone https://github.com/raihan0824/prometheus-mcp-server.git\ncd prometheus-mcp-server\n\n# Install with uv (development mode)\nuv pip install -e .\n\n# Or install with pip (development mode)\npip install -e .\n```\n\n## Usage\n\n### For End Users (Using PyPI Package)\n\nIf you want to use the pre-built package from PyPI:\n\n```bash\n# Install and run in one command\nuvx --from raihan0824-prometheus-mcp-server prometheus-mcp-server\n\n# Or install permanently\npip install raihan0824-prometheus-mcp-server\nprometheus-mcp-server\n```\n\n### For Developers (Local Development)\n\nIf you want to modify the code or contribute:\n\n```bash\n# Clone and install in development mode\ngit clone https://github.com/raihan0824/prometheus-mcp-server.git\ncd prometheus-mcp-server\nuv pip install -e .\n\n# Run the development version\nprometheus-mcp-server\n```\n\n---\n\n1. Ensure your Prometheus server is accessible from the environment where you'll run this MCP server.\n\n2. Configure the environment variables for your Prometheus server, either through a `.env` file or system environment variables:\n\n```env\n# Required: Prometheus configuration\nPROMETHEUS_URL=http://your-prometheus-server:9090\n\n# Optional: Authentication credentials (if needed)\n# Choose one of the following authentication methods if required:\n\n# For basic auth\nPROMETHEUS_USERNAME=your_username\nPROMETHEUS_PASSWORD=your_password\n\n# For bearer token auth\nPROMETHEUS_TOKEN=your_token\n\n# Optional: Custom MCP configuration\nPROMETHEUS_MCP_SERVER_TRANSPORT=stdio # Choose between http, stdio, sse. If undefined, stdio is set as the default transport.\n\n# Optional: Only relevant for non-stdio transports\nPROMETHEUS_MCP_BIND_HOST=localhost # if undefined, 127.0.0.1 is set by default.\nPROMETHEUS_MCP_BIND_PORT=8080 # if undefined, 8080 is set by default.\n\n# Optional: For multi-tenant setups like Cortex, Mimir or Thanos\nORG_ID=your_organization_id\n```\n\n3. Add the server configuration to your client configuration file. For example, for Claude Desktop:\n\n### Option A: Using uvx with PyPI package (Recommended for Users)\n\n```json\n{\n  \"mcpServers\": {\n    \"prometheus\": {\n      \"command\": \"uvx\",\n      \"args\": [\n        \"--from\",\n        \"raihan0824-prometheus-mcp-server\",\n        \"prometheus-mcp-server\"\n      ],\n      \"env\": {\n        \"PROMETHEUS_URL\": \"<your-prometheus-url>\",\n        \"PROMETHEUS_USERNAME\": \"<your-username>\",\n        \"PROMETHEUS_PASSWORD\": \"<your-password>\"\n      }\n    }\n  }\n}\n```\n\n### Option B: Using uvx with local repository\n\n```json\n{\n  \"mcpServers\": {\n    \"prometheus\": {\n      \"command\": \"uvx\",\n      \"args\": [\n        \"--directory\",\n        \"/path/to/prometheus-mcp-server\",\n        \"run\",\n        \"prometheus-mcp-server\"\n      ],\n      \"env\": {\n        \"PROMETHEUS_URL\": \"<your-prometheus-url>\",\n        \"PROMETHEUS_USERNAME\": \"<your-username>\",\n        \"PROMETHEUS_PASSWORD\": \"<your-password>\"\n      }\n    }\n  }\n}\n```\n\n### Option C: Using uvx with Git repository\n\n```json\n{\n  \"mcpServers\": {\n    \"prometheus\": {\n      \"command\": \"uvx\",\n      \"args\": [\n        \"run\",\n        \"--from\",\n        \"git+https://github.com/raihan0824/prometheus-mcp-server.git\",\n        \"prometheus-mcp-server\"\n      ],\n      \"env\": {\n        \"PROMETHEUS_URL\": \"<your-prometheus-url>\",\n        \"PROMETHEUS_USERNAME\": \"<your-username>\",\n        \"PROMETHEUS_PASSWORD\": \"<your-password>\"\n      }\n    }\n  }\n}\n```\n\n### Option D: Using Docker (Legacy)\n\n```json\n{\n  \"mcpServers\": {\n    \"prometheus\": {\n      \"command\": \"docker\",\n      \"args\": [\n        \"run\",\n        \"-i\",\n        \"--rm\",\n        \"-e\",\n        \"PROMETHEUS_URL\",\n        \"ghcr.io/pab1it0/prometheus-mcp-server:latest\"\n      ],\n      \"env\": {\n        \"PROMETHEUS_URL\": \"<url>\",\n        \"PROMETHEUS_MCP_SERVER_TRANSPORT\": \"http\",\n        \"PROMETHEUS_MCP_BIND_HOST\": \"localhost\",\n        \"PROMETHEUS_MCP_BIND_PORT\": \"8080\"\n      }\n    }\n  }\n}\n```\n\n\n## Development\n\nContributions are welcome! Please open an issue or submit a pull request if you have any suggestions or improvements.\n\nThis project uses [`uv`](https://github.com/astral-sh/uv) to manage dependencies. Install `uv` following the instructions for your platform:\n\n```bash\ncurl -LsSf https://astral.sh/uv/install.sh | sh\n```\n\nYou can then create a virtual environment and install the dependencies with:\n\n```bash\nuv venv\nsource .venv/bin/activate  # On Unix/macOS\n.venv\\Scripts\\activate     # On Windows\nuv pip install -e .\n```\n\n## Project Structure\n\nThe project has been organized with a `src` directory structure:\n\n```\nprometheus-mcp-server/\n\u251c\u2500\u2500 src/\n\u2502   \u2514\u2500\u2500 prometheus_mcp_server/\n\u2502       \u251c\u2500\u2500 __init__.py      # Package initialization\n\u2502       \u251c\u2500\u2500 server.py        # MCP server implementation\n\u2502       \u251c\u2500\u2500 main.py          # Main application logic\n\u251c\u2500\u2500 Dockerfile               # Docker configuration\n\u251c\u2500\u2500 docker-compose.yml       # Docker Compose configuration\n\u251c\u2500\u2500 .dockerignore            # Docker ignore file\n\u251c\u2500\u2500 pyproject.toml           # Project configuration\n\u2514\u2500\u2500 README.md                # This file\n```\n\n### Testing\n\nThe project includes a comprehensive test suite that ensures functionality and helps prevent regressions.\n\nRun the tests with pytest:\n\n```bash\n# Install development dependencies\nuv pip install -e \".[dev]\"\n\n# Run the tests\npytest\n\n# Run with coverage report\npytest --cov=src --cov-report=term-missing\n```\nTests are organized into:\n\n- Configuration validation tests\n- Server functionality tests\n- Error handling tests\n- Main application tests\n\nWhen adding new features, please also add corresponding tests.\n\n### Tools\n\n| Tool | Category | Description |\n| --- | --- | --- |\n| `execute_query` | Query | Execute a PromQL instant query against Prometheus |\n| `execute_range_query` | Query | Execute a PromQL range query with start time, end time, and step interval |\n| `list_metrics` | Discovery | List all available metrics in Prometheus |\n| `get_metric_metadata` | Discovery | Get metadata for a specific metric |\n| `get_targets` | Discovery | Get information about all scrape targets |\n\n## License\n\nMIT\n\n---\n\n[mcp]: https://modelcontextprotocol.io\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "MCP server for Prometheus integration",
    "version": "1.2.12",
    "project_urls": {
        "Documentation": "https://github.com/raihan0824/prometheus-mcp-server/blob/main/README.md",
        "Homepage": "https://github.com/raihan0824/prometheus-mcp-server",
        "Issues": "https://github.com/raihan0824/prometheus-mcp-server/issues",
        "Repository": "https://github.com/raihan0824/prometheus-mcp-server"
    },
    "split_keywords": [
        "prometheus",
        " mcp",
        " monitoring",
        " metrics",
        " claude",
        " ai"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "36472e3932edb0888808397237aff9933e8ab1ec8e25bb08e68097de3746df9d",
                "md5": "f7c60c858ade2d24c32e3bbf40f244e1",
                "sha256": "7e4cf43a0ffe47b23f2c8917508864ad796ec11985bfd70257e52c452d3d8264"
            },
            "downloads": -1,
            "filename": "raihan0824_prometheus_mcp_server-1.2.12-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f7c60c858ade2d24c32e3bbf40f244e1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 12181,
            "upload_time": "2025-08-28T12:06:58",
            "upload_time_iso_8601": "2025-08-28T12:06:58.395089Z",
            "url": "https://files.pythonhosted.org/packages/36/47/2e3932edb0888808397237aff9933e8ab1ec8e25bb08e68097de3746df9d/raihan0824_prometheus_mcp_server-1.2.12-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "32b5d3e02f1b8cfa74e7a9c4f3ecda549d542e55672eb9234b1b4246301dc148",
                "md5": "090ef13168940919dacfa24b55c64e57",
                "sha256": "9a54762d39f900be91289b483a33a7a0c9e418c7192118bb65d7fcf19a5b5969"
            },
            "downloads": -1,
            "filename": "raihan0824_prometheus_mcp_server-1.2.12.tar.gz",
            "has_sig": false,
            "md5_digest": "090ef13168940919dacfa24b55c64e57",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 22299,
            "upload_time": "2025-08-28T12:06:59",
            "upload_time_iso_8601": "2025-08-28T12:06:59.852231Z",
            "url": "https://files.pythonhosted.org/packages/32/b5/d3e02f1b8cfa74e7a9c4f3ecda549d542e55672eb9234b1b4246301dc148/raihan0824_prometheus_mcp_server-1.2.12.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-28 12:06:59",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "raihan0824",
    "github_project": "prometheus-mcp-server",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "raihan0824-prometheus-mcp-server"
}
        
Elapsed time: 2.48490s