Skip to main content
Glama

Datadog MCP 服务器

用于与 Datadog API 交互的模型上下文协议 (MCP) 服务器。

特征

  • 监控:访问监控数据和配置

  • 仪表板:检索和查看仪表板定义

  • 指标:查询可用指标及其元数据

  • 事件:在时间范围内搜索和检索事件

  • 日志:使用高级过滤和排序选项搜索日志

  • 事件:访问事件管理数据

  • API 集成:与 Datadog 的 v1 和 v2 API 直接集成

  • 全面的错误处理:清晰的 API 和身份验证问题错误消息

  • 服务特定端点:支持日志和指标的不同端点

Related MCP server: ClickHouse Trace-Activity MCP Server

先决条件

  1. Node.js(版本 16 或更高版本)

  2. Datadog 帐户:

    • API 密钥 - 在“组织设置”>“API 密钥”中找到

    • 应用程序密钥 - 在“组织设置”>“应用程序密钥”中找到

安装

通过 npm(推荐)

npm install -g datadog-mcp-server

来自源

  1. 克隆此存储库

  2. 安装依赖项:

    npm install
  3. 构建项目:

    npm run build

配置

您可以使用环境变量或命令行参数配置 Datadog MCP 服务器。

环境变量

使用您的 Datadog 凭证创建一个.env文件:

DD_API_KEY=your_api_key_here
DD_APP_KEY=your_app_key_here
DD_SITE=datadoghq.com
DD_LOGS_SITE=datadoghq.com
DD_METRICS_SITE=datadoghq.com

注意: DD_LOGS_SITE和DD_METRICS_SITE是可选的,如果未指定,则默认为DD_SITE的值。

命令行参数

全局站点设置的基本用法:

datadog-mcp-server --apiKey=your_api_key --appKey=your_app_key --site=datadoghq.eu

服务特定端点的高级用法:

datadog-mcp-server --apiKey=your_api_key --appKey=your_app_key --site=datadoghq.com --logsSite=logs.datadoghq.com --metricsSite=metrics.datadoghq.com

注意:站点参数不需要https:// - 它会自动添加。

区域端点

不同的 Datadog 区域有不同的端点:

  • 美国(默认): datadoghq.com

  • 欧盟: datadoghq.eu

  • US3(政府云): ddog-gov.com

  • US5: us5.datadoghq.com

  • AP1: ap1.datadoghq.com

与 Claude Desktop 一起使用

将其添加到您的claude_desktop_config.json中:

{
  "mcpServers": {
    "datadog": {
      "command": "npx",
      "args": [
        "datadog-mcp-server",
        "--apiKey",
        "<YOUR_API_KEY>",
        "--appKey",
        "<YOUR_APP_KEY>",
        "--site",
        "<YOUR_DD_SITE>(e.g us5.datadoghq.com)"
      ]
    }
  }
}

对于具有用于日志和指标的单独端点的更高级配置:

{
  "mcpServers": {
    "datadog": {
      "command": "npx",
      "args": [
        "datadog-mcp-server",
        "--apiKey",
        "<YOUR_API_KEY>",
        "--appKey",
        "<YOUR_APP_KEY>",
        "--site",
        "<YOUR_DD_SITE>",
        "--logsSite",
        "<YOUR_LOGS_SITE>",
        "--metricsSite",
        "<YOUR_METRICS_SITE>"
      ]
    }
  }
}

Claude 桌面配置文件的位置:

  • MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json

  • Windows: %APPDATA%/Claude/claude_desktop_config.json

与 MCP Inspector 一起使用

要与 MCP Inspector 工具一起使用:

npx @modelcontextprotocol/inspector datadog-mcp-server --apiKey=your_api_key --appKey=your_app_key

可用工具

该服务器提供以下 MCP 工具:

  • get-monitors :获取带有可选过滤的监视器

  • get-monitor :通过 ID 获取特定监视器的详细信息

  • get-dashboards :列出所有仪表板

  • get-dashboard :通过 ID 获取特定仪表板

  • get-metrics :列出可用指标

  • get-metric-metadata :获取特定指标的元数据

  • get-events :获取时间范围内的事件

  • get-incidents :列出带有可选过滤的事件

  • search-logs :使用高级查询过滤搜索日志

  • 聚合日志:对日志数据进行分析和聚合

示例

示例:获取监视器

{
  "method": "tools/call",
  "params": {
    "name": "get-monitors",
    "arguments": {
      "groupStates": ["alert", "warn"],
      "limit": 5
    }
  }
}

示例:获取仪表板

{
  "method": "tools/call",
  "params": {
    "name": "get-dashboard",
    "arguments": {
      "dashboardId": "abc-def-123"
    }
  }
}

示例:搜索日志

{
  "method": "tools/call",
  "params": {
    "name": "search-logs",
    "arguments": {
      "filter": {
        "query": "service:web-app status:error",
        "from": "now-15m",
        "to": "now"
      },
      "sort": "-timestamp",
      "limit": 20
    }
  }
}

示例:聚合日志

{
  "method": "tools/call",
  "params": {
    "name": "aggregate-logs",
    "arguments": {
      "filter": {
        "query": "service:web-app",
        "from": "now-1h",
        "to": "now"
      },
      "compute": [
        {
          "aggregation": "count"
        }
      ],
      "groupBy": [
        {
          "facet": "status",
          "limit": 10,
          "sort": {
            "aggregation": "count",
            "order": "desc"
          }
        }
      ]
    }
  }
}

示例:获取事件

{
  "method": "tools/call",
  "params": {
    "name": "get-incidents",
    "arguments": {
      "includeArchived": false,
      "query": "state:active",
      "pageSize": 10
    }
  }
}

故障排除

如果遇到 403 Forbidden 错误,请验证:

  1. 您的 API 密钥和应用程序密钥正确

  2. 这些密钥具有访问所请求资源的必要权限

  3. 您的帐户有权访问所请求的数据

  4. 您正在使用适合您所在地区的正确端点(例如,欧盟客户使用datadoghq.eu )

调试

如果遇到问题,请检查 Claude Desktop 的 MCP 日志:

# On macOS
tail -n 20 -f ~/Library/Logs/Claude/mcp*.log

# On Windows
Get-Content -Path "$env:APPDATA\Claude\Logs\mcp*.log" -Tail 20 -Wait

常见问题:

  • 403 禁止:Datadog API 密钥的身份验证问题

  • API 密钥或应用密钥格式无效:请确保您使用的是完整的密钥字符串

  • 站点配置错误:确保您使用的是正确的 Datadog 域

  • 端点不匹配:如果您对日志和指标使用单独的域,请验证特定于服务的端点是否正确设置

执照

麻省理工学院

Available Tools

10 tools
aggregate-logsB

Perform analytical queries and aggregations on log data. Essential for calculating metrics (count, avg, sum, etc.), grouping data by fields, and creating statistical summaries from logs. Use this when you need to analyze patterns or extract metrics from log data.

Inputs: filter, compute, groupBy, options.

get-dashboardA

Get the complete definition of a specific Datadog dashboard by its ID. Returns all widgets, layout, and configuration details.

Inputs: dashboardId (required).

get-dashboardsC

Retrieve a list of all dashboards from Datadog. Useful for discovering available dashboards and their IDs for further exploration.

Inputs: filterConfigured, limit.

get-eventsC

Search for events in Datadog within a specified time range. Events include deployments, alerts, comments, and other activities. Useful for correlating system behaviors with specific events.

Inputs: start (required), end (required), priority, sources, +4 more.

get-incidentsC

List incidents from Datadog's incident management system. Can filter by active/archived status and use query strings to find specific incidents. Helpful for reviewing current or past incidents.

Inputs: includeArchived, pageSize, pageOffset, query, +1 more.

get-metric-metadataB

Retrieve detailed metadata about a specific metric, including its type, description, unit, and other attributes. Use this to understand a metric's meaning and proper usage.

Inputs: metricName (required).

get-metricsB

List available metrics from Datadog. Optionally use the q parameter to search for specific metrics matching a pattern. Helpful for discovering metrics to use in monitors or dashboards.

Inputs: q.

get-monitorB

Get detailed information about a specific Datadog monitor by its ID. Use this to retrieve the complete configuration, status, and other details of a single monitor.

Inputs: monitorId (required).

get-monitorsB

Fetch monitors from Datadog with optional filtering. Use groupStates to filter by monitor status (e.g., 'alert', 'warn', 'no data'), tags or monitorTags to filter by tag criteria, and limit to control result size.

Inputs: groupStates, tags, monitorTags, limit.

search-logsB

Search logs in Datadog with advanced filtering options. Use filter.query for search terms (e.g., 'service:web-app status:error'), from/to for time ranges (e.g., 'now-15m', 'now'), and sort to order results. Essential for investigating application issues.

Inputs: filter, sort, page, limit.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 10 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose targeting specific Datadog resources: logs (aggregate-logs, search-logs), dashboards (get-dashboard, get-dashboards), events (get-events), incidents (get-incidents), metrics (get-metric-metadata, get-metrics), and monitors (get-monitor, get-monitors). There is no overlap in functionality, and the descriptions clearly differentiate between analytical queries, retrieval operations, and search capabilities.

    Naming Consistency5/5

    All tool names follow a consistent verb-noun pattern with hyphens, using 'get-' for retrieval operations (e.g., get-dashboard, get-metrics) and descriptive prefixes for other actions (e.g., aggregate-logs, search-logs). This uniformity makes the tool set predictable and easy to navigate, with no deviations in naming conventions.

    Tool Count5/5

    With 10 tools, the server is well-scoped for a Datadog integration, covering key areas like logs, dashboards, events, incidents, metrics, and monitors. Each tool serves a distinct and necessary function, avoiding redundancy while providing comprehensive access to core Datadog features without being overwhelming.

    Completeness4/5

    The tool set offers strong read-only coverage for Datadog's core resources, including retrieval and search operations. However, it lacks write operations (e.g., create, update, delete) for dashboards, monitors, or incidents, which could limit agents in full lifecycle management. Minor gaps exist, but agents can still perform essential monitoring and analysis tasks effectively.

    Maintenance

    ActivityInactive
    ResponsivenessLimited data

    Related MCP Connectors

    Related MCP Servers