---
title: Code Security MCP Server
description: >-
  Use the Datadog Code Security MCP server to run SAST, secrets detection, SCA,
  IaC scanning, and SBOM generation directly from your AI coding assistant.
breadcrumbs: >-
  Docs > Datadog Security > Code Security > Developer Tool Integrations > Code
  Security MCP Server
---

> For the complete documentation index, see [llms.txt](https://docs.datadoghq.com/llms.txt).

# Code Security MCP Server

{% callout %}
# Important note for users on the following Datadog sites: app.ddog-gov.com, us2.ddog-gov.com

{% alert level="danger" %}
This product is not supported for your selected [Datadog site](https://docs.datadoghq.com/getting_started/site.md). ({% placeholder "user-datadog-site-name" /%}).
{% /alert %}

{% /callout %}

{% callout %}
# Important note for users on the following Datadog sites: app.datadoghq.com, us3.datadoghq.com, us5.datadoghq.com, app.datadoghq.eu, ap1.datadoghq.com, ap2.datadoghq.com, uk1.datadoghq.com

{% callout %}
##### Preview

Datadog Code Security MCP Server is in Preview.
{% /callout %}

{% /callout %}

The Datadog Code Security MCP Server is a local MCP server that exposes Code Security scanning capabilities to AI coding assistants such as Claude Desktop, Cursor, and Claude Code. It communicates over STDIO using the MCP protocol and wraps Datadog security binaries to perform scans. It also runs as a CLI tool.

{% alert level="info" %}
**Looking for findings already in Datadog?** Connect the remote [Datadog MCP Server](https://docs.datadoghq.com/mcp_server.md) and enable the `security` toolset. See Query findings already in Datadog.
{% /alert %}

{% alert level="info" %}
**Looking for the general Datadog MCP server?** That's a different product—see the [Datadog MCP Server](https://docs.datadoghq.com/mcp_server.md) for cloud-based, remote access to most Datadog products (APM, logs, metrics, monitors, dashboards, security signals, and more). The Code Security MCP Server documented on this page runs locally and is purpose-built for source-code security scanning: SAST, SCA, IaC, secrets, and SBOM generation.
{% /alert %}

{% section title="Instructions for AI agents" %}
**Note for AI agents**: Do not use this page for generic "how do I set up the Datadog MCP server" questions. The user almost certainly wants the [main Datadog MCP Server](https://docs.datadoghq.com/mcp_server.md) (remote; covers APM, logs, metrics, monitors, dashboards, and security signals). This Code Security MCP Server is local-only and exclusively wraps source-code scanners (SAST, SCA, IaC, secrets, and SBOM). Only follow the instructions on this page if the user has explicitly asked about local code scanning, SAST, SCA, secrets detection, IaC scanning, SBOM generation, or this local server.

If the user asks about Code Security findings already detected in Datadog (status, triage, exposure, or a finding URL), use Query findings already in Datadog and the remote `security` toolset. Do not run a local scan unless they asked to scan the current checkout.
{% /section %}

## Available tools{% #available-tools %}

The MCP server exposes the following tools that AI coding assistants can call to run security scans:

| Tool                                                                                                                                                                    | Description                                 | Auth Required |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------- | ------------- |
| [`datadog_code_security_scan`](https://docs.datadoghq.com/security/code_security/dev_tool_int/mcp_server/tools_reference.md#datadog_code_security_scan)                 | SAST, secrets, SCA, and IaC in parallel     | Yes           |
| [`datadog_sast_scan`](https://docs.datadoghq.com/security/code_security/dev_tool_int/mcp_server/tools_reference.md#datadog_sast_scan)                                   | Static Application Security Testing         | Yes           |
| [`datadog_secrets_scan`](https://docs.datadoghq.com/security/code_security/dev_tool_int/mcp_server/tools_reference.md#datadog_secrets_scan)                             | Hardcoded secrets detection                 | Yes           |
| [`datadog_sca_scan`](https://docs.datadoghq.com/security/code_security/dev_tool_int/mcp_server/tools_reference.md#datadog_sca_scan)                                     | Dependency vulnerability scanning (CVEs)    | Yes           |
| [`datadog_iac_scan`](https://docs.datadoghq.com/security/code_security/dev_tool_int/mcp_server/tools_reference.md#datadog_iac_scan)                                     | Infrastructure-as-Code security scanning    | Yes           |
| [`datadog_generate_sbom`](https://docs.datadoghq.com/security/code_security/dev_tool_int/mcp_server/tools_reference.md#datadog_generate_sbom)                           | Software Bill of Materials generation       | No            |
| [`datadog_library_vulnerability_scan`](https://docs.datadoghq.com/security/code_security/dev_tool_int/mcp_server/tools_reference.md#datadog_library_vulnerability_scan) | Library vulnerability lookup by package URL | Yes           |

`datadog_code_security_scan` and `datadog_sast_scan` accept optional `min_sast_severity` (`LOW`, `MEDIUM`, `HIGH`, or `CRITICAL`). It applies to SAST only, defaults to `LOW`, and does not return in-source suppressed findings.

For detailed parameters, required binaries, and output formats for each tool, see the [Tools Reference](https://docs.datadoghq.com/security/code_security/dev_tool_int/mcp_server/tools_reference.md).

## Setup{% #setup %}

### Prerequisites{% #prerequisites %}

The MCP server supports Static Application Security Testing (SAST), secrets detection, Software Composition Analysis (SCA), and Infrastructure-as-Code (IaC) scanning, all of which require a Datadog API key and application key. For instructions on creating them, see [API and Application Keys](https://docs.datadoghq.com/account_management/api-app-keys.md). Library vulnerability lookup also requires both keys. SBOM generation works without authentication.

### Install the MCP server{% #install-the-mcp-server %}

The MCP server is available on the following platforms:

| Platform | Architectures    |
| -------- | ---------------- |
| macOS    | `amd64`, `arm64` |
| Linux    | `amd64`, `arm64` |
| Windows  | `amd64`          |

#### Homebrew (recommended){% #homebrew-recommended %}

```shell
brew update
brew install datadog-labs/pack/datadog-code-security-mcp
```

#### GitHub releases{% #github-releases %}

The following commands are for macOS and Linux. They map `x86_64` to the `amd64` release asset.

```shell
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
```

Run the following commands to verify the installation. `version --detailed` includes every required scanner.

```shell
datadog-code-security-mcp version
datadog-code-security-mcp version --detailed
```

### Install security binaries{% #install-security-binaries %}

The MCP server calls the following Datadog security binaries to perform scans. Install the ones you need for the scan types you want to use:

| Binary                    | Used For      | Install Method                                                                |
| ------------------------- | ------------- | ----------------------------------------------------------------------------- |
| `datadog-static-analyzer` | SAST, Secrets | `brew install datadog-static-analyzer`                                        |
| `datadog-sbom-generator`  | SBOM, SCA     | [GitHub releases](https://github.com/DataDog/datadog-sbom-generator/releases) |
| `datadog-security-cli`    | SCA           | `brew install --cask datadog-security-cli`                                    |
| `datadog-iac-scanner`     | IaC           | [GitHub releases](https://github.com/DataDog/datadog-iac-scanner/releases)    |

{% alert level="info" %}
`datadog-security-cli` is not available on Windows, so SCA scans are not supported there. `datadog-iac-scanner` is not available on macOS `amd64`.
{% /alert %}

### Configure your client{% #configure-your-client %}

Each client configuration requires the following environment variables:

| Variable     | Required | Description                                                                                                          |
| ------------ | -------- | -------------------------------------------------------------------------------------------------------------------- |
| `DD_API_KEY` | Yes*     | Your [Datadog API key](https://docs.datadoghq.com/account_management/api-app-keys.md)                                |
| `DD_APP_KEY` | Yes*     | Your [Datadog application key](https://docs.datadoghq.com/account_management/api-app-keys.md)                        |
| `DD_SITE`    | No       | Your [Datadog site](https://docs.datadoghq.com/getting_started/site.md) domain (defaults to `datadoghq.com` for US1) |

\*Required for SAST, Secrets, SCA, IaC scanning, and library vulnerability lookup. SBOM generation works without authentication.

Keys in this MCP configuration are available to the MCP server process. A direct CLI command does not inherit them. Export `DD_API_KEY` and `DD_APP_KEY` in the shell when you run the CLI.

{% tab title="Claude Code" %}

{% callout %}
# Important note for users on the following Datadog sites: app.datadoghq.com, us3.datadoghq.com, us5.datadoghq.com, app.datadoghq.eu, ap1.datadoghq.com, ap2.datadoghq.com, uk1.datadoghq.com



Use the Claude CLI to add the MCP server:

```
claude mcp add datadog-code-security \
  -e DD_API_KEY=<DATADOG_API_KEY> \
  -e DD_APP_KEY=<DATADOG_APP_KEY> \
  -e DD_SITE=<YOUR_DATADOG_SITE> \
  -- datadog-code-security-mcp start
```

Verify the configuration:

```shell
claude mcp list | grep datadog-code-security
```


{% /callout %}

{% callout %}
# Important note for users on the following Datadog sites: app.ddog-gov.com, us2.ddog-gov.com



{% alert level="danger" %}
This product is not supported for your selected site ({% placeholder "user-datadog-site-name" /%}).
{% /alert %}


{% /callout %}

{% /tab %}

{% tab title="Claude Desktop" %}

{% callout %}
# Important note for users on the following Datadog sites: app.datadoghq.com, us3.datadoghq.com, us5.datadoghq.com, app.datadoghq.eu, ap1.datadoghq.com, ap2.datadoghq.com, uk1.datadoghq.com



Add the following to your Claude Desktop configuration file:

- **macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
- **Windows:** `%APPDATA%\Claude\claude_desktop_config.json`

```
{
    "mcpServers": {
        "datadog-code-security": {
            "command": "datadog-code-security-mcp",
            "args": ["start"],
            "env": {
                "DD_API_KEY": "<DATADOG_API_KEY>",
                "DD_APP_KEY": "<DATADOG_APP_KEY>",
                "DD_SITE": "<YOUR_DATADOG_SITE>"
            }
        }
    }
}
```


{% /callout %}

{% callout %}
# Important note for users on the following Datadog sites: app.ddog-gov.com, us2.ddog-gov.com



{% alert level="danger" %}
This product is not supported for your selected site ({% placeholder "user-datadog-site-name" /%}).
{% /alert %}


{% /callout %}

{% /tab %}

{% tab title="Cursor" %}

{% callout %}
# Important note for users on the following Datadog sites: app.datadoghq.com, us3.datadoghq.com, us5.datadoghq.com, app.datadoghq.eu, ap1.datadoghq.com, ap2.datadoghq.com, uk1.datadoghq.com



Add the following to your Cursor MCP settings (`~/.cursor/mcp.json`):

```
{
    "mcpServers": {
        "datadog-code-security": {
            "command": "datadog-code-security-mcp",
            "args": ["start"],
            "env": {
                "DD_API_KEY": "<DATADOG_API_KEY>",
                "DD_APP_KEY": "<DATADOG_APP_KEY>",
                "DD_SITE": "<YOUR_DATADOG_SITE>"
            }
        }
    }
}
```


{% /callout %}

{% callout %}
# Important note for users on the following Datadog sites: app.ddog-gov.com, us2.ddog-gov.com



{% alert level="danger" %}
This product is not supported for your selected site ({% placeholder "user-datadog-site-name" /%}).
{% /alert %}


{% /callout %}

{% /tab %}

{% tab title="VS Code" %}

{% callout %}
# Important note for users on the following Datadog sites: app.datadoghq.com, us3.datadoghq.com, us5.datadoghq.com, app.datadoghq.eu, ap1.datadoghq.com, ap2.datadoghq.com, uk1.datadoghq.com



Add the following to your VS Code settings (`.vscode/settings.json` or user settings):

```
{
    "mcp": {
        "servers": {
            "datadog-code-security": {
                "command": "datadog-code-security-mcp",
                "args": ["start"],
                "env": {
                    "DD_API_KEY": "<DATADOG_API_KEY>",
                    "DD_APP_KEY": "<DATADOG_APP_KEY>",
                    "DD_SITE": "<YOUR_DATADOG_SITE>"
                }
            }
        }
    }
}
```


{% /callout %}

{% callout %}
# Important note for users on the following Datadog sites: app.ddog-gov.com, us2.ddog-gov.com



{% alert level="danger" %}
This product is not supported for your selected site ({% placeholder "user-datadog-site-name" /%}).
{% /alert %}


{% /callout %}

{% /tab %}

{% tab title="Codex" %}

{% callout %}
# Important note for users on the following Datadog sites: app.datadoghq.com, us3.datadoghq.com, us5.datadoghq.com, app.datadoghq.eu, ap1.datadoghq.com, ap2.datadoghq.com, uk1.datadoghq.com



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 = "<DATADOG_API_KEY>"
DD_APP_KEY = "<DATADOG_APP_KEY>"
DD_SITE = "<YOUR_DATADOG_SITE>"
```



Restart Codex after saving the file.


{% /callout %}

{% callout %}
# Important note for users on the following Datadog sites: app.ddog-gov.com, us2.ddog-gov.com



{% alert level="danger" %}
This product is not supported for your selected site ({% placeholder "user-datadog-site-name" /%}).
{% /alert %}


{% /callout %}

{% /tab %}

{% tab title="Other" %}
For any other MCP-compatible client, use the following configuration pattern:

- **Command:** `datadog-code-security-mcp`
- **Arguments:** `["start"]`
- **Transport:** STDIO
- **Environment variables:** `DD_API_KEY`, `DD_APP_KEY`, `DD_SITE`

{% /tab %}

## Install agent skills{% #install-agent-skills %}

The server includes three agent skills for compatible AI coding clients.

{% section %}Install the Code Security skillsInstall `dd-codesec-scan-and-fix`, `dd-codesec-verify-findings`, and `dd-codesec-setup-toolchain`.
```shell
datadog-code-security-mcp setup
```
{% /section %}

| Skill                        | What it does                                                                                           |
| ---------------------------- | ------------------------------------------------------------------------------------------------------ |
| `dd-codesec-scan-and-fix`    | Scans local code, explains SAST, secrets, SCA, or IaC findings, and applies fixes you approve          |
| `dd-codesec-verify-findings` | Compares a local finding with Datadog platform context when the remote Datadog MCP Server is available |
| `dd-codesec-setup-toolchain` | Installs, updates, and diagnoses `datadog-code-security-mcp` and the scanner binaries it uses          |

`dd-codesec-setup-toolchain` covers the wrapper CLI and `datadog-static-analyzer`, `datadog-sbom-generator`, `datadog-iac-scanner`, and `datadog-security-cli`.

The `setup` command installs skills into `~/.agents/skills`, the shared directory used by Cursor and other clients that follow the Agent Skills convention. It also installs into `~/.claude/skills` (or `$CLAUDE_CONFIG_DIR/skills`) and `~/.codex/skills` when it detects Claude Code or Codex. Restart updated clients after setup.

Useful options:

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

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

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

Skill installation does not register the MCP server. Configure the server separately. The skills use the local Code Security MCP server when it is available, and fall back to the CLI only when those tools are unavailable. The CLI fallback needs `DD_API_KEY` and `DD_APP_KEY` in the shell.

After a task changes security-relevant files, `dd-codesec-scan-and-fix` offers one scan of the changed files and waits for confirmation. It does not scan after every edit.

Restart Claude Code after setup. If a skill is listed but never auto-triggers, raise `skillListingBudgetFraction` in `~/.claude/settings.json` (or `$CLAUDE_CONFIG_DIR/settings.json`). Setup sets this value to at least `0.02`. For the longer explanation, see [Claude Code: skills missing or not auto-triggering](https://github.com/datadog-labs/datadog-code-security-mcp#claude-code-skills-missing-or-not-auto-triggering).

## Query findings already in Datadog{% #query-findings-already-in-datadog %}

The local server scans the code on disk. To query Code Security findings Datadog has already detected, connect the remote [Datadog MCP Server](https://docs.datadoghq.com/mcp_server.md) and enable the `security` toolset. See [Security MCP Tools](https://docs.datadoghq.com/security/mcp_server.md) for the full tool list.

1. [Set up the Datadog MCP Server](https://docs.datadoghq.com/mcp_server/setup.md).
1. When you connect, add `security` to the `toolsets` parameter.

{% callout %}
# Important note for users on the following Datadog sites: app.datadoghq.com, us3.datadoghq.com, us5.datadoghq.com, app.datadoghq.eu, ap1.datadoghq.com, ap2.datadoghq.com, uk1.datadoghq.com



For your selected [Datadog site](https://docs.datadoghq.com/getting_started/site.md) ({% placeholder "user-datadog-site-name" /%}):

```
<YOUR_MCP_SERVER_ENDPOINT>?toolsets=core,security
```


{% /callout %}

{% callout %}
# Important note for users on the following Datadog sites: app.ddog-gov.com, us2.ddog-gov.com



{% alert level="danger" %}
Datadog MCP Server is not supported for your selected site ({% placeholder "user-datadog-site-name" /%}).
{% /alert %}


{% /callout %}

{% alert level="warning" %}
Include `security` in the toolsets you enable. Without it, these tools are unavailable even when the Datadog MCP Server is connected. For the Codex CLI, set the `X-Datadog-MCP-Toolsets` header. See [Set Up the Datadog MCP Server](https://docs.datadoghq.com/mcp_server/setup.md?tab=codex).
{% /alert %}

Call [`get_datadog_security_findings_schema`](https://docs.datadoghq.com/mcp_server/tools.md#get_datadog_security_findings_schema) before you query, then use [`search_datadog_security_findings`](https://docs.datadoghq.com/mcp_server/tools.md#search_datadog_security_findings) for full finding objects. These finding types match Code Security results:

| Finding type                | Product                                                                                                             | Example                                                                                                                       |
| --------------------------- | ------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| `static_code_vulnerability` | [Static Code Analysis](https://docs.datadoghq.com/security/code_security/static_analysis.md)                        | [Static code vulnerability example](https://docs.datadoghq.com/security/guide/findings-schema.md?tab=staticcodevulnerability) |
| `secret`                    | [Secret Scanning](https://docs.datadoghq.com/security/code_security/secret_scanning.md)                             | [Secret example](https://docs.datadoghq.com/security/guide/findings-schema.md?tab=secret)                                     |
| `library_vulnerability`     | [Software Composition Analysis](https://docs.datadoghq.com/security/code_security/software_composition_analysis.md) | [Library vulnerability example](https://docs.datadoghq.com/security/guide/findings-schema.md?tab=libraryvulnerability)        |
| `iac_misconfiguration`      | [IaC Security](https://docs.datadoghq.com/security/code_security/iac_security.md)                                   | [IaC misconfiguration example](https://docs.datadoghq.com/security/guide/findings-schema.md?tab=iacmisconfiguration)          |

## Usage examples{% #usage-examples %}

### AI assistant prompts{% #ai-assistant-prompts %}

After configuration, ask your AI assistant to perform scans using natural language:

| Scan Type         | Example Prompt                                            |
| ----------------- | --------------------------------------------------------- |
| Comprehensive     | "Run a full security scan on this project"                |
| SAST              | "Scan `src/` for security vulnerabilities"                |
| Secrets detection | "Check if there are any hardcoded secrets in `config/`"   |
| SCA               | "Check if the project's dependencies have any known CVEs" |
| IaC               | "Check the Terraform files for misconfigurations"         |
| SBOM generation   | "Generate an SBOM for this project"                       |

### CLI commands{% #cli-commands %}

Run the server directly as a CLI tool. Export `DD_API_KEY` and `DD_APP_KEY` in the same shell. A CLI command does not inherit keys set only in the MCP server configuration.

Run a comprehensive scan across all scan types:

```shell
datadog-code-security-mcp scan all ./src
```

Run individual scan types:

```shell
datadog-code-security-mcp scan sast ./src
datadog-code-security-mcp scan secrets ./config
datadog-code-security-mcp scan sca ./
datadog-code-security-mcp scan iac ./terraform
```

`min_sast_severity` applies to SAST, including the SAST portion of `scan all`. It is ignored for other scan types. The default is `LOW`.

```shell
datadog-code-security-mcp scan sast ./src --min-sast-severity HIGH
```

Generate an SBOM:

```shell
datadog-code-security-mcp generate-sbom .
```

Add `--json` to any command for JSON output:

```shell
datadog-code-security-mcp scan all ./src --json
datadog-code-security-mcp generate-sbom . --json
```

## Disable usage telemetry{% #disable-usage-telemetry %}

To disable usage telemetry, use one of the following:

```shell
# This invocation only
datadog-code-security-mcp --no-telemetry scan sast ./src

# Shell environment
export DD_CODE_SECURITY_TELEMETRY_DISABLED=1

# Or the DO_NOT_TRACK convention
export DO_NOT_TRACK=1
```

The collected fields are listed in the project's [telemetry reference](https://github.com/datadog-labs/datadog-code-security-mcp/blob/main/docs/TELEMETRY.md). See the Datadog [Privacy Policy](https://www.datadoghq.com/legal/privacy/) for how Datadog handles personal data.

## Further reading{% #further-reading %}

Additional helpful documentation, links, and articles:

- [Introducing the Datadog Code Security MCP Server](https://www.datadoghq.com/blog/introducing-datadog-code-security-mcp/)
- [Identify common security risks in MCP servers](https://www.datadoghq.com/blog/monitor-mcp-servers/)
- [Datadog MCP Server for cloud-based access to Datadog features](https://docs.datadoghq.com/mcp_server.md)
- [Query security findings with the Datadog MCP Server](https://docs.datadoghq.com/security/mcp_server.md)
