Skip to content

About

No description, website, or topics provided.

Resources

Stars

6 stars

Watchers

0 watching

Forks

Repository files navigation

Datadog Code Security MCP

Datadog Code Security MCP provides all Code Security scan tools to AI coding assistants like Claude Desktop, Cursor, etc - Can also be used as a CLI tool.

Note: The Datadog Code Security MCP server is currently in Preview

Setup for this repository is below. The Code Security MCP Server documentation also covers site-specific client configuration and how to query findings already in Datadog with the remote Datadog MCP Server.

Available MCP Tools

  1. datadog_code_security_scan - SAST + Secrets + SCA + IAC in parallel
  2. datadog_sast_scan - Static Application Security Testing only
  3. datadog_secrets_scan - Secrets detection only
  4. datadog_sca_scan - Software Composition Analysis (dependency vulnerabilities)
  5. datadog_iac_scan - Infrastructure as code scanning
  6. datadog_generate_sbom - Generate Software Bill of Materials (SBOM)
  7. datadog_library_vulnerability_scan - Scan specific libraries by package URL
  8. datadog_ephemeral_sast_scan - Run one caller-supplied SAST rule locally without publishing it (no API keys)
  9. datadog_promote_sast_rule - Save an approved SAST rule as a Datadog custom rule (requires API keys)

datadog_ephemeral_sast_scan needs datadog-static-analyzer 0.9.10 or later, which adds --rules-with-config. It runs only the supplied rule, even when the repository has a Static Analysis configuration, but still honors that configuration's ignored paths, only paths, file size limit, and gitignore setting. datadog_promote_sast_rule refuses to save over an existing rule unless the caller passes overwrite: true after the user agrees.

datadog_code_security_scan and datadog_sast_scan accept optional min_sast_severity (LOW, MEDIUM, HIGH, or CRITICAL). It affects SAST only and defaults to LOW; in-source-suppressed findings remain excluded.

Quick Start

Installation

Homebrew (Recommended):

brew tap datadog-labs/pack
brew update
brew install datadog-labs/pack/datadog-code-security-mcp

Alternative: Download from GitHub Releases

# macOS / Linux (auto-detects platform)
OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
case "$(uname -m)" in
  x86_64)        ARCH="amd64" ;;
  arm64|aarch64) ARCH="arm64" ;;
  *) echo "Unsupported architecture: $(uname -m)" >&2; exit 1 ;;
esac

ASSET="datadog-code-security-mcp-${OS}-${ARCH}.tar.gz"
curl -fL \
  "https://github.com/datadog-labs/datadog-code-security-mcp/releases/latest/download/${ASSET}" \
  -o "/tmp/${ASSET}"
tar -xzf "/tmp/${ASSET}"
sudo install -m 755 datadog-code-security-mcp /usr/local/bin/
rm -f "/tmp/${ASSET}" datadog-code-security-mcp

Verify installation:

datadog-code-security-mcp version
datadog-code-security-mcp version --detailed # Include every required scanner

Install AI Client Skills

The binary ships four Agent Skills for compatible AI coding clients:

  • dd-codesec-scan-and-fix — scans local code, loads a focused SAST, Secrets, SCA, or IaC playbook, optionally enriches matches with Datadog-proposed code or package updates, applies approved fixes, and rescans to verify them.
  • dd-codesec-verify-findings — enriches a current local finding with Datadog platform context when a Datadog MCP server is available. Platform proposals are advisory and must be matched and verified against the current checkout.
  • dd-codesec-setup-toolchain — installs, updates, and diagnoses the scanner binaries, relaying the CLI's platform-specific installation instructions with confirmation guardrails.
  • dd-codesec-find-security-variants — after an uncommitted security fix, infers the invariant, runs a temporary SAST rule with the local scanner, and reports other places that break the same invariant.

Install them into the shared Agent Skills directory and every detected native client directory:

datadog-code-security-mcp setup

Useful options:

# Preview without writing files
datadog-code-security-mcp setup --dry-run

# Restrict setup to one or more clients
datadog-code-security-mcp setup --client agents --client codex

# Install Claude Code skills without changing its skill-listing budget
datadog-code-security-mcp setup --client claude-code --skip-skill-listing-budget

# Remove only skills managed by this binary
datadog-code-security-mcp setup --remove-skills

# Remove Datadog skills from the shared Agent Skills directory only
datadog-code-security-mcp setup --client agents --remove-skills

# Machine-readable report
datadog-code-security-mcp setup --json

Setup always installs into ~/.agents/skills, the shared directory used by Cursor, OpenCode, Pi, Gemini CLI, and other clients that follow the Agent Skills convention. It also detects Claude Code and Codex from their CLIs or user configuration directories and installs into ~/.claude/skills (or $CLAUDE_CONFIG_DIR/skills) and ~/.codex/skills when present. It then asks you to restart updated clients. The accepted --client IDs are agents, claude-code, and codex. For Claude Code, setup also ensures that skillListingBudgetFraction is at least 0.02 in ~/.claude/settings.json (or $CLAUDE_CONFIG_DIR/settings.json), so skill descriptions stay in context. See Claude Code: skills missing or not auto-triggering for why. Existing higher values are preserved. Use --skip-skill-listing-budget to install the skills without changing this setting. If the settings file cannot be updated, setup still installs the skills and prints a warning. Removing skills does not revert the setting.

The skills prefer the local Code Security MCP scan tools when that MCP server is registered in the client. They fall back to datadog-code-security-mcp ... --json from the local shell only if those MCP tools are unavailable or a tool call fails. Skill installation does not register the MCP server; configure it separately so the preferred path works. Direct CLI fallback requires DD_API_KEY and DD_APP_KEY in the shell environment. The remote Datadog MCP, when available, provides platform context rather than performing the authoritative local scan. Setup does not modify MCP configuration.

For the best experience, also connect the official Datadog MCP Server. It gives the skills access to Datadog platform context such as finding status and exposure information. It complements this local Code Security MCP server: the remote server retrieves platform data, while this server scans the code currently on disk.

The remediation skill never scans after every edit. It runs when explicitly asked or when verifying a backend finding; after a task changes security- relevant files it offers one changed-file scan and waits for confirmation.

Claude Code: skills missing or not auto-triggering

After setup, Claude Code should list dd-codesec-scan-and-fix, dd-codesec-verify-findings, dd-codesec-setup-toolchain, and dd-codesec-find-security-variants. Restart Claude Code if they are missing from /skills. Confirm the trees exist under ~/.claude/skills or $CLAUDE_CONFIG_DIR/skills (native), or ~/.agents/skills (shared). You can still invoke a skill by name, for example /dd-codesec-scan-and-fix.

If a skill is listed but never auto-triggers, Claude Code may have dropped its description from context. It caps how much of the skill listing (names + descriptions) it loads each turn. When that cap is exceeded, it keeps every skill's name but drops the description for the skills you invoke least. A skill you rarely call — including these, right after install — can lose its description before a heavily used native one does. Renaming the skill or rewriting its description does not fix this; it is a budget and priority issue, not a wording issue.

This is a known upstream pattern. See anthropics/claude-code #57515, #59921, #68677, #78270, and #85027.

Check /context and run /doctor to see whether the skill listing is over budget. Setup raises the user-level budget from Claude Code's 0.01 default to at least 0.02, but that may still be insufficient for a large skill library. Two settings can help:

Option A — raise the skill-listing budget further:

{
  "skillListingBudgetFraction": 0.03
}

Add it to ~/.claude/settings.json for all local projects, or to a project's .claude/settings.json for that project only. This is a blunt instrument: it gives more room to every skill's description, not just Datadog's, and may need raising again as more skills get installed.

Option B — turn off a competing skill:

{
  "skillOverrides": {
    "security-review": "off"
  }
}

Claude Code ships a native security-review skill that can win the "most invoked" slot and push Datadog descriptions out first. "off" (or "name-only") removes it from contention without changing the global budget. You can also set this from the /skills menu: highlight the skill, press Space to cycle its state, then Esc to save.

Option B is more targeted than repeatedly raising the budget, but only disable skills you do not need. Full reference: Claude Code settings (skillListingBudgetFraction, skillListingMaxDescChars, skillOverrides).

⚠️ Requirements:

The MCP server requires external Datadog security binaries to perform scans.

Note: If a required binary is missing, the MCP server will detect this and provide platform-specific installation instructions.

Authentication

Datadog Code Security needs a Datadog API key and application key as DD_API_KEY and DD_APP_KEY. Where you set them depends on how you run the tool:

  • MCP server (recommended for AI assistants): put the keys in the MCP server env in your client configuration (examples below). The MCP process inherits those values. Skills use this server when it is available.
  • Direct CLI: export DD_API_KEY and DD_APP_KEY in your shell environment (optionally DD_SITE). MCP env values are not visible to a raw datadog-code-security-mcp scan ... process. Without these variables, some scans fail — Secrets in particular cannot fetch security rules.

Optional: DD_SITE (your Datadog site, for example datadoghq.com).

Datadog employees: instead of permanent keys, set DD_AUTH_DOMAIN (for example app.datadoghq.com) so the tool obtains short-lived keys from dd-auth. Keys already in the environment take precedence.

Claude Configuration

For Claude Code skills that do not appear or do not auto-trigger, see Claude Code: skills missing or not auto-triggering.

# Configure with API keys
claude mcp add datadog-code-security \
  -e DD_API_KEY=<your-api-key> \
  -e DD_APP_KEY=<your-app-key> \
  -e DD_SITE=datadoghq.com \
  -- datadog-code-security-mcp start

# Verify it's running
claude mcp list | grep datadog-code-security

Manual Configuration (~/.claude/config.json)

{
  "mcpServers": {
    "datadog-code-security": {
      "command": "datadog-code-security-mcp",
      "args": ["start"],
      "env": {
        "DD_API_KEY": "<your-api-key>",
        "DD_APP_KEY": "<your-app-key>",
        "DD_SITE": "datadoghq.com"
      }
    }
  }
}

Cursor Configuration

Cursor supports MCP servers through its settings. Add the following to your Cursor MCP configuration:

{
  "mcpServers": {
    "datadog-code-security": {
      "command": "datadog-code-security-mcp",
      "args": ["start"],
      "env": {
        "DD_API_KEY": "<your-api-key>",
        "DD_APP_KEY": "<your-app-key>",
        "DD_SITE": "datadoghq.com"
      }
    }
  }
}

Codex Configuration

Add the following to ~/.codex/config.toml:

[mcp_servers.datadog-code-security]
command = "datadog-code-security-mcp"
args = ["start"]

[mcp_servers.datadog-code-security.env]
DD_API_KEY = "<your-api-key>"
DD_APP_KEY = "<your-app-key>"
DD_SITE = "datadoghq.com"

Restart Codex after saving the file so it picks up the new server. Skills installed by datadog-code-security-mcp setup live in ~/.codex/skills and ~/.agents/skills.

Usage

Once configured, ask your AI assistant to scan your code:

Security Scans:

  • "Scan this directory for security vulnerabilities"
  • "Check if there are any hardcoded secrets in config/"
  • "Run a full security scan (SAST + Secrets + SCA + IaC)"
  • "Find all security issues in this project"

Security Variants (after an uncommitted security fix):

  • "I just fixed this missing authorization check. Is the same mistake anywhere else?"
  • "Save that rule as a custom rule"

Dependency Analysis:

  • "Scan for vulnerable dependencies"
  • "Check if my dependencies have any known CVEs"
  • "Generate an SBOM for this project"
  • "What dependencies does this project have?"

Direct Scanning with CLI

You can run scans without an MCP client. Export DD_API_KEY and DD_APP_KEY in the same environment as the CLI (see Authentication). MCP configuration does not apply to these commands.

# Comprehensive scan (SAST + Secrets + SCA + IaC in parallel)
datadog-code-security-mcp scan all ./src

