Skip to main content

Semgrep MCP Server (beta)

Semgrep's open source Model Context Protocol (MCP) server scans AI-generated code for security vulnerabilities using Semgrep Code, Supply Chain, and Secrets. The IDE re-generates code until Semgrep returns no findings or the user prompts the IDE to ignore Semgrep's findings.

This article includes instructions for setting up the MCP server with Cursor and Claude Code, but it also works with any IDE-based MCP client.

Prerequisites

  • Python 3.10 or later
  • Homebrew or Pip to install Semgrep
  • A Semgrep account

Installation

  1. Install Semgrep:

    # install through homebrew
    brew install semgrep

    # install through pip
    python3 -m pip install semgrep
  2. Verify that you've installed the latest version of Semgrep by running the following:

    semgrep --version
  3. Add Semgrep to Cursor. Review the prefilled information and click Install to proceed.

  4. Open Cursor's AI Pane window and run /semgrep/setup_semgrep_mcp to begin the initial setup process. Follow the on-screen prompts and run the suggested commands. When done, you'll see a confirmation message that begins with Semgrep MCP setup complete.

Scan your code

  1. Open up your IDE's AI chat window.
  2. Ensure that you're in the correct context to use Semgrep.
  3. Prompt your IDE to scan with Semgrep.

By default, the MCP Server runs all three Semgrep products: Code, Supply Chain, and Secrets.

Additional resources


Not finding what you need in this doc? Ask questions in our Community Slack group, or see Support for other ways to get help.