InfluxDB MCP Server

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 查询和线路协议格式的模板

资源

服务器公开以下资源:

  1. 组织列表influxdb://orgs
    • 显示 InfluxDB 实例中的所有组织
  2. 存储桶列表influxdb://buckets
    • 显示所有存储桶及其元数据
  3. 存储桶测量influxdb://bucket/{bucketName}/measurements
    • 列出指定存储桶内的所有测量值
  4. 查询数据influxdb://query/{orgName}/{fluxQuery}
    • 执行 Flux 查询并将结果作为资源返回

工具

服务器提供以下工具:

  1. write-data :以线路协议格式写入时间序列数据
    • 参数:org、bucket、data、precision(可选)
  2. query-data :执行 Flux 查询
    • 参数:org,query
  3. create-bucket :创建一个新的存储桶
    • 参数:name、orgID、retentionPeriodSeconds(可选)
  4. create-org :创建新组织
    • 参数:名称、描述(可选)

提示

服务器提供以下提示模板:

  1. flux-query-examples :常见的 Flux 查询示例
  2. line-protocol-guide :InfluxDB 线路协议格式指南

配置

服务器需要以下环境变量:

  • INFLUXDB_TOKEN (必需):InfluxDB API 的身份验证令牌
  • INFLUXDB_URL (可选): InfluxDB 实例的 URL (默认为http://localhost:8086 )
  • INFLUXDB_ORG (可选):某些操作的默认组织名称

安装

选项 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 start

与 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 - 存储桶列表
      • measurementsHandler.js - 测量列表
      • queryHandler.js - 查询执行
      • writeDataTool.js - 数据写入工具
      • queryDataTool.js - 查询工具
      • createBucketTool.js - Bucket创建工具
      • createOrgTool.js - 组织创建工具
    • prompts/ - 提示模板
      • fluxQueryExamplesPrompt.js - Flux 查询示例
      • lineProtocolGuidePrompt.js - 线路协议指南

这种结构可以实现更好的可维护性、更容易的测试和更清晰的关注点分离。

测试

该存储库包括全面的集成测试:

  • 使用 InfluxDB 启动 Docker 容器
  • 使用示例数据填充
  • 测试所有 MCP 服务器功能

运行测试:

npm test

执照

麻省理工学院

You must be authenticated.

A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

模型上下文协议服务器,为 Claude 提供对 InfluxDB 时间序列数据库实例的访问,实现通过自然语言进行数据写入、查询以及组织和存储桶的管理。

  1. Features
    1. Resources
      1. Tools
        1. Prompts
          1. Configuration
            1. Installation
              1. Option 1: Run with npx (recommended)
              2. Option 2: Install globally
              3. Option 3: From source
            2. Integration with Claude for Desktop
              1. Using npx (recommended)
              2. If installed locally
            3. Code Structure
              1. Testing
                1. License
                  ID: 9bo1fbiook