Datadog Model Context Protocol Server
The `datadog-mcp-server` package provides a Model Context Protocol (MCP) server designed to interface with the Datadog API. Currently at version 1.0.9, this server acts as a comprehensive gateway for accessing various Datadog resources including monitors, dashboards, metrics, events, logs, and incidents. It offers direct integration with both Datadog's v1 and v2 APIs, featuring robust error handling and support for service-specific endpoints across different Datadog regional sites. The server is primarily distributed as a command-line interface (CLI) tool, configured via environment variables or CLI arguments, and is intended to run as a background service or be invoked by other MCP-compatible tools like Claude Desktop or MCP Inspector. Its main differentiator is providing a standardized MCP interface over the extensive Datadog API.
Common errors
-
Error: Node.js vX.Y.Z is not supported. Please use Node.js v16 or higher.
cause Attempting to run the server with an unsupported Node.js version.fixUpgrade your Node.js installation to version 16 or newer. Check your current version with `node -v`. -
Failed to authenticate with Datadog API. Please check your API and Application keys.
cause Missing or invalid Datadog API or Application keys.fixSet `DD_API_KEY` and `DD_APP_KEY` environment variables, or pass `--apiKey` and `--appKey` command-line arguments with correct values. -
API request failed: Host not found or service unavailable.
cause Incorrect Datadog site URL or network connectivity issues preventing access to the Datadog API endpoints.fixVerify the `--site` argument or `DD_SITE` environment variable is set to the correct regional endpoint (e.g., `datadoghq.com`, `datadoghq.eu`). Check network connectivity to Datadog's API. -
Error: Missing required argument: --apiKey
cause Server started without providing the necessary Datadog API or Application key via CLI arguments or environment variables.fixInclude both `--apiKey=<YOUR_API_KEY>` and `--appKey=<YOUR_APP_KEY>` in your command-line arguments, or ensure `DD_API_KEY` and `DD_APP_KEY` are set in your environment.
Warnings
- breaking Node.js version 16 or higher is a prerequisite for running `datadog-mcp-server`. Older Node.js versions will prevent the server from starting or cause unexpected runtime errors.
- gotcha Datadog API and Application keys are mandatory for server operation. Running the server without valid keys, either via environment variables (`DD_API_KEY`, `DD_APP_KEY`) or command-line arguments (`--apiKey`, `--appKey`), will result in authentication failures and prevent any interaction with the Datadog API.
- gotcha Incorrectly specifying the Datadog regional site (e.g., `--site`, `DD_SITE`) can lead to connectivity issues or data not being found, even with valid API keys. The default is `datadoghq.com` (US).
- gotcha As a server process, `datadog-mcp-server` will continuously run and consume system resources (CPU, memory, network). It must be properly managed (e.g., via `systemd`, `pm2`, or `docker`) for production deployments to ensure uptime and resource efficiency.
Install
-
npm install datadog-mcp-server -
yarn add datadog-mcp-server -
pnpm add datadog-mcp-server
Imports
- runServer
import DatadogMCP from 'datadog-mcp-server';
import { runServer } from 'datadog-mcp-server'; - ServerOptions
import { ServerConfig } from 'datadog-mcp-server';import type { ServerOptions } from 'datadog-mcp-server'; - getMonitorTool
import { getMonitor } from 'datadog-mcp-server';import { getMonitorTool } from 'datadog-mcp-server/dist/tools';
Quickstart
import { spawn } from 'child_process';
import path from 'path';
// This demonstrates how to programmatically start the datadog-mcp-server CLI.
// In a typical setup, you would run this server globally or via npx.
const apiKey = process.env.DD_API_KEY ?? 'your_datadog_api_key';
const appKey = process.env.DD_APP_KEY ?? 'your_datadog_app_key';
const site = process.env.DD_SITE ?? 'datadoghq.com';
if (apiKey === 'your_datadog_api_key' || appKey === 'your_datadog_app_key') {
console.warn("WARNING: Using placeholder Datadog API/App keys. Please set DD_API_KEY and DD_APP_KEY environment variables for actual use.");
}
const serverProcess = spawn('npx', [
'datadog-mcp-server',
'--apiKey', apiKey,
'--appKey', appKey,
'--site', site
], {
stdio: 'inherit', // Pipe child process stdout/stderr to parent
env: process.env, // Inherit environment variables
cwd: path.resolve(__dirname), // Ensure context is correct
});
console.log(`Datadog MCP Server started with site: ${site}.`);
console.log('Use Ctrl+C to stop the server.');
serverProcess.on('error', (err) => {
console.error('Failed to start Datadog MCP Server:', err);
});
serverProcess.on('exit', (code) => {
console.log(`Datadog MCP Server exited with code ${code}.`);
});
// Example of how you might stop it programmatically after some time (optional)
// setTimeout(() => {
// console.log('Stopping Datadog MCP Server...');
// serverProcess.kill('SIGTERM');
// }, 60000);