InfluxDB MCP server

Provides secure, read-only access to InfluxDB 1.8 time-series databases with JWT authentication, enabling database listing, measurement exploration, and query execution while enforcing security restrictions.
Back to servers
Provider
m4tyn0
Release date
Mar 14, 2025
Language
Python
Stats
1 star

The InfluxDB MCP Server provides secure, read-only access to InfluxDB 1.8 through a standardized Model Context Protocol (MCP) interface with JWT authentication, allowing AI assistants to safely query your time-series data.

Prerequisites

Before installation, ensure you have:

  • Docker
  • A running InfluxDB 1.8 instance
  • Valid credentials for your InfluxDB instance

Installation

Step 1: Clone the Repository

git clone https://github.com/m4tyn0/influx_mcp
cd influxdb-mcp-server

Step 2: Configure Environment

Create a .env file with your configuration settings:

cp env.example .env

Then edit the .env file with your specific details:

INFLUXDB_HOST=
INFLUXDB_PORT=8086
INFLUXDB_USERNAME=
INFLUXDB_PASSWORD=
INFLUXDB_SSL=false
INFLUXDB_VERIFY_SSL=true
INFLUXDB_TIMEOUT=10
JWT_SECRET=
JWT_ALGORITHM=HS256

Step 3: Build and Run with Docker

Build and launch the Docker container:

docker build -t influxdb-mcp-server .
docker run -d --env-file .env -p 8000:8000 influxdb-mcp-server

Authentication Setup

The server requires JWT tokens for authentication. Use this Python script to generate a token:

import jwt
import datetime

# Create a token
payload = {
    "sub": "username",  # Replace with your preferred username
    "iat": datetime.datetime.utcnow(),
    "exp": datetime.datetime.utcnow() + datetime.timedelta(hours=1)
}
token = jwt.encode(payload, "your-jwt-secret", algorithm="HS256")
print(token)

Replace "your-jwt-secret" with the same secret you defined in your .env file.

Usage Instructions

Basic MCP Commands

After setting up the server, interact with it using these MCP commands:

  1. Authenticate first:

    Tool: auth
    Arguments: {"token": "your.jwt.token.here"}
    
  2. List available databases:

    Tool: list_databases
    Arguments: {}
    
  3. View measurements in a database:

    Tool: list_measurements
    Arguments: {"database": "your_database_name"}
    
  4. Query your time-series data:

    Tool: query
    Arguments: {
      "database": "your_database_name",
      "query": "SELECT * FROM measurement_name LIMIT 10"
    }
    

Troubleshooting

Connection Issues

If you can't connect to InfluxDB:

  • Verify your INFLUXDB_HOST is correct and reachable from the Docker container
  • Confirm your InfluxDB credentials are valid
  • Check that InfluxDB is configured to accept external connections

Authentication Problems

If authentication fails:

  • Ensure your JWT_SECRET is consistent between environment settings and token generation
  • Check if your token has expired
  • Verify your InfluxDB user has read permissions on the databases

Viewing Logs

To check server logs for error messages:

docker logs <container_id>

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