OpenTelemetry MCP 服务器使大语言模型(LLM)能够高效地使用 OpenTelemetry 堆栈。
MCP 使用 collectorschema 模块 对收集器配置进行验证。
https://github.com/user-attachments/assets/af56cda4-9ab0-4c93-969e-a2ee7b9f0480
go install github.com/pavolloffay/opentelemetry-mcp-server@latest
opentelemetry-mcp-server --protocol http --addr 0.0.0.0:8080
# 或者使用 Docker 运行
docker run --rm -it -p 8080:8080 ghcr.io/pavolloffay/opentelemetry-mcp-server:latest --protocol http --addr 0.0.0.0:8080
claude mcp add --transport=http otel http://localhost:8080/mcp --scope user
目前,MCP 服务器提供了配置 OpenTelemetry 收集器的工具。这些工具为每个收集器组件返回严格的 JSON 架构,确保配置正确。
完整的工具列表可以在 tools 中找到。
docker run --rm -it -v $(pwd)/collector.yaml:/tmp/collector.yaml:Z pavolloffay/otelcol-with-mcp:0.1 --config
claude mcp add --transport=http otelcol http://localhost:9999/mcp --scope user
此 MCP 服务器作为收集器扩展和连接器实现,提供实时数据视图。
有一个工具可以获取收集器配置,每个构建到收集器中的组件的架构,并执行验证。
返回的架构不完整,且不包含字段解释和类型。
● OTLP 接收器架构
组件类型:otlpKind: 接收器配置类型:*otlpreceiver.Config
架构结构
{
"protocols": {
"grpc": null,
"http": null
}
}
当前配置(含默认值)
{
"protocols": {
"grpc": {
"endpoint": "0.0.0.0:4317",
"keepalive": {
"enforcement_policy": {},
"server_parameters": {}
},
"read_buffer_size": 524288,
"transport": "tcp"
},
"http": {
"cors": null,
"endpoint": "0.0.0.0:4318",
"idle_timeout": 0,
"keep_alives_enabled": true,
"logs_url_path": "/v1/logs",
"metrics_url_path": "/v1/metrics",
"read_header_timeout": 0,
"tls": null,
"traces_url_path": "/v1/traces",
"write_timeout": 0
}
}
}