使用说明
DataDog MCP服务器
证据驱动的MCP服务器,将DataDog暴露为 工具, 资源,以及 提示.使用官方 数据狗API 和 MCP Python SDK.
需求
- Python 3.10+
- DataDog API密钥和应用程序密钥(在此创建)
快速启动
- 克隆或进入此仓库,然后安装:
uv sync - 复制
.env.example到.env并设置DD_API_KEY和DD_APP_KEY(在以下位置创建密钥 DataDog API密钥).永不承诺.env. - 运行服务器:
uv run python -m datadog_mcp.server(stdio)或使用可流式传输的HTTP(见下文)。
配置
通过环境变量设置凭据(do 不 承诺真实价值):
| 变量 | 必填 | 描述 |
|---|---|---|
DD_API_KEY |
是 | DataDog API密钥 |
DD_APP_KEY |
是 | DataDog应用程序密钥 |
DD_SITE |
否 | 站点(默认值: datadoghq.com;使用 datadoghq.eu, ap1.datadoghq.com等等) |
复制 .env.example 到 .env 并在本地填写值;永不承诺 .env.
光标/MCP客户端设置
要将此服务器作为MCP连接到Cursor(或其他stdio客户端)中,请执行以下操作:
- 命令:
uv run python -m datadog_mcp.server(从datadog-mcp目录)。 - 环境: 确保
DD_API_KEY和DD_APP_KEY在客户端运行的环境中设置(例如在Cursor的MCP设置或shell中)。
MCP配置示例片段(路径和环境取决于您的设置):
{
"mcpServers": {
"datadog": {
"command": "uv",
"args": ["run", "python", "-m", "datadog_mcp.server"],
"cwd": "/path/to/datadog-mcp",
"env": { "DD_API_KEY": "<your-api-key>", "DD_APP_KEY": "<your-app-key>" }
}
}
}
运行服务器
默认值:stdio (适用于Cursor、CLI客户端):
cd datadog-mcp
uv run python -m datadog_mcp.server
# or with explicit stdio:
uv run python -m datadog_mcp.server stdio
流式HTTP (为 MCP检查员,基于浏览器的客户端):
uv run python -c "from datadog_mcp.server import run; run(transport='streamable-http')"
然后将MCP检查器连接到显示的URL(例如。 http://localhost:8000/mcp).
工具
| 工具 | 描述 | 范围 |
|---|---|---|
validate_keys_tool |
验证API/应用程序密钥 | - |
list_monitors, get_monitor, create_monitor, update_monitor, delete_monitor, mute_monitor, unmute_monitor |
监视器 | 监视器_读取,监视器_写入 |
list_dashboards, get_dashboard, create_dashboard, update_dashboard, delete_dashboard |
仪表板 | 仪表板_读,仪表板_写 |
query_metrics |
指标查询 | Metrics_read |
list_log_indexes, query_logs |
日志 | Logs_read_config,Logs_read |
list_events |
事件 | 事件_阅读 |
list_hosts, get_host_tags |
主机/标签 | 基础设施_read,标签_read |
list_slos, get_slo |
slo | slo_read |
list_downtimes, get_downtime, create_downtime, update_downtime, cancel_downtime |
停机时间(v1) | 监视器_读取,监视器_写入 |
list_incidents, get_incident, create_incident, update_incident |
事件(v2) | incident_read,incident_write |
list_apm_services |
APM服务 | APM_read |
list_synthetics_tests, get_synthetics_test |
合成物 | 合成物_阅读 |
list_notebooks, get_notebook |
笔记本 | Notebooks_read |
get_usage_summary |
使用计量 | Usage_read |
资源(URI)
datadog://validate-API密钥验证状态datadog://monitors--监视器列表datadog://monitors/{id}--单显示器IDdatadog://dashboards--仪表板列表datadog://dashboards/{id}--按ID显示单个仪表板datadog://downtimes--停机时间列表datadog://downtimes/{id}--按ID列出的单次停机时间datadog://slos--SLO列表datadog://slos/{id}--按ID列出的单个SLOdatadog://incidents--事件列表datadog://incidents/{id}--按ID列出的单一事件
提示
prompt_summarize_monitor_state(monitor_id)--要求LLM总结监视器的状态prompt_draft_incident_status(incident_id)--要求LLM从事件中起草一条状态消息prompt_summarize_slo(slo_id)--要求LLM总结SLO状态和燃烧率prompt_dashboard_insights(dashboard_id)--请LLM总结关键小部件并建议重点领域
完整端点→ 工具映射和范围: docs/api_mapping.md。有关详细的工具参数、范围和示例: docs/tool_reference.md.
发展
uv sync
uv run pytest
DataDog范围和速率限制
- 范围: 看 授权范围每个工具都记录了它需要的范围;给予最低要求。
- 费率限制: 看 速率限制在429上,服务器使用回退重试(参见docs/tool_reference.md);如果仍然存在速率限制,它将返回一个经过净化的错误。
秘密
做 不 日志、回声或提交 DD_API_KEY 或 DD_APP_KEY。仅使用环境变量或安全密钥管理器。
