Telegraf Controller MCP Server

Telegraf Controller MCP Server

An MCP server that gives AI assistants full control over Telegraf Controller to manage agent fleets, configurations, labels, and health rules using natural language.

Category
访问服务器

README

Telegraf Controller MCP Server

A Model Context Protocol (MCP) server that gives AI assistants full control over Telegraf Controller — manage agent fleets, configurations, labels, and health rules using natural language.

License: MIT Node.js MCP


What This Does

Ask your AI assistant (Claude, Cline, etc.) questions like:

  • "Show me all Telegraf agents that haven't reported in the last hour"
  • "Create a configuration for MQTT IoT sensor collection and deploy it"
  • "Label all production agents and assign them the strict monitoring rule"
  • "Merge our CPU, memory, and disk configs into one stack"
  • "Which agents are not reporting and why?"

The MCP server translates natural language → 27 API calls → structured answers, all without leaving your chat interface.


Architecture

┌──────────────────────────┐
│   Claude / Cline / etc.  │
└────────────┬─────────────┘
             │ MCP (stdio)
             ▼
┌──────────────────────────┐
│   Telegraf Controller    │
│      MCP Server          │
│  27 tools · 4 resources  │
│  6 guided prompts        │
└────────────┬─────────────┘
             │ HTTP/REST
             ▼
┌──────────────────────────┐
│   Telegraf Controller    │
│   (port 8888)            │
│  Agent mgmt · Configs    │
│  Labels · Health rules   │
└──────────────────────────┘
             │ Heartbeat (port 8889)
             ▼
┌──────────────────────────┐
│   Telegraf Agents        │
│  (IoT, infra, etc.)      │
└──────────────────────────┘

Quick Start

Prerequisites

1. Start the Telegraf Controller

docker run -d \
  --name telegraf-controller \
  -p 8888:8888 \
  -p 8889:8889 \
  influxdata/telegraf-controller:latest

# Verify
curl http://localhost:8888/health
# → {"status":"healthy","message":"Telegraf Controller is accessible"}

Or use the included Docker Compose:

docker-compose up -d

2. Configure Your MCP Client

Claude Desktop

Edit ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):

{
  "mcpServers": {
    "telegraf-controller": {
      "command": "npx",
      "args": ["-y", "@influxdata/telegraf-controller-mcp-server"],
      "env": {
        "TELEGRAF_CONTROLLER_URL": "http://localhost:8888"
      }
    }
  }
}

Local install (Node.js)

git clone https://github.com/dburton-influxdata/telegraf-controller-mcp-server.git
cd telegraf-controller-mcp-server
npm install && npm run build

Then in your MCP client config:

{
  "mcpServers": {
    "telegraf-controller": {
      "command": "node",
      "args": ["/absolute/path/to/telegraf-controller-mcp-server/build/index.js"],
      "env": {
        "TELEGRAF_CONTROLLER_URL": "http://localhost:8888"
      }
    }
  }
}

Docker

docker run -i --rm --network=host \
  -e TELEGRAF_CONTROLLER_URL=http://localhost:8888 \
  ghcr.io/dburton-influxdata/telegraf-controller-mcp-server:latest

3. Restart Your MCP Client & Test

After restarting Claude Desktop / Cline, ask:

"Check the health of my Telegraf Controller"

You should see the MCP server respond with agent counts, health status, and configuration counts.


Available Tools (27)

Configuration Management (9 tools)

Tool Description Modifies State
telegraf-controller_list_configs List all configurations with metadata ❌ Read-only
telegraf-controller_get_config Get full TOML content of a config ❌ Read-only
telegraf-controller_get_config_details Get config metadata (no TOML) ❌ Read-only
telegraf-controller_create_config Create a new Telegraf configuration ✅ Creates
telegraf-controller_update_config Update name, TOML, or description ✅ Modifies
telegraf-controller_delete_config Delete a configuration ✅ Deletes
telegraf-controller_duplicate_config Clone a configuration ✅ Creates
telegraf-controller_bulk_duplicate_configs Clone multiple configs at once ✅ Creates
telegraf-controller_merge_configs Combine multiple configs into one ✅ Creates

Agent Management (6 tools)

Tool Description Modifies State
telegraf-controller_list_agents List all agents (filterable by status) ❌ Read-only
telegraf-controller_get_agent_details Get full details for one agent ❌ Read-only
telegraf-controller_get_agent_summary Fleet-wide health statistics ❌ Read-only
telegraf-controller_delete_agent Remove an agent from the controller ✅ Deletes
telegraf-controller_bulk_delete_agents Remove multiple agents at once ✅ Deletes
telegraf-controller_assign_agent_reporting_rule Override health threshold for agent ✅ Modifies

Label Management (8 tools)

Tool Description Modifies State
telegraf-controller_list_labels List all labels ❌ Read-only
telegraf-controller_get_label Get label details ❌ Read-only
telegraf-controller_create_label Create a new label ✅ Creates
telegraf-controller_update_label Update label description ✅ Modifies
telegraf-controller_delete_label Delete a label ✅ Deletes
telegraf-controller_bulk_delete_labels Delete multiple labels ✅ Deletes
telegraf-controller_assign_label_to_agent Tag one agent with a label ✅ Modifies
telegraf-controller_bulk_assign_labels_to_agents Tag multiple agents with labels ✅ Modifies

Reporting Rules (5 tools)

Tool Description Modifies State
telegraf-controller_list_reporting_rules List all health threshold rules ❌ Read-only
telegraf-controller_get_reporting_rule Get one rule's details ❌ Read-only
telegraf-controller_create_reporting_rule Define new health threshold ✅ Creates
telegraf-controller_update_reporting_rule Update thresholds ✅ Modifies
telegraf-controller_delete_reporting_rule Remove a rule ✅ Deletes

System Tools (3 tools)

Tool Description
telegraf-controller_health_check Verify controller is reachable
telegraf-controller_get_heartbeat_info Get heartbeat endpoint URL
telegraf-controller_get_analytics_instance Get analytics instance ID

MCP Resources

Read-only data URIs available to your AI client:

URI Description
telegraf://status Real-time controller status + agent summary
telegraf://configs All configurations (names, IDs, descriptions)
telegraf://agents All agents with current health status
telegraf://reporting-rules All health threshold rules

MCP Prompts (Guided Workflows)

Pre-built workflows that chain multiple tools together:

Prompt Description
check-agent-health Full fleet health report
troubleshoot-not-reporting Diagnose silent agents step-by-step
create-config-from-template Guided TOML config creation
deploy-config-to-agents Walk through deploying configs
optimize-reporting-rules Analyze and improve health thresholds
agent-fleet-overview Complete fleet summary

Usage Examples

Natural Language

"List all agents that haven't reported in the last 30 minutes"
→ Uses: list_agents(status_filter="not_reporting")

"Create an IoT sensor config for MQTT topics IOT/+/temperature and IOT/+/humidity"
→ Uses: create_config(name=..., toml=...)

"Assign the production label and strict monitoring rule to all US-East agents"
→ Uses: list_agents + list_labels + bulk_assign_labels_to_agents + assign_agent_reporting_rule

"Merge the CPU, memory, and disk configs into one monitoring stack"
→ Uses: list_configs + merge_configs(...)

Slash Commands (Cline / OpenCode)

# Health check
/mcp telegraf-controller_health_check

# List all agents
/mcp telegraf-controller_list_agents limit=100 page=1

# Get unhealthy agents only
/mcp telegraf-controller_list_agents status_filter=not_reporting

# Create a label
/mcp telegraf-controller_create_label description="env:production"

# Create a config
/mcp telegraf-controller_create_config \
  name="iot-sensors" \
  description="MQTT IoT data collector" \
  toml="[agent]\n  interval = \"10s\"\n\n[[inputs.mqtt_consumer]]\n..."

# Create a strict reporting rule
/mcp telegraf-controller_create_reporting_rule \
  name="production-strict" \
  threshold_seconds=300 \
  has_auto_delete=false

Complete Fleet Setup (step-by-step)

1. Check health:
   telegraf-controller_health_check

2. See current state:
   telegraf-controller_get_agent_summary

3. Create environment labels:
   telegraf-controller_create_label description="env:production"
   telegraf-controller_create_label description="location:us-east"
   telegraf-controller_create_label description="type:iot-sensor"

4. Create IoT config:
   telegraf-controller_create_config name="iot-us-east" toml="..."

5. Create strict monitoring rule:
   telegraf-controller_create_reporting_rule name="prod-strict" threshold_seconds=300

6. Assign labels to agents:
   telegraf-controller_bulk_assign_labels_to_agents agent_ids="..." label_ids="..."

7. Assign reporting rule:
   telegraf-controller_assign_agent_reporting_rule agent_id="..." rule_id="..."

Configuration

Environment Variables

Variable Required Default Description
TELEGRAF_CONTROLLER_URL Yes http://localhost:8888 Base URL of Telegraf Controller API

MCP Client Config Examples

See the examples/ directory:


Grafana Dashboards

Four pre-built Grafana dashboards are included in grafana/dashboards/:

Dashboard File Description
IoT Sensor Monitoring iot-sensors.json Real-time MQTT sensor data (temp, humidity, pressure, CO2)
Infrastructure Monitoring infrastructure.json CPU, memory, disk, network, Docker metrics
Controller Events controller-events.json Config changes, agent lifecycle, label assignments
MCP Server Monitoring telegraf-mcp-monitoring.json Agent health, config counts, MCP tool activity

Import Dashboards

# Install Grafana (if not running)
docker run -d -p 3001:3000 --name grafana grafana/grafana:latest

# Import via Grafana UI
# 1. http://localhost:3001 → Dashboards → Import
# 2. Upload JSON files from grafana/dashboards/

# Or import via API
for f in grafana/dashboards/*.json; do
  curl -s -X POST http://admin:admin@localhost:3001/api/dashboards/import \
    -H "Content-Type: application/json" \
    -d "{\"dashboard\": $(cat $f), \"overwrite\": true, \"folderId\": 0}"
  echo " → Imported: $f"
done

See docs/GRAFANA_DASHBOARDS.md for full panel descriptions and queries.


Documentation

Document Description
docs/MCP_TOOLS.md Complete reference for all 27 tools with parameters and examples
docs/INSTALLATION.md Step-by-step setup for Claude Desktop, Cline, OpenCode
docs/GRAFANA_DASHBOARDS.md All 4 dashboards: panels, queries, import instructions

Project Structure

telegraf-controller-mcp-server/
├── src/
│   ├── index.ts              # MCP server entry point
│   ├── tools/
│   │   ├── configs.ts        # Configuration management tools
│   │   ├── agents.ts         # Agent management tools
│   │   └── reporting.ts      # Reporting rules tools
│   ├── resources/
│   │   └── index.ts          # 4 MCP resources
│   ├── prompts/
│   │   └── index.ts          # 6 guided prompts
│   └── utils/
│       ├── client.ts         # Telegraf Controller API client
│       └── validation.ts     # Input validation helpers
├── examples/
│   ├── claude-desktop-local.json
│   ├── claude-desktop-npx.json
│   └── claude-desktop-docker.json
├── grafana/
│   └── dashboards/
│       ├── iot-sensors.json
│       ├── infrastructure.json
│       ├── controller-events.json
│       └── telegraf-mcp-monitoring.json
├── docs/
│   ├── MCP_TOOLS.md          # All 27 tools reference
│   ├── INSTALLATION.md       # Setup guide
│   └── GRAFANA_DASHBOARDS.md # Dashboard reference
├── context/                  # Telegraf documentation context files
├── Dockerfile
├── docker-compose.yml
├── package.json
└── tsconfig.json

Development

Build from Source

git clone https://github.com/dburton-influxdata/telegraf-controller-mcp-server.git
cd telegraf-controller-mcp-server
npm install
npm run build

Test with MCP Inspector

npm run inspector
# Opens browser-based MCP inspector at http://localhost:5173

Test Manually

# Initialize the MCP server
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}' \
  | TELEGRAF_CONTROLLER_URL=http://localhost:8888 node build/index.js

# List all tools
echo '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}' \
  | TELEGRAF_CONTROLLER_URL=http://localhost:8888 node build/index.js

Docker Build

docker build -t telegraf-controller-mcp-server:dev .

# Test Docker image
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}' \
  | docker run -i --rm --network=host \
      -e TELEGRAF_CONTROLLER_URL=http://localhost:8888 \
      telegraf-controller-mcp-server:dev

Troubleshooting

"Cannot connect to Telegraf Controller"

# Check controller is running
curl http://localhost:8888/health

# Check from Docker (if MCP runs in Docker)
curl http://host.docker.internal:8888/health

"No agents found"

Agents must send heartbeats to the Controller. Add to any Telegraf config:

[[outputs.http]]
  url = "http://localhost:8889/agents/heartbeat"
  method = "POST"
  data_format = "json"
  [outputs.http.headers]
    Content-Type = "application/json"

Verify heartbeats are arriving:

docker logs telegraf-controller 2>&1 | grep heartbeat

MCP server not showing in Claude Desktop

  1. Verify the path to build/index.js is absolute (not relative)
  2. Check JSON config syntax (no trailing commas)
  3. Check Claude Desktop logs:
    • macOS: ~/Library/Logs/Claude/mcp*.log
    • Windows: %APPDATA%\Claude\logs\
  4. Restart Claude Desktop completely

Related Resources


License

MIT — see LICENSE


Built by the InfluxData community · Report an issue

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选