一个基于Python的工具,用于与Datadog API交互并从基础设施中获取监控数据。此MCP提供了通过简单接口访问监控状态和Kubernetes日志的功能。
要通过 Smithery 自动安装Datadog到Claude Desktop:
npx -y @smithery/cli install @didlawowo/mcp-collection --client claude
所需包:
datadog-api-client
fastmcp
loguru
icecream
python-dotenv
uv
创建一个包含您的Datadog凭证的.env文件:
DD_API_KEY=your_api_key
DD_APP_KEY=your_app_key
# 假设您在macOS上
brew install claude-desktop
# 或从官方网站下载
https://claude.ai/desktop
# 在mac上是
~/Library/Application\ Support/Claude/claude_desktop_config.json
# 将以下内容添加到您的claude配置json中
```json
"Datadog-MCP-Server": {
"command": "uv",
"args": [
"run",
"--with",
"datadog-api-client",
"--with",
"fastmcp",
"--with",
"icecream",
"--with",
"loguru",
"--with",
"python-dotenv",
"fastmcp",
"run",
"/your-path/mcp-collection/datadog/main.py"
],
"env": {
"DD_API_KEY": "xxxx",
"DD_APP_KEY": "xxx"
}
},


我将添加关于MCP和Claude Desktop设置的部分:
模型上下文协议 (MCP) 是一个框架,允许AI模型以标准化的方式与外部工具和API进行交互。它使像Claude这样的模型能够:
https://github.com/punkpeye/awesome-mcp-servers?tab=readme-ov-file
LLM使用提供的函数来获取数据并使用它
get_monitor_states(
name: str, # 要搜索的监控名称
timeframe: int = 1 # 回溯小时数
)
示例:
response = get_monitor_states(name="traefik")
# 示例输出
{
"id": "12345678",
"name": "traefik",
"status": "OK",
"query": "avg(last_5m):avg:traefik.response_time{*} > 1000",
"message": "响应时间过高",
"type": "指标警报",
"created": "2024-01-14T10:00:00Z",
"modified": "2024-01-14T15:30:00Z"
}
get_k8s_logs(
cluster: str, # Kubernetes集群名称
timeframe: int = 5, # 回溯小时数
namespace: str = None # 可选命名空间过滤器
)
示例:
logs = get_k8s_logs(
cluster="prod-cluster",
timeframe=3,
namespace="default"
)
# 示例输出
{
"timestamp": "2024-01-14T22:00:00Z",
"host": "worker-1",
"service": "nginx-ingress",
"pod_name": "nginx-ingress-controller-abc123",
"namespace": "default",
"container_name": "controller",
"message": "连接被拒绝",
"status": "错误"
}
# 作为MCP扩展安装
cd datadog
task install-mcp
检查Claude中的Datadog连接

.env中# 启动 MCP Inspector 进行调试
task run-mcp-inspector
MCP Inspector 提供:
API认证错误
错误:(403) 禁止访问
➡️ 检查您的.env中的DD_API_KEY和DD_APP_KEY
MCP连接问题
错误:无法连接到MCP服务器
➡️ 验证您的claude_desktop_config.json路径和内容
未找到监控
错误:未找到名为'xxx'的监控
➡️ 检查监控名称的拼写和大小写敏感性
日志可以在这里找到

随时可以: