Gene Library Courses Download Pricing Contact Sign in
semgrep logo
developer-tools Official Website

Semgrep MCP Server – AI Code Security Scans

Semgrep's official MCP server lets AI coding assistants run deterministic code security checks with Semgrep. Use it to scan generated or existing code, run custom Semgrep rules, inspect syntax trees, retrieve rule schema resources, and fetch Semgrep AppSec Platform findings when authenticated.

#security#static-analysis#sast

Overview

Semgrep MCP connects AI coding assistants to Semgrep's static analysis engine.
It gives agents a security-aware toolset for checking code during development,
especially when an assistant is generating, modifying, or reviewing code in an
IDE or chat-based coding workflow.

What the MCP server enables

The official server exposes tools for code scanning, code understanding, and
Semgrep metadata:

  • security_check scans code for security vulnerabilities.
  • semgrep_scan scans code files using a given Semgrep config string.
  • semgrep_scan_with_custom_rule scans code with a custom Semgrep rule.
  • get_abstract_syntax_tree returns the AST for code being inspected.
  • semgrep_findings fetches findings from the Semgrep AppSec Platform when
    the user is logged in and has a Semgrep token.
  • supported_languages returns the languages Semgrep supports.
  • semgrep_rule_schema fetches the latest Semgrep rule JSON schema.
  • The server also exposes resources for the Semgrep rule schema and rule YAML
    from the Semgrep registry, plus a prompt for writing custom Semgrep rules.

When to use it

Use Semgrep MCP when an AI agent needs to validate code for security before a
user accepts changes. Practical examples include scanning newly generated code
for injection flaws, checking a patch before committing it, writing and testing
a custom Semgrep rule, inspecting AST output to understand a pattern, retrieving
supported language information, or using Semgrep AppSec Platform findings as
context for remediation.

Connection and authentication

Local stdio can be run with the official Semgrep MCP command. Semgrep's current
documentation also shows use through the official Semgrep binary, while the
archived standalone repository documents the older uvx semgrep-mcp package
and Docker image. For hosted use, Semgrep documents an experimental server at
https://mcp.semgrep.ai/mcp for Streamable HTTP and
https://mcp.semgrep.ai/sse for SSE. ChatGPT connector setup is documented
with no authentication for the hosted SSE endpoint.

Cloud Platform tools require a Semgrep login and token, commonly supplied as
SEMGREP_APP_TOKEN in local client configuration.

Key considerations

The hosted mcp.semgrep.ai server is documented as experimental and may change
unexpectedly. The older semgrep/mcp repository is archived; prefer the
current Semgrep documentation and official Semgrep binary for new work. SSE is
documented as a legacy transport, with Streamable HTTP recommended as the
replacement where supported. Local scans inspect submitted code files, and
AppSec Platform access depends on token permissions. Treat scan results and
AI-generated remediation as review inputs: run tests, review code changes, and
confirm that security findings are fixed before merging or deploying.

Supported Transports

streamable_http

URL: https://mcp.semgrep.ai/mcp

sse

URL: https://mcp.semgrep.ai/sse

stdio

Command: semgrep

Args:

  • mcp

stdio

Command: uvx

Args:

  • semgrep-mcp

streamable_http

URL: http://127.0.0.1:8000/mcp

sse

URL: http://127.0.0.1:8000/sse

Frequently Asked Questions

When should an AI agent use the Semgrep MCP server?
Use it when an AI coding assistant needs to scan generated or modified code for security issues, test a custom Semgrep rule, inspect AST output, check supported languages, or use Semgrep AppSec Platform findings as context for remediation.
What does the Semgrep MCP server add to an AI agent's capabilities?
It gives the agent deterministic Semgrep scanning and rule tooling through MCP, including security checks, Semgrep config scans, custom-rule scans, AST output, supported-language lookup, rule schema resources, and optional AppSec Platform findings.
What can an AI agent access or manage through Semgrep MCP?
The agent can scan code supplied to the MCP server, run custom Semgrep rules, inspect syntax trees, fetch rule schema and rule resources, list supported languages, and retrieve Semgrep AppSec Platform findings when the user is authenticated and has a valid token.
How is authentication configured for Semgrep MCP?
Hosted ChatGPT connector setup is documented with no authentication for the experimental SSE endpoint. Local Semgrep AppSec Platform access requires a Semgrep login and token, commonly supplied as SEMGREP_APP_TOKEN. Store the token securely and grant only the access needed for findings workflows.
Which transport should be used for Semgrep MCP?
Use hosted Streamable HTTP at https://mcp.semgrep.ai/mcp when the client supports it. Use hosted SSE at https://mcp.semgrep.ai/sse for clients that require SSE. For local workflows, use stdio through the Semgrep MCP command; local Streamable HTTP or local SSE require the server to be started first, and SSE is considered legacy.