Purpose
Semgrep MCP Server is a Model Context Protocol (MCP) server used to scan code for security vulnerabilities using Semgrep. MCP is a standardized API for LLMs, Agents, and MCP-supporting IDEs such as Cursor, VS Code, and Windsurf, enabling them to obtain specialized assistance, context, and invoke tool capabilities. Semgrep is a fast, deterministic static analysis tool that can semantically understand multiple languages and comes with over 5,000 built-in rules.
Main Capabilities
The server provides the following Tools:
- security_check: Scan code for security vulnerabilities
- semgrep_scan: Scan code files for security vulnerabilities using a specified configuration string
- semgrep_scan_with_custom_rule: Scan code files using a custom Semgrep rule
- get_abstract_syntax_tree: Output the abstract syntax tree (AST) of code
- semgrep_findings: Retrieve Semgrep findings from the Semgrep AppSec Platform API
- supported_languages: Return the list of languages supported by Semgrep
- semgrep_rule_schema: Retrieve the latest semgrep rule JSON Schema
It also provides Meta Prompts (reusable prompts used to standardize common LLM interactions):
- write_custom_semgrep_rule: Return a prompt that helps write Semgrep rules
And Resources (expose data and content to LLMs):
- semgrep://rule/schema: Describe the Semgrep rule YAML syntax using JSON schema
- semgrep://rule/{rule_id}/yaml: Retrieve the full Semgrep rule in YAML format from the Semgrep registry
Usage
This Python package is published to PyPI under the name semgrep-mcp and can be installed and run via pip, pipx, uv, poetry, or any Python package manager.
Multiple transport methods are supported:
- Standard input/output (stdio): The default mode, suitable for local integration and command-line tools.
- Streamable HTTP: Streams responses as JSON RPC via HTTP POST requests, listening by default on 127.0.0.1:8000/mcp, modifiable via FASTMCP_* environment variables.
- Server-sent events (SSE): Considered a legacy transport protocol by the MCP community, mainly used for backward compatibility; Streamable HTTP is recommended instead. Listens by default on 127.0.0.1:8000/sse.
The Docker container is published at ghcr.io/semgrep/mcp and runs in SSE mode by default. For stdio mode, add -t stdio after the image name and run in interactive mode with -i.
Integration methods include: Cursor IDE, VS Code / Copilot, Windsurf, Claude Desktop, Claude Code, OpenAI Agents SDK, and custom clients.
To connect to the Semgrep AppSec Platform, you need to log in or register, generate a token from Settings, and add the token to an environment variable (for CLI use export SEMGREP_APP_TOKEN=<token>, for Docker use docker run -e SEMGREP_APP_TOKEN=<token>, or write it into the MCP configuration JSON).
Applicable Scenarios
Suitable for developers who want to integrate code security scanning capabilities into AI coding assistants or IDEs. It can automatically check for security vulnerabilities during code writing (vibe coding), and can also be used to obtain code AST, query the Semgrep rule schema, pull findings from the Semgrep AppSec Platform, and more.
Limitations and Status
This repository has been deprecated. Semgrep MCP Server has been migrated from a standalone repository to the main Semgrep repository, and subsequent updates will be released through the official semgrep binary. This project is in beta and under active development. mcp.semgrep.ai is an experimental server that may be interrupted unexpectedly, but new features will be added quickly. SSE transport is considered a legacy protocol by the MCP community, and Streamable HTTP is recommended.