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.
Before installation, ensure you have:
git clone https://github.com/m4tyn0/influx_mcp
cd influxdb-mcp-server
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
Build and launch the Docker container:
docker build -t influxdb-mcp-server .
docker run -d --env-file .env -p 8000:8000 influxdb-mcp-server
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.
After setting up the server, interact with it using these MCP commands:
Authenticate first:
Tool: auth
Arguments: {"token": "your.jwt.token.here"}
List available databases:
Tool: list_databases
Arguments: {}
View measurements in a database:
Tool: list_measurements
Arguments: {"database": "your_database_name"}
Query your time-series data:
Tool: query
Arguments: {
"database": "your_database_name",
"query": "SELECT * FROM measurement_name LIMIT 10"
}
If you can't connect to InfluxDB:
INFLUXDB_HOST
is correct and reachable from the Docker containerIf authentication fails:
JWT_SECRET
is consistent between environment settings and token generationTo check server logs for error messages:
docker logs <container_id>
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.
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"
]
}
}
}
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.
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.