Semgrep Plugin
Semgrep's plugin integrates natively with AI coding agents like Cursor, Claude Code, and Windsurf to catch security issues before they ship. It bundles the Semgrep MCP server, Hooks, and Skills into a single install, and scans every file an agent generates using Semgrep Code, Supply Chain, and Secrets. When findings are detected, the agent is prompted to regenerate code until Semgrep returns clean results or you choose to dismiss them.
This guide covers setup for Cursor, Windsurf, and Claude Code, but the plugin works with any MCP client.
Prerequisites
- Python 3.10 or later
- Homebrew or Pip to install Semgrep
- A Semgrep account
Installation
- Claude Code
- Cursor
- Windsurf
- Other IDEs
-
Install Semgrep:
# install through homebrew
brew install semgrep
# install through pip
python3 -m pip install semgrep -
Verify that you've installed the latest version of Semgrep by running the following:
semgrep --version -
Start a new Claude Code instance in the terminal:
claude -
Open the plugin browser:
/plugin -
Go to Discover, search for Semgrep, and click Install.
-
Set up the Semgrep plugin by running the following skill. This also installs the Semgrep CLI:
/setup-semgrep-plugin
-
Install Semgrep:
# install through homebrew
brew install semgrep
# install through pip
python3 -m pip install semgrep -
Verify that you've installed the latest version of Semgrep by running the following:
semgrep --version -
Log in to Semgrep and install Semgrep Pro:
semgrep login && semgrep install-semgrep-pro -
Find Semgrep in the Cursor Plugin Marketplace, or open Cursor > ⌘⇧J > Plugins. Search "Semgrep" and click Add to Cursor.
-
Restart Cursor to apply configuration.
-
Install Semgrep:
# install through homebrew
brew install semgrep
# install through pip
python3 -m pip install semgrep -
Verify that you've installed the latest version of Semgrep by running the following:
semgrep --version -
Log in to Semgrep and install Semgrep Pro:
semgrep login && semgrep install-semgrep-pro -
Create a
hooks.jsonfile at~/.codeium/windsurf/hooks.jsonand paste the following configuration:{
"hooks": {
"post_write_code": [
{
"command": "semgrep mcp -k post-tool-cli-scan -a windsurf",
"show_output": true
}
]
}
} -
Restart Windsurf to apply hook configuration.
-
Install Semgrep:
# install through homebrew
brew install semgrep
# install through pip
python3 -m pip install semgrep -
Verify that you've installed the latest version of Semgrep by running the following:
semgrep --version -
Sign in to your Semgrep account. Running this command launches a browser window, but you can also use the link that's returned in the CLI to proceed:
semgrep loginIn the Semgrep CLI login, click Activate to proceed.
-
Return to the CLI, and install the Semgrep Pro engine:
semgrep install-semgrep-pro -
Add the Semgrep MCP Server to your IDE. Semgrep provides sample configuration information that you can use as a starting point for your configuration. Refer to your IDE's documentation for specific details on where to add the MCP server configuration information.
Scan your code
- Open up your IDE's AI chat window.
- Ensure that you're in the correct context to use Semgrep.
- Prompt your IDE to scan with Semgrep.
By default, the MCP Server runs all three Semgrep products: Code, Supply Chain, and Secrets.
Additional resources
- Semgrep's
#mcpSlack community - The Semgrep MCP server repo on GitHub
Not finding what you need in this doc? Ask questions in our Community Slack group, or see Support for other ways to get help.