# Individual scan types
datadog-code-security-mcp scan sast ./app      # SAST only
datadog-code-security-mcp scan secrets ./config # Secrets only
datadog-code-security-mcp scan sca ./           # SCA only (requires datadog-security-cli)
datadog-code-security-mcp scan iac ./infra      # IaC only

# SAST returns LOW and above by default; choose a higher threshold if desired
datadog-code-security-mcp scan sast ./app --min-sast-severity HIGH

# SBOM generation
datadog-code-security-mcp generate-sbom .           # Generate SBOM

# JSON output for programmatic use
datadog-code-security-mcp scan all ./src --json
datadog-code-security-mcp scan sast ./app --json
datadog-code-security-mcp generate-sbom . --json

# Run one unpublished SAST rule (no API keys; JSON output)
datadog-code-security-mcp ephemeral-scan --language GO --directory . \
  --code-file rule.js --query-file query.scm

# Save that rule as a custom rule in the security-variants ruleset
datadog-code-security-mcp promote-sast-rule --user-confirmed \
  --language GO --rule-name missing-guard \
  --code-file rule.js --query-file query.scm --tests-file tests.json

--tests-file is required. It holds exactly two examples: the fixed code with annotation_count 0, and the code before the fix with a positive annotation_count. The rule runs on both before anything is uploaded, and nothing is saved unless each count matches and the rule ran without errors.

Both commands report a rule that throws, does not compile, or times out as an error, instead of an empty result. They run the analyzer with --debug yes to read those failures.

testdata/ephemeral/ has a working rule.js, query.scm, and tests.json.

Manual Installation Instructions for Requirements (Optional)

datadog-static-analyzer (SAST + Secrets)

# macOS (Homebrew — tap is already added if you installed the MCP server via brew)
brew install datadog-static-analyzer

datadog-sbom-generator (SBOM)

# macOS / Linux (download from GitHub releases)
curl -L "https://github.com/DataDog/datadog-sbom-generator/releases/latest/download/datadog-sbom-generator_$(uname -s | tr '[:upper:]' '[:lower:]')_$(uname -m).zip" -o /tmp/sbom.zip
unzip -o /tmp/sbom.zip -d /tmp/ && mkdir -p ~/.local/bin && mv /tmp/datadog-sbom-generator ~/.local/bin/ && chmod +x ~/.local/bin/datadog-sbom-generator

On Windows, download the zip for your architecture, extract datadog-sbom-generator.exe, and move it to a directory in your PATH:

datadog-security-cli (SCA)

# macOS (Homebrew)
brew install --cask datadog-security-cli

Telemetry Data Collection

Datadog Code Security MCP collects usage telemetry (tool and scanner versions, OS/arch, run duration, success/failure, aggregate counts, coarse authentication/workspace metadata, whether a Datadog agent skill initiated the run, categorized error kinds, a fixed team ownership tag, and a random install ID stored on your machine) to help improve the tool. It does not collect source code, paths, scan finding contents, secrets, repository names, usernames, or raw error messages. Each error carries a short curated, path-free description (for Error Tracking) — never the raw error text.

Scanner versions are collected once per process and are not persisted. Telemetry events sent to Datadog are retained for 30 days.

To disable collection of any of this usage telemetry, use any of the following:

# Per-invocation flag
datadog-code-security-mcp --no-telemetry scan sast ./src

# Environment variable (add to your shell profile to make it permanent)
export DD_CODE_SECURITY_TELEMETRY_DISABLED=1

# DO_NOT_TRACK standard (https://consoledonottrack.com/)
export DO_NOT_TRACK=1

Full details on what is collected, the install ID, and how to turn off data collection: docs/TELEMETRY.md.

Please see the Datadog Privacy Policy for more information.

For Developers

Quick References:

Key Commands:

make build          # Build binary
make test           # Run tests with race detector
make lint           # Run linters
go run ./cmd/datadog-code-security-mcp version

License

Apache 2.0

About

No description, website, or topics provided.

Resources

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages