InfluxDB MCP 服务器是一个基于 Model Context Protocol (MCP) 的服务器,借助 InfluxDB OSS API v2 提供对 InfluxDB 实例的访问。该项目主要使用 Claude Code 构建。
要配置 InfluxDB MCP 服务器,需添加以下环境变量:
INFLUXDB_URL=http://localhost:8086
INFLUXDB_TOKEN=your-influxdb-token
npx influx-mcp-server@latest --install
npm install -g influx-mcp-server
git clone https://github.com/your-repository.git
cd your-repository
npm install
npm start
此 MCP 服务器提供以下功能:
该服务器暴露以下资源:
influxdb://orgs
influxdb://buckets
influxdb://bucket/{bucketName}/measurements
influxdb://query/{orgName}/{fluxQuery}
服务器提供以下工具:
write-data:按行协议格式写入时序数据
query-data:执行 Flux 查询
create-bucket:创建新存储桶
create-org:创建新组织
src/
├── main.ts # 主程序入口
├── config.ts # 配置文件
└── modules/
├── influxdb/ # InfluxDB 相关模块
│ └── connection.ts # 连接管理
├── prompts/ # 提示模板
│ ├── flux-query-examples.prompt.ts # Flux 查询示例提示
│ └── line-protocol-guide.prompt.ts # Line Protocol 指南
└── utils/ # 工具函数
└── logger.ts # 日志记录工具
仓库包含全面的集成测试,测试步骤如下:
运行测试命令:
npm test
本项目采用 MIT 许可证。