datadog-mcp
Enables AI assistants to search logs, query metrics, manage dashboards, analyze APM traces, and control monitors via Datadog APIs.
README
Datadog MCP Server
A Model Context Protocol (MCP) server that connects Cursor AI agents to Datadog APIs. Search logs, query metrics, manage dashboards, analyze APM traces, and control monitors - all from your AI assistant.
Architecture
This project uses FastMCP (Fast Model Context Protocol) for elegant, FastAPI-style tool definitions. Tools are automatically discovered via decorators, schemas are generated from type hints, and routing is handled automatically.
Key patterns:
- Dependency Injection: Like FastAPI, auth is injected into tools
- No Context Managers: Direct API client access for simplicity
- Resources: Proactive context for the AI agent
- Prompts: Pre-configured query templates
See FASTMCP_IMPROVEMENTS.md for details on agent detection improvements and DEPENDENCY_INJECTION.md for architecture patterns.
Features
š Logs
- search_logs - Search logs with Datadog query syntax, time ranges, and facets
- get_log_details - Get detailed information about specific log entries
š Metrics
- query_metrics - Query time series metrics with aggregations
- list_metrics - Discover available metrics
- submit_metrics - Send custom metrics (gauge, count, rate)
š Dashboards
- list_dashboards - Browse all dashboards
- get_dashboard - Get complete dashboard definitions
- create_dashboard - Create dashboards with widgets, variables, and templates
- update_dashboard - Modify existing dashboards
š¬ APM/Traces
- search_spans - Search APM spans by service, operation, tags
- get_trace - Get complete trace information with all spans
- list_services - List available APM services
šØ Monitors/Alerts
- list_monitors - List all monitors with filtering
- get_monitor - Get monitor details
- create_monitor - Create metric, log, APM, or composite monitors
- update_monitor - Modify monitor configuration
- mute_monitor / unmute_monitor - Control alert notifications
Installation
Prerequisites
- Python 3.10 or higher
- uv (recommended) or pip
- Datadog account with API access
1. Install Dependencies
Using uv (recommended):
cd /path/to/datadog-mcp
uv sync
Using pip:
pip install -e .
2. Configure Datadog Credentials
ā ļø IMPORTANT: Credentials go in Cursor's mcp.json, NOT in this project's .env
Option A: Using Environment Variables (Recommended)
Set these in your shell's RC file (~/.zshrc, ~/.bashrc, etc.):
export DD_API_KEY="your-api-key-here"
export DD_APP_KEY="your-application-key-here"
export DD_SITE="datadoghq.com"
Then in Cursor's mcp.json, reference them:
{
"mcpServers": {
"datadog": {
"command": "uv",
"args": ["--directory", "/absolute/path/to/datadog-mcp", "run", "fastmcp", "run", "src/datadog_mcp/server.py"],
"env": {
"DD_API_KEY": "${DD_API_KEY}",
"DD_APP_KEY": "${DD_APP_KEY}",
"DD_SITE": "${DD_SITE}"
}
}
}
}
Option B: Direct in mcp.json
Alternatively, put credentials directly in Cursor's mcp.json (less secure, but simpler):
{
"mcpServers": {
"datadog": {
"command": "uv",
"args": ["--directory", "/absolute/path/to/datadog-mcp", "run", "fastmcp", "run", "src/datadog_mcp/server.py"],
"env": {
"DD_API_KEY": "your-actual-api-key",
"DD_APP_KEY": "your-actual-app-key",
"DD_SITE": "datadoghq.com"
}
}
}
}
Getting Your API Keys
- Go to Datadog Organization Settings
- API Key: Organization Settings > API Keys > New Key
- Application Key: Organization Settings > Application Keys > New Key
š Important: The Application Key requires specific scopes for full functionality:
- Read:
logs_read,metrics_read,dashboards_read,monitors_read,apm_read - Write:
metrics_write,dashboards_write,monitors_write,monitors_downtime_write
See DATADOG_PERMISSIONS.md for detailed permission requirements.
Datadog Regions
Set DD_SITE based on your Datadog region:
- US1:
datadoghq.com(default) - US3:
us3.datadoghq.com - US5:
us5.datadoghq.com - EU:
datadoghq.eu - AP1:
ap1.datadoghq.com
3. Configure Cursor
Add the Datadog MCP server to Cursor's MCP configuration:
Location:
- macOS/Linux:
~/.cursor/mcp.json - Windows:
%APPDATA%\Cursor\mcp.json
Configuration:
{
"mcpServers": {
"datadog": {
"command": "uv",
"args": [
"--directory",
"/absolute/path/to/datadog-mcp",
"run",
"fastmcp",
"run",
"src/datadog_mcp/server.py"
],
"env": {
"DD_API_KEY": "${DD_API_KEY}",
"DD_APP_KEY": "${DD_APP_KEY}",
"DD_SITE": "datadoghq.com"
}
}
}
}
Important: Replace /absolute/path/to/datadog-mcp with the actual absolute path to this project.
4. Restart Cursor
Restart Cursor IDE to load the new MCP server.
Usage Examples
Search Logs
Search Datadog logs for errors in the api service in the last hour
The agent will use search_logs with appropriate query syntax like:
- Query:
status:error service:api - Time range: last hour in ISO 8601 format
Query Metrics
Show me CPU usage for all hosts over the last 4 hours
The agent will use query_metrics with:
- Query:
avg:system.cpu.user{*} - Time range: Unix timestamps for last 4 hours
Create a Dashboard
Create a dashboard called "API Performance" with a timeseries widget showing request latency
The agent will use create_dashboard with proper widget configuration.
Search APM Traces
Find traces for the checkout service with status code 500 in the last 30 minutes
The agent will use search_spans with:
- Query:
service:checkout @http.status_code:500 - Time range: last 30 minutes
Create a Monitor
Create a metric alert that notifies @slack-alerts when CPU usage exceeds 80%
The agent will use create_monitor with appropriate thresholds and notification settings.
Development
Project Structure
datadog-mcp/
āāā src/
ā āāā datadog_mcp/
ā āāā __init__.py
ā āāā server.py # MCP server entry point
ā āāā auth.py # Authentication management
ā āāā tools/
ā āāā logs.py # Logs tools
ā āāā metrics.py # Metrics tools
ā āāā dashboards.py # Dashboard tools
ā āāā apm.py # APM/traces tools
ā āāā monitors.py # Monitor tools
āāā pyproject.toml
āāā README.md
āāā .env.example
Running Locally
Test the server directly:
# Using uv
uv run datadog-mcp
# Using python
python -m datadog_mcp.server
Adding New Tools
- Implement the tool function in the appropriate file under
src/datadog_mcp/tools/ - Add the tool definition to
list_tools()inserver.py - Add the tool handler to
call_tool()inserver.py
Troubleshooting
Server Not Appearing in Cursor
- Check that the path in
mcp.jsonis absolute and correct - Ensure credentials are set in
.envor environment variables - Restart Cursor IDE completely
- Check Cursor logs for MCP server errors
Authentication Errors
- Verify API keys are correct in
.env - Check that Application Key has proper permissions
- Verify
DD_SITEmatches your Datadog region
Import Errors
# Reinstall dependencies
uv sync
# or
pip install -e .
API Documentation
For detailed information about Datadog API endpoints and query syntax:
Contributing
Contributions are welcome! Please feel free to submit issues or pull requests.
License
MIT License - See LICENSE file for details
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.