Integrate semgrep-mcp with Claude Code
mainUse the following command to add the Semgrep MCP server to Claude Code:
claude mcp add semgrep uvx semgrep-mcprepository·main·Indexed 20 days ago
https://github.com/semgrep/mcpA Model Context Protocol (MCP) server implementation that enables LLMs, Agents, and IDEs (such as Cursor and VS Code) to use Semgrep for automated security scanning and code analysis. It provides tools for scanning code, retrieving Abstract Syntax Trees (AST), and fetching findings from the Semgrep AppSec Platform. Supports multiple transport protocols including stdio, streamable-http, and SSE.
Use the following command to add the Semgrep MCP server to Claude Code:
claude mcp add semgrep uvx semgrep-mcpDeploy the semgrep-mcp server using Helm. This chart uses the semgrep/mcp:main Docker image by default.
Run the following command to install the chart locally:
helm install my-semgrep-mcp ./chart/semgrep-mcphelm install my-semgrep-mcp ./chart/semgrep-mcpTo connect Semgrep to ChatGPT via the hosted SSE server:
Semgrep.https://mcp.semgrep.ai/sse.No authentication.Add the following configuration to your ~/.cursor/mcp.json (global) or .cursor/mcp.json (project-specific) file to use uvx to run the server.
{
"mcpServers": {
"semgrep": {
"command": "uvx",
"args": ["semgrep-mcp"]
}
}
}The server is available as a Docker image on GitHub Container Registry (ghcr.io/semgrep/mcp).
-i (interactive) and specify -t stdio because the default container mode is SSE.-t streamable-http flag.-t sse flag.# Run in stdio mode
docker run -i --rm ghcr.io/semgrep/mcp -t stdio
# Run in Streamable HTTP mode
docker run -p 8000:8000 ghcr.io/semgrep/mcp -t streamable-http
# Run in SSE mode
docker run -p 8000:8000 ghcr.io/semgrep/mcp -t sseTo use Semgrep in Cursor, add the server to your mcp.json configuration. If you are using the local uvx method, you may need to provide a SEMGREP_APP_TOKEN in the environment variables.
Alternatively, you can use the Hosted Server (experimental) by adding a new MCP server in Cursor Settings (Cmd + Shift + J) with the type streamable-http and the URL https://mcp.semgrep.ai/mcp.
{
"mcpServers": {
"semgrep": {
"command": "uvx",
"args": ["semgrep-mcp"],
"env": {
"SEMGREP_APP_TOKEN": "<token>"
}
}
}
}The Semgrep MCP server can be run locally using uvx or via a Docker container.
Using uvx:
uvx semgrep-mcp # see --help for more optionsUsing Docker:
docker run -i --rm ghcr.io/semgrep/mcp -t stdioNote: This repository is deprecated. Further updates will be made via the official semgrep binary in the main semgrep repository.
uvx semgrep-mcpThe semgrep-mcp package is available on PyPI and can be installed using standard Python package managers like pipx, uv, or poetry. To install it globally using pipx:
$ pipx install semgrep-mcpAdd the following configuration to your claude_desktop_config.json file.
{
"mcpServers": {
"semgrep": {
"command": "uvx",
"args": ["semgrep-mcp"]
}
}
}Add the following block to your ~/.codeium/windsurf/mcp_config.json file.
{
"mcpServers": {
"semgrep": {
"command": "uvx",
"args": ["semgrep-mcp"]
}
}
}To use the server in VS Code, add the configuration to your User Settings (JSON) or a workspace-specific .vscode/mcp.json file.
Using uvx:
{
"mcp": {
"servers": {
"semgrep": {
"command": "uvx",
"args": ["semgrep-mcp"]
}
}
}
}Using Docker:
{
"mcp": {
"servers": {
"semgrep": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"ghcr.io/semgrep/mcp",
"-t",
"stdio"
]
}
}
}
}To use the Semgrep AppSec Platform features, you must provide an API token generated from your Semgrep organization settings. Use the environment variable SEMGREP_APP_TOKEN.
Methods to provide the token:
export SEMGREP_APP_TOKEN=<token>docker run -e SEMGREP_APP_TOKEN=<token> ..."env": {
"SEMGREP_APP_TOKEN": "<token>"
}"env": {
"SEMGREP_APP_TOKEN": "<token>"
}