Semgrep MCP server

Integrates with Semgrep's static analysis engine to scan code for security vulnerabilities and coding issues, enabling developers to identify and fix potential problems directly within their coding workflow.
Back to servers
Setup instructions
Provider
Semgrep
Release date
Feb 02, 2025
Language
Python
Stats
220 stars

Semgrep MCP Server provides a Model Context Protocol interface that lets LLMs and AI assistants leverage Semgrep's powerful static analysis capabilities to scan code for security vulnerabilities. This server allows AI tools like Cursor, VS Code, and ChatGPT to identify potential security issues in your code through the standardized MCP API.

Installation Options

Using Python Package

The simplest way to install and run the Semgrep MCP server is with Python's package manager:

uvx semgrep-mcp

Using Docker

Alternatively, you can run it as a Docker container:

docker run -i --rm ghcr.io/semgrep/mcp -t stdio

Transport Methods

Standard Input/Output (stdio)

For local integrations and command-line tools:

semgrep-mcp

By default, the Python package runs in stdio mode, which may appear to be hanging without output (this is expected behavior).

Streamable HTTP

For HTTP-based streaming responses:

semgrep-mcp -t streamable-http

This starts a server listening on 127.0.0.1:8000/mcp for client connections.

Server-sent Events (SSE)

For server-to-client streaming (legacy transport):

semgrep-mcp -t sse

This starts a server listening on 127.0.0.1:8000/sse for client connections.

Integration with IDEs and Tools

Cursor IDE

Add to your ~/.cursor/mcp.json or .cursor/mcp.json file:

{
  "mcpServers": {
    "semgrep": {
      "command": "uvx",
      "args": ["semgrep-mcp"]
    }
  }
}

VS Code / Copilot

Add to your VS Code User Settings (JSON):

{
  "mcp": {
    "servers": {
      "semgrep": {
        "command": "uvx",
        "args": ["semgrep-mcp"]
      }
    }
  }
}

ChatGPT

  1. Go to the Connector Settings page
  2. Name the connection "Semgrep"
  3. Set MCP Server URL to https://mcp.semgrep.ai/sse
  4. Set Authentication to "No authentication"
  5. Check the "I trust this application" checkbox
  6. Click "Create"

Semgrep AppSec Platform Integration

To connect to the Semgrep AppSec Platform:

  1. Login or sign up at semgrep.dev
  2. Generate a token from Settings
  3. Add the token to your environment:
export SEMGREP_APP_TOKEN=<token>

Or in your MCP config JSON:

"env": {
  "SEMGREP_APP_TOKEN": "<token>"
}

Available Tools

Scan Code

  • security_check: Scan code for security vulnerabilities
  • semgrep_scan: Scan code files for security vulnerabilities with a given config
  • semgrep_scan_with_custom_rule: Scan code files using a custom Semgrep rule

Understand Code

  • get_abstract_syntax_tree: Output the Abstract Syntax Tree (AST) of code

Cloud Platform Features

  • semgrep_findings: Fetch Semgrep findings from the Semgrep AppSec Platform API (requires token)

Meta Tools

  • supported_languages: Return the list of languages Semgrep supports
  • semgrep_rule_schema: Fetches the latest semgrep rule JSON Schema

Prompts and Resources

The server also provides:

  • Reusable prompts for writing custom Semgrep rules
  • Resource endpoints for accessing rule schemas and registry rules

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "semgrep" '{"command":"uvx","args":["semgrep-mcp"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "semgrep": {
            "command": "uvx",
            "args": [
                "semgrep-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "semgrep": {
            "command": "uvx",
            "args": [
                "semgrep-mcp"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later