Run queries against InfluxDB OSS API v2.
This document details the implementation of an InfluxDB MCP server, enabling seamless integration between Large Language Models (LLMs) and time-series data stored within InfluxDB. By leveraging the InfluxDB OSS API v2, this server provides a standardized interface for LLMs to access, query, and manipulate data, fostering a new era of AI-driven time-series analysis and automation.
This MCP server unlocks the following key functionalities:
The server exposes the following resources via the influxdb://
protocol:
Organizations Listing: influxdb://orgs
- Retrieves a list of all organizations within the InfluxDB instance. This allows LLMs to understand the organizational structure of the data.
Buckets Listing: influxdb://buckets
- Returns a list of all buckets, including their associated metadata. This provides LLMs with information about available data storage locations.
Bucket Measurements: influxdb://bucket/{bucketName}/measurements
- Lists all measurements within a specified bucket. This allows LLMs to discover the available data series within a given bucket.
Query Execution: influxdb://query/{orgName}/{fluxQuery}
- Executes a provided Flux query against the InfluxDB instance and returns the results as a resource. This enables LLMs to perform complex data analysis and retrieval.
The server provides the following tools for interacting with InfluxDB:
write-data
: Writes time-series data to InfluxDB in line protocol format.
org
(organization name), bucket
(bucket name), data
(line protocol data), precision
(optional: data precision).query-data
: Executes arbitrary Flux queries against InfluxDB.
org
(organization name), query
(Flux query string).create-bucket
: Creates a new bucket within InfluxDB.
name
(bucket name), orgID
(organization ID), retentionPeriodSeconds
(optional: retention period in seconds).create-org
: Creates a new organization within InfluxDB.
name
(organization name), description
(optional: organization description).The server includes prompt templates to guide LLM interaction:
flux-query-examples
: Provides examples of common Flux queries for various time-series analysis tasks. This helps LLMs understand the syntax and capabilities of Flux.
line-protocol-guide
: Offers a comprehensive guide to the InfluxDB line protocol format. This enables LLMs to correctly format data for ingestion into InfluxDB.
The server requires the following environment variables:
INFLUXDB_TOKEN
(required): Authentication token for the InfluxDB API. Security Note: Store this token securely and avoid hardcoding it directly in your code.INFLUXDB_URL
(optional): URL of the InfluxDB instance (defaults to http://localhost:8086
).INFLUXDB_ORG
(optional): Default organization name for certain operations.Installation Options:
npx
(Recommended): Run the server directly without installation.
INFLUXDB_TOKEN=your_token npx influxdb-mcp-server
Global Installation: Install the server globally using npm
.
npm install -g influxdb-mcp-server INFLUXDB_TOKEN=your_token influxdb-mcp-server
From Source: Clone the repository and run the server locally.
git clone https://github.com/idoru/influxdb-mcp-server.git cd influxdb-mcp-server npm install INFLUXDB_TOKEN=your_token npm start
Integration with Claude for Desktop:
Configure the server within your claude_desktop_config.json
file.
Using npx
:
{ "mcpServers": { "influxdb": { "command": "npx", "args": ["influxdb-mcp-server"], "env": { "INFLUXDB_TOKEN": "your_token", "INFLUXDB_URL": "http://localhost:8086", "INFLUXDB_ORG": "your_org" } } } }
Local Installation:
{ "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" } } } }
The server employs a modular architecture for enhanced maintainability and scalability:
src/
: Root directory containing the server's source code.
index.js
: Main entry point for the server application.config/
: Configuration-related files.
env.js
: Handles environment variable loading and validation.utils/
: Utility functions and modules.
influxClient.js
: Provides a wrapper around the InfluxDB API client. This module should handle authentication and error handling.loggerConfig.js
: Configures the console logger for consistent logging across the application.handlers/
: Contains handlers for resource endpoints and tools.
organizationsHandler.js
: Handles requests for listing organizations.bucketsHandler.js
: Handles requests for listing buckets.measurementsHandler.js
: Handles requests for listing measurements within a bucket.queryHandler.js
: Handles the execution of Flux queries.writeDataTool.js
: Implements the write-data
tool.queryDataTool.js
: Implements the query-data
tool.createBucketTool.js
: Implements the create-bucket
tool.createOrgTool.js
: Implements the create-org
tool.prompts/
: Stores prompt templates.
fluxQueryExamplesPrompt.js
: Contains examples of Flux queries.lineProtocolGuidePrompt.js
: Provides a guide to the InfluxDB line protocol.The repository includes integration tests to ensure the server's functionality:
Running Tests:
npm test
These tests are crucial for verifying the correctness and stability of the server. Consider adding unit tests for individual modules to improve test coverage and isolate potential issues.
This InfluxDB MCP server provides a powerful bridge between LLMs and time-series data, enabling a wide range of AI-driven applications. By providing a standardized interface for data access, manipulation, and management, this server empowers developers to build intelligent systems that can analyze, predict, and automate tasks based on time-series data stored in InfluxDB. Future enhancements could include support for more advanced InfluxDB features, such as tasks and alerts, further expanding the capabilities of LLMs in the time-series domain.
๐ โ๏ธ Biomedical research server providing access to PubMed, ClinicalTrials.gov, and MyVariant.info.
๐ MCP server that provides SQL analysis, linting, and dialect conversion using [SQLGlot](https://github.com/tobymao/sqlglot)
๐ ๐ All-in-one MCP server for Postgres development and operations, with tools for performance analysis, tuning, and health checks
Supabase MCP Server with support for SQL query execution and database exploration tools