mcp server
influxdb-mcp-server
An MCP Server for querying InfluxDB
Set up
Runs on your computer. Pick your agent and operating system.
Before you start
- Node.js 20 or newer
{
"mcpServers": {
"idoru-influxdb-mcp-server": {
"command": "npx",
"args": [
"-y",
"influxdb-mcp-server"
]
}
}
}same format Cursor, GitHub Copilot CLI, Junie, JetBrains AI Assistant, Augment (Auggie CLI), Factory Droid, Kiro, Devin CLI +12
Values in angle brackets are placeholders. Restart Claude Desktop after editing its config.Claude Desktop docs
README
synced Oct 25, 2026InfluxDB v2 MCP Server
A Model Context Protocol (MCP) server that exposes access to an InfluxDB v2 instance using the InfluxDB OSS API v2. Mostly built with Claude Code.
Features
This MCP server provides:
- Resources: Access to organization, bucket, and measurement data
- Tools: Write data, execute queries, and manage database objects
- Prompts: Templates for common Flux queries and Line Protocol format
Resources
The server exposes the following resources:
-
Organizations List:
influxdb://orgs- Displays all organizations in the InfluxDB instance
-
Buckets List:
influxdb://buckets- Shows all buckets with their metadata
-
Bucket Measurements:
influxdb://bucket/{bucketName}/measurements- Lists all measurements within a specified bucket (uses
INFLUXDB_ORG)
- Lists all measurements within a specified bucket (uses
-
Query Data:
influxdb://query/{orgName}/{fluxQuery}- Executes a Flux query and returns results as JSON (
headersand one record per row, across all result tables)
- Executes a Flux query and returns results as JSON (
Template variables (bucketName, orgName, fluxQuery) must be percent-encoded, e.g. with encodeURIComponent, so names containing spaces or / and multi-line queries survive the URI.
Tools
The server provides these tools:
-
write-data: Write time-series data in line protocol format- Parameters: org, bucket, data, precision (optional)
organdbucketare optional whenINFLUXDB_ORG/INFLUXDB_BUCKETare set, and fall back to those values
-
query-data: Execute Flux queries- Parameters: org, query
orgis optional whenINFLUXDB_ORGis set, and falls back to that value
-
create-bucket: Create a new bucket- Parameters: name, orgID, retentionPeriodSeconds (optional, whole seconds; omit or pass 0 for infinite retention)
-
create-org: Create a new organization- Parameters: name, description (optional)
Prompts
The server offers these prompt templates:
flux-query-examples: Common Flux query examplesline-protocol-guide: Guide to InfluxDB line protocol format
Configuration
The server requires these environment variables:
INFLUXDB_TOKEN(required): Authentication token for the InfluxDB APIINFLUXDB_URL(optional): URL of the InfluxDB instance (defaults tohttp://localhost:8086)INFLUXDB_ORG(optional): Default organization name for certain operations. When set,orgbecomes optional on thewrite-dataandquery-datatoolsINFLUXDB_BUCKET(optional): Default bucket name. When set,bucketbecomes optional on thewrite-datatoolDEBUG(optional): Set tomcp:*to log every MCP message to stderr. This includes query text and written data, so leave it off in production
The following variables apply only to the Streamable HTTP transport (see HTTP transport security):
MCP_HTTP_HOST(optional): Interface to listen on (defaults to127.0.0.1; same as--host)MCP_AUTH_TOKEN(optional): When set, every request must sendAuthorization: Bearer <token>. Required to listen on a non-loopback interfaceMCP_ALLOWED_HOSTS(optional): Comma-separated hostnames (ports are ignored) accepted in theHostheader. Defaults tolocalhost,127.0.0.1,[::1]plus the bind address on loopback; unset means noHostcheck on other interfacesMCP_HTTP_ALLOW_UNAUTHENTICATED(optional): Set totrueto listen on a non-loopback interface withoutMCP_AUTH_TOKEN, e.g. behind a reverse proxy that authenticates for youMCP_HTTP_BODY_LIMIT(optional): Maximum request body size (defaults to4mb; acceptsb,kbormbsuffixes). Raise it for very largewrite-databatches
Requests to InfluxDB time out after 10 seconds (60 seconds for queries, 30 seconds for writes), including the time spent reading the response.
Installation
Installing via Smithery
To install InfluxDB MCP Server for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install @idoru/influxdb-mcp-server --client claude
Option 1: Run with npx (recommended)
# Run directly with npx
INFLUXDB_TOKEN=your_token npx influxdb-mcp-server
Option 2: Install globally
# Install globally
npm install -g influxdb-mcp-server
# Run the server
INFLUXDB_TOKEN=your_token influxdb-mcp-server
Option 3: From source
# Clone the repository
git clone https://github.com/idoru/influxdb-mcp-server.git
cd influxdb-mcp-server
# Install dependencies
npm install
# Run the server
INFLUXDB_TOKEN=your_token npm start
Node.js 20 or later is required.
influxdb-mcp-server uses stdio transport by default. You can explicitly request it with --stdio, or start the server with Streamable HTTP transport by providing the --http option with an optional port number (defaults to 3000). This mode uses an internal Express.js server that listens on 127.0.0.1 unless --host is given:
# Start with Streamable HTTP transport on default port 3000
INFLUXDB_TOKEN=your_token npm start -- --http
# Start with Streamable HTTP transport on a specific port
INFLUXDB_TOKEN=your_token npm start -- --http 8080
If you installed globally or are using npx, you can run:
INFLUXDB_TOKEN=your_token influxdb-mcp-server --http
# or explicitly force stdio
INFLUXDB_TOKEN=your_token influxdb-mcp-server --stdio
# or
INFLUXDB_TOKEN=your_token influxdb-mcp-server --http 8080
HTTP transport security
Anyone who can reach the HTTP endpoint can read and write InfluxDB with the server's INFLUXDB_TOKEN, so the HTTP transport is locked down by default:
- It listens on
127.0.0.1only. - On loopback it rejects requests whose
Hostheader is notlocalhost,127.0.0.1or[::1], which blocks DNS rebinding attacks from websites open in your browser. - It refuses to listen on any other interface unless
MCP_AUTH_TOKENis set (orMCP_HTTP_ALLOW_UNAUTHENTICATED=true).
To expose the server on your network, or from a container, require a bearer token:
INFLUXDB_TOKEN=your_token MCP_AUTH_TOKEN="$(openssl rand -hex 32)" \
influxdb-mcp-server --http 3000 --host 0.0.0.0
Clients then send Authorization: Bearer <MCP_AUTH_TOKEN> with each request. Set MCP_ALLOWED_HOSTS to the hostnames clients use to reach the server for additional DNS rebinding protection. Prefer terminating TLS in front of the server when it is reachable beyond your machine.
Docker
The image runs as the unprivileged node user and uses stdio by default:
docker build -t influxdb-mcp-server .
docker run --rm -i -e INFLUXDB_TOKEN=your_token -e INFLUXDB_URL=http://host.docker.internal:8086 influxdb-mcp-server
# Streamable HTTP inside a container must bind 0.0.0.0, so it needs a token
docker run --rm -p 127.0.0.1:3000:3000 -e INFLUXDB_TOKEN=your_token -e MCP_AUTH_TOKEN=your_mcp_token \
influxdb-mcp-server --http 3000 --host 0.0.0.0
Integration with Claude for Desktop
Add the server to your claude_desktop_config.json:
Using npx (recommended)
{
"mcpServers": {
"influxdb": {
"command": "npx",
"args": ["influxdb-mcp-server"],
"env": {
"INFLUXDB_TOKEN": "your_token",
"INFLUXDB_URL": "http://localhost:8086",
"INFLUXDB_ORG": "your_org",
"INFLUXDB_BUCKET": "your_bucket"
}
}
}
}
If installed locally
{
"mcpServers": {
"influxdb": {
"command": "node",
"args": ["/path/to/influxdb-mcp-server/src/index.js"],
"env": {
"INFLUXDB_TOKEN": "your_token",
"INFLUXDB_URL": "http://localhost:8086",
"INFLUXDB_ORG": "your_org",
"INFLUXDB_BUCKET": "your_bucket"
}
}
}
}
Code Structure
The server code is organized into a modular structure:
src/index.js- CLI entry point (argument parsing and transport selection)server.js- MCP server factory registering resources, tools and promptsconfig/- Configuration related filesenv.js- Environment variable handlinghttp.js- HTTP transport options and safety checks
http/- Streamable HTTP transportapp.js- Express app (Host validation, bearer auth, body limits)
utils/- Utility functionsinfluxClient.js- InfluxDB API client with request timeoutscsv.js- Flux CSV response parserflux.js- Flux string escaping and URI parameter decodingloggerConfig.js- Console logger configuration andDEBUGtracingtraceTransport.js- MCP message tracing forDEBUG=mcp:*
handlers/- Resource and tool handlersorganizationsHandler.js- Organizations listingbucketsHandler.js- Buckets listingmeasurementsHandler.js- Measurements listingqueryHandler.js- Query executionwriteDataTool.js- Data write toolqueryDataTool.js- Query toolcreateBucketTool.js- Bucket creation toolcreateOrgTool.js- Organization creation tool
prompts/- Prompt templatesfluxQueryExamplesPrompt.js- Flux query exampleslineProtocolGuidePrompt.js- Line protocol guide
This structure allows for better maintainability, easier testing, and clearer separation of concerns.
Testing
The repository includes comprehensive tests that:
- Spin up a Docker container with InfluxDB
- Populate it with sample data
- Test all MCP server functionality
- Exercise the HTTP transport's Host validation, authentication and limits, and the CSV and Flux helpers, without Docker
To run the tests:
npm test
License
MIT
