Integrations
Provides templates and execution capabilities for Flux queries, which is the query language for InfluxDB, allowing for data querying and transformation operations.
Exposes access to an InfluxDB instance using the InfluxDB OSS API v2, allowing for organization and bucket management, measurement data access, writing time-series data, and executing Flux queries against the database.
InfluxDB MCP 服务器
一个模型上下文协议 (MCP) 服务器,使用 InfluxDB OSS API v2 公开对 InfluxDB 实例的访问。主要使用 Claude 代码构建。
特征
该 MCP 服务器提供:
- 资源:访问组织、存储桶和测量数据
- 工具:写入数据、执行查询和管理数据库对象
- 提示:常见 Flux 查询和线路协议格式的模板
资源
服务器公开以下资源:
- 组织列表:
influxdb://orgs
- 显示 InfluxDB 实例中的所有组织
- 存储桶列表:
influxdb://buckets
- 显示所有存储桶及其元数据
- 存储桶测量:
influxdb://bucket/{bucketName}/measurements
- 列出指定存储桶内的所有测量值
- 查询数据:
influxdb://query/{orgName}/{fluxQuery}
- 执行 Flux 查询并将结果作为资源返回
工具
服务器提供以下工具:
write-data
:以线路协议格式写入时间序列数据- 参数:org、bucket、data、precision(可选)
query-data
:执行 Flux 查询- 参数:org,query
create-bucket
:创建一个新的存储桶- 参数:name、orgID、retentionPeriodSeconds(可选)
create-org
:创建新组织- 参数:名称、描述(可选)
提示
服务器提供以下提示模板:
flux-query-examples
:常见的 Flux 查询示例line-protocol-guide
:InfluxDB 线路协议格式指南
配置
服务器需要以下环境变量:
INFLUXDB_TOKEN
(必需):InfluxDB API 的身份验证令牌INFLUXDB_URL
(可选): InfluxDB 实例的 URL (默认为http://localhost:8086
)INFLUXDB_ORG
(可选):某些操作的默认组织名称
安装
选项 1:使用 npx 运行(推荐)
Copy
选项 2:全局安装
Copy
选项 3:从源头
Copy
与 Claude for Desktop 集成
将服务器添加到您的claude_desktop_config.json
:
使用 npx(推荐)
Copy
如果本地安装
Copy
代码结构
服务器代码被组织成模块化结构:
src/
index.js
- 主服务器入口点config/
——配置相关文件env.js
- 环境变量处理
utils/
——实用函数influxClient.js
- InfluxDB API 客户端loggerConfig.js
- 控制台记录器配置
handlers/
- 资源和工具处理程序organizationsHandler.js
- 组织列表bucketsHandler.js
- 存储桶列表measurementsHandler.js
- 测量列表queryHandler.js
- 查询执行writeDataTool.js
- 数据写入工具queryDataTool.js
- 查询工具createBucketTool.js
- Bucket创建工具createOrgTool.js
- 组织创建工具
prompts/
- 提示模板fluxQueryExamplesPrompt.js
- Flux 查询示例lineProtocolGuidePrompt.js
- 线路协议指南
这种结构可以实现更好的可维护性、更容易的测试和更清晰的关注点分离。
测试
该存储库包括全面的集成测试:
- 使用 InfluxDB 启动 Docker 容器
- 使用示例数据填充
- 测试所有 MCP 服务器功能
运行测试:
Copy
执照
麻省理工学院
You must be authenticated.
模型上下文协议服务器,为 Claude 提供对 InfluxDB 时间序列数据库实例的访问,实现通过自然语言进行数据写入、查询以及组织和存储桶的管理。
- Features
- Resources
- Tools
- Prompts
- Configuration
- Installation
- Integration with Claude for Desktop
- Code Structure
- Testing
- License