Skip to content

Menu

Semgrep MCP Server logo

Semgrep MCP Server

Published · Updated

At a glance

GitHub repository
semgrep/semgrep
Watch out for
semgrep_findings needs a SEMGREP_APP_TOKEN and an AppSec Platform account; plain scans work without one.

Semgrep publishes its MCP server as part of the main Semgrep CLI. It started life in a standalone repo (semgrep/mcp), which is now archived with a note that updates ship through the official semgrep binary instead. The code lives under cli/src/semgrep/mcp in the semgrep/semgrep repository, and you start it with the semgrep mcp subcommand.

The server lets a coding agent run Semgrep's static analysis on the code it is writing or reviewing. It can scan files, test a custom rule, look at a syntax tree, and, if you connect a Semgrep AppSec Platform token, pull findings your organisation already has.

It runs locally over stdio by default, or as a streamable HTTP server on port 8000 with -t streamable-http. Semgrep now packages it in a bundle it calls Semgrep Guardian, delivered as a plugin for Claude Code and Cursor.

How it connects

Your AI app

An assistant or agent that supports MCP

Semgrep MCP Server

Runs as

  • Python (uv / pip)
  • Docker

Gives the agent

  • Scan code
  • Custom rules
  • Supply chain checks
  • AppSec Platform findings
  • Code structure
  • Prompts and resources

Semgrep

The data or system the tools act on

Your AI app talks to Semgrep MCP Server over the Model Context Protocol, and the server carries out the work. Built from the setup and capability sections on this page.

What it can do

Scan code
semgrep_scan runs Semgrep over local files. In hosted mode the server swaps it for semgrep_scan_remote, which takes file contents in the request instead.
Custom rules
semgrep_scan_with_custom_rule scans code against a rule the agent writes, and semgrep_rule_schema returns the rule schema so the agent can write a valid one.
Supply chain checks
semgrep_scan_supply_chain checks dependencies for known issues. It is only registered when the server is not running in hosted mode.
AppSec Platform findings
semgrep_findings lists existing SAST or SCA findings, filtered by repo, status, severity and confidence.
Code structure
get_abstract_syntax_tree returns the AST for a snippet, and get_supported_languages lists the languages Semgrep can parse.
Prompts and resources
The server ships write_custom_semgrep_rule and setup_semgrep_mcp prompts, plus semgrep://rule/schema and semgrep://rule/{rule_id}/yaml resources.

Setting it up

Install the Semgrep CLI first, for example with brew install semgrep or python3 -m pip install semgrep, then check semgrep --version. In Claude Code, open /plugin, go to Discover, search for Semgrep and install it, then run /setup-semgrep-plugin, which also installs the CLI. Cursor works the same way through its plugin marketplace, followed by /setup-semgrep-plugin and a restart. For VS Code, add a server named semgrep under mcpServers in the workspace-root .mcp.json with "command": "semgrep" and "args": ["mcp"]. Docker users can run docker run -i --rm semgrep/semgrep semgrep mcp -t stdio. To reach AppSec Platform data, generate a token under Settings at semgrep.dev and set SEMGREP_APP_TOKEN in the environment or in the env block of your MCP config. For HTTP, run semgrep mcp -t streamable-http and point the client at http://localhost:8000/mcp.

Where each client keeps its MCP config file, and the JSON it expects (cheat sheet)

Where it helps

  • Scan a file the agent just wrote for injection or other security bugs before it opens a pull request.
  • Draft a Semgrep rule for a pattern your team keeps getting wrong, then test it against sample code in the same session.
  • Pull open high-severity findings for a repo from the AppSec Platform and have the agent work through fixes.
  • Check a project's dependencies for known vulnerable packages with a supply chain scan.

Limitations and things to watch

  • semgrep_findings needs a SEMGREP_APP_TOKEN and an AppSec Platform account; plain scans work without one.
  • semgrep_whoami is removed over stdio because it needs a JWT that only comes through the OAuth flow on HTTP transports.
  • Older guides point at the uvx semgrep-mcp package and the ghcr.io/semgrep/mcp image from the archived repo; current setup uses the semgrep binary.
  • The README notes the project is under active development and that some install badges may not work since the move into the main repo.
  • Scan results depend on the rules configured, so a clean scan is not proof that code is free of vulnerabilities.

Sources

Written from the project's own documentation, checked November 2026.

How we research: where our facts come from, how often we re-check them, and why no one can pay for a review or a verdict.

Reviews and commentsShow

Reviews

Sign in to leave a review.

Loading reviews…

Comments

Sign in to leave a comment.

Loading comments…