Semgrep SAST MCP Server
Deterministic multi-language AST static analysis and SARIF finding triage over Model Context Protocol.
Prerequisites & Step-by-Step Installation
Copy & run inside isolated labBefore You Start (Prerequisites)
- + Semgrep OSS CLI (>= 1.90) installed locally
- + Python >= 3.11 with uv or pip
- + Local source repository checked out on a clean branch
Install Semgrep CLI and verify local rulesets work offline
python3 -m pip install semgrep
semgrep --version
Set SEMGREP_SEND_METRICS=off in air-gapped or NDA audit workspaces.
Register Semgrep MCP in Claude Code with telemetry disabled
claude mcp add semgrep-mcp -e SEMGREP_SEND_METRICS=off -- semgrep mcp
Runs AST scanning locally inside the active workspace directory.
SEMGREP_SEND_METRICS=off semgrep --version
Client Integration & Configuration Files
Review scope limits before wiringclaude mcp add semgrep-sast-mcp-server -- semgrep-mcp --config p/owasp-top-ten --read-only
{
"mcpServers": {
"semgrep-sast-mcp-server": {
"command": "semgrep-mcp",
"args": [
"--config",
"p/owasp-top-ten",
"--read-only"
],
"env": {
"TOOLWAR_SAFE_MODE": "strict",
"AUTH_TOKEN": "YOUR_SCOPED_TOKEN_HERE"
}
}
}
}
{
"mcpServers": {
"semgrep-sast-mcp-server": {
"command": "semgrep-mcp",
"args": [
"--config",
"p/owasp-top-ten",
"--read-only"
]
}
}
}
services:
semgrep-sast-mcp-server:
image: toolwar-sandbox/mcp-runner:latest
read_only: true
cap_drop:
- ALL
security_opt:
- no-new-privileges:true
How to Use & Defensive Workflow
Authorized assessment protocolTypical Scenario: Pair AST pattern matching with AI reasoning so security findings cite real data-flow lines rather than LLM guesses.
- 01. Disable telemetry with SEMGREP_SEND_METRICS=off for private repositories.
- 02. Run a targeted ruleset scan across changed files or API controllers.
- 03. Review each CWE hit, write a regression unit test, and apply the parameterized fix.
Scan app/Http/Controllers with semgrep-mcp using p/owasp-top-ten rules, verify which findings lack authorization middleware, and draft unit-tested patches.
Bind the MCP server exclusively inside a read-only workspace or isolated container (`read_only: true`, `--cap-drop=ALL`). Enforce strict CIDR/directory allowlists and never expose local MCP stdio or SSE ports on untrusted network interfaces without mutual authentication.
Technical Architecture & Deployment Brief
Overview & Role in Security Engineering
Semgrep SAST MCP Server (Security MCP Server) is engineered to support practitioners focused on deterministic taint rule scanning, custom YAML rule validation, and developer-ready patch guidance without sending proprietary source externally. Within the ToolWar ecosystem, it serves as an explicit bridge between AI reasoning layers and verifiable cybersecurity telemetry.
Technical Architecture & Data Flow
The Model Context Protocol (MCP) separates the language model reasoning layer from privileged binary execution. Rather than letting an AI assistant invoke unconstrained shell commands, this server exposes typed, schema-validated read/inspection tools with explicit scope boundaries.
Unlike ad-hoc prompt wrappers that execute unconstrained strings directly in a shell, structured integration enforces typed parameter validation, bounded scope allowlists, and explicit separation between untrusted analyzed artifacts (source files, telemetry logs, network banners, or binary samples) and system-level control instructions.
Recommended Deployment Practice
- Isolate the Execution Boundary: Deploy integrations inside ephemeral containers or dedicated analysis VMs so untrusted repositories, binaries, or HTTP responses cannot affect primary workstations.
- Enforce Least-Privilege Scoping: Use read-only filesystem mounts, non-privileged service tokens, and target CIDR allowlists before enabling interactive assistant sessions.
- Verify Outputs Deterministically: Pair this connector with least-privilege runtime profiles and inspect every returned JSON schema before forwarding findings into automated tickets or dashboards.
Integration & Operational Caveats
- Treat all external content ingested by an LLM (including code comments, HTML titles, log lines, and MCP responses) as potential prompt-injection vectors.
- Review configuration JSON and
SKILL.mdmanifests carefully before binding credentials or running inside automated CI/CD pipelines.