](https://mseep.ai/app/idoru-influxdb-mcp-server)
InfluxDB v2 MCP服务器
](https://smithery.ai/server/@idoru/influxdb-mcp-server)

模型上下文协议(MCP)服务器,使用InfluxDB OSS API v2公开对InfluxDBv2实例的访问。主要使用Claude Code构建。
特性
此MCP服务器提供:
- 资源:访问组织、存储桶和测量数据
- 工具:写入数据、执行查询和管理数据库对象
- 提示:常见Flux查询和Line Protocol格式的模板
资源
服务器公开以下资源:
- 组织列表:
influxdb://orgs
- 显示InfluxDB实例中的所有组织
- Buckets列表:
influxdb://buckets
- 显示所有存储桶及其元数据
- 铲斗测量:
influxdb://bucket/{bucketName}/measurements
- 列出指定桶内的所有测量值
- 查询数据:
influxdb://query/{orgName}/{fluxQuery}
- 执行Flux查询并将结果作为资源返回
工具
服务器提供以下工具:
write-data:以线路协议格式写入时间序列数据
- 参数:组织、桶、数据、精度(可选)
query-data:执行Flux查询
- 参数:组织、查询
create-bucket:创建新bucket
- 参数:名称、组织ID、保留周期秒(可选)
create-org:创建新组织
- 参数:名称、描述(可选)
提示
服务器提供以下提示模板:
flux-query-examples:常见Flux查询示例line-protocol-guide:InfluxDB线路协议格式指南
配置
服务器需要以下环境变量:
INFLUXDB_TOKEN(必需):InfluxDB API的身份验证令牌INFLUXDB_URL(可选):InfluxDB实例的URL(默认为http://localhost:8086)INFLUXDB_ORG(可选):某些操作的默认组织名称
安装
通过Smithery安装
通过以下方式自动安装克劳德桌面版InfluxDB MCP服务器 史密瑟里:
npx -y @smithery/cli install @idoru/influxdb-mcp-server --client claude选项1:使用npx运行(推荐)
# Run directly with npx
INFLUXDB_TOKEN=your_token npx influxdb-mcp-server选项2:全局安装
# Install globally
npm install -g influxdb-mcp-server
# Run the server
INFLUXDB_TOKEN=your_token influxdb-mcp-server选项3:来源
# 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 startinfluxdb-mcp-server 默认情况下使用stdio传输。您可以通过以下方式明确请求 --stdio,或通过提供流式HTTP传输来启动服务器 --http 带有可选端口号的选项(默认为3000)。此模式使用内部Express.js服务器:
# 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如果您全局安装或使用npx,则可以运行:
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与Claude for Desktop集成
将服务器添加到您的 claude_desktop_config.json:
使用npx(推荐)
{
"mcpServers": {
"influxdb": {
"command": "npx",
"args": ["influxdb-mcp-server"],
"env": {
"INFLUXDB_TOKEN": "your_token",
"INFLUXDB_URL": "http://localhost:8086",
"INFLUXDB_ORG": "your_org"
}
}
}
}如果本地安装
{
"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"
}
}
}
}代码结构
服务器代码被组织成模块化结构:
src/
- index.js -主服务器入口点 - config/ -配置相关文件 - env.js -环境变量处理 - utils/ -实用功能 - influxClient.js -InfluxDB API客户端 - loggerConfig.js -控制台记录器配置 - handlers/ -资源和工具处理程序 - organizationsHandler.js -组织列表 - bucketsHandler.js -Buckets列表 - measurementsHandler.js -测量列表 - queryHandler.js -查询执行 - writeDataTool.js -数据写入工具 - queryDataTool.js -查询工具 - createBucketTool.js -Bucket创建工具 - createOrgTool.js -组织创建工具 - prompts/ -提示模板 - fluxQueryExamplesPrompt.js -通量查询示例 - lineProtocolGuidePrompt.js -线路协议指南
这种结构允许更好的可维护性、更容易的测试和更清晰的关注点分离。
测试
该存储库包括全面的集成测试,这些测试:
- 使用InfluxDB启动Docker容器
- 用示例数据填充它
- 测试所有MCP服务器功能
要运行测试,请执行以下操作:
npm test许可证
麻省理工学院
