### Install and Get Help for Semgrep MCP Source: https://github.com/semgrep/mcp/blob/main/README.md Install the package using pipx and view the command-line help for available options. ```bash $ pipx install semgrep-mcp $ semgrep-mcp --help ``` -------------------------------- ### Run Development Server Source: https://github.com/semgrep/mcp/blob/main/CONTRIBUTING.md Starts the MCP server in development mode using `uv`. This mode is optimized for local development and debugging. ```bash uv run mcp dev ./src/semgrep_mcp/server.py ``` -------------------------------- ### Install Semgrep CLI Source: https://github.com/semgrep/mcp/blob/main/CONTRIBUTING.md Installs the Semgrep CLI tool. Ensure Python 3.13+ is installed and the repository is cloned. ```bash pip install semgrep ``` -------------------------------- ### OpenAI Agents SDK MCPServerStdio Initialization Source: https://github.com/semgrep/mcp/blob/main/README.md Example of initializing MCPServerStdio with Semgrep MCP server parameters using the OpenAI Agents SDK. ```python async with MCPServerStdio( params={ "command": "uvx", "args": ["semgrep-mcp"], } ) as server: tools = await server.list_tools() ``` -------------------------------- ### Install semgrep-mcp Helm Chart Source: https://github.com/semgrep/mcp/blob/main/chart/semgrep-mcp/README.md Use this command to install the semgrep-mcp Helm chart in your cluster. ```sh helm install my-semgrep-mcp ./chart/semgrep-mcp ``` -------------------------------- ### Run MCP Server (STDIO Mode - CLI) Source: https://github.com/semgrep/mcp/blob/main/CONTRIBUTING.md Starts the MCP server in STDIO mode using the CLI. This is useful for integrating with other tools that communicate via standard input/output. ```bash uv run mcp run ./src/semgrep_mcp/server.py -t stdio ``` -------------------------------- ### Configure SEMGREP_APP_TOKEN in values.yaml Source: https://github.com/semgrep/mcp/blob/main/chart/semgrep-mcp/README.md Example of how to set the SEMGREP_APP_TOKEN environment variable in your values.yaml file for the semgrep-mcp Helm chart. ```yaml env: - name: SEMGREP_APP_TOKEN value: "your-token-here" ``` -------------------------------- ### Cursor MCP Server Configuration Source: https://github.com/semgrep/mcp/blob/main/README.md Example mcp.json configuration for Cursor IDE to connect to a Semgrep MCP server. Requires a Semgrep App Token. ```json { "mcpServers": { "semgrep": { "command": "uvx", "args": ["semgrep-mcp"], "env": { "SEMGREP_APP_TOKEN": "" } } } } ``` -------------------------------- ### Run Semgrep MCP with Streamable HTTP Transport Source: https://github.com/semgrep/mcp/blob/main/README.md Start the semgrep-mcp server using the streamable-http transport. This is the recommended transport for client connections. ```bash semgrep-mcp -t streamable-http ``` -------------------------------- ### Build MCP Docker Image Source: https://github.com/semgrep/mcp/blob/main/CONTRIBUTING.md Builds the Docker image for the MCP server. Requires Docker to be installed and Semgrep API token configured. ```bash make docker ``` -------------------------------- ### Run MCP Server (SSE Mode - CLI) Source: https://github.com/semgrep/mcp/blob/main/CONTRIBUTING.md Starts the MCP server in SSE (Server-Sent Events) mode using the CLI. This mode is suitable for real-time updates and notifications. ```bash uv run mcp run ./src/semgrep_mcp/server.py -t sse ``` -------------------------------- ### Custom Python SSE Client for MCP Source: https://github.com/semgrep/mcp/blob/main/README.md An example of a custom Python SSE client that connects to an MCP server and calls a tool. Ensure the server is running and accessible at the specified URL. ```python from mcp.client.session import ClientSession from mcp.client.sse import sse_client async def main(): async with sse_client("http://localhost:8000/sse") as (read_stream, write_stream): async with ClientSession(read_stream, write_stream) as session: await session.initialize() results = await session.call_tool( "semgrep_scan", { "code_files": [ { "path": "hello_world.py", "content": "def hello(): print('Hello, World!')", } ] }, ) print(results) ``` -------------------------------- ### Cursor IDE Rule for Semgrep Source: https://github.com/semgrep/mcp/blob/main/README.md An example instruction to add to Cursor IDE's .cursor/rules to automatically scan generated code with Semgrep for security vulnerabilities. ```text Always scan code generated using Semgrep for security vulnerabilities ``` -------------------------------- ### Increase Inspector Server Timeout Source: https://github.com/semgrep/mcp/blob/main/CONTRIBUTING.md Example URL to access the inspector server with an increased timeout parameter. Adjust the `timeout` value as needed. ```http http://localhost:6274/?timeout=300000 ``` -------------------------------- ### Run Semgrep MCP CLI with uvx Source: https://github.com/semgrep/mcp/blob/main/README.md Execute the Semgrep MCP package as a command-line tool using uvx. Use --help for more options. ```bash uvx semgrep-mcp # see --help for more options ``` -------------------------------- ### Workspace .vscode/mcp.json Configuration Source: https://github.com/semgrep/mcp/blob/main/README.md Optionally, configure the Semgrep MCP server by adding this JSON block to a `.vscode/mcp.json` file in your workspace. ```json { "servers": { "semgrep": { "command": "uvx", "args": ["semgrep-mcp"] } } } ``` -------------------------------- ### Prompts Source: https://github.com/semgrep/mcp/blob/main/README.md Reusable prompts to standardize common LLM interactions. ```APIDOC ## Prompts Reusable prompts to standardize common LLM interactions. - `write_custom_semgrep_rule`: Return a prompt to help write a Semgrep rule ``` -------------------------------- ### Execute MCP Server Script Source: https://github.com/semgrep/mcp/blob/main/CONTRIBUTING.md Makes the server script executable and displays its help message. Useful for understanding available command-line arguments. ```bash chmod +x ./src/semgrep_mcp/server.py ./src/semgrep_mcp/server.py --help ``` -------------------------------- ### Tools Source: https://github.com/semgrep/mcp/blob/main/README.md Enable LLMs to perform actions, make deterministic computations, and interact with external services. ```APIDOC ## Tools Enable LLMs to perform actions, make deterministic computations, and interact with external services. ### Scan Code - `security_check`: Scan code for security vulnerabilities - `semgrep_scan`: Scan code files for security vulnerabilities with a given config string - `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 (login and Semgrep token required) - `semgrep_findings`: Fetch Semgrep findings from the Semgrep AppSec Platform API ### Meta - `supported_languages`: Return the list of languages Semgrep supports - `semgrep_rule_schema`: Fetches the latest semgrep rule JSON Schema ``` -------------------------------- ### Cursor MCP Server Configuration (Streamable HTTP) Source: https://github.com/semgrep/mcp/blob/main/README.md Configuration for Cursor IDE to connect to the Semgrep hosted server using streamable HTTP. This is an experimental server. ```json { "mcpServers": { "semgrep": { "type": "streamable-http", "url": "https://mcp.semgrep.ai/mcp" } } } ``` -------------------------------- ### Run MCP Server (STDIO Mode - Docker) Source: https://github.com/semgrep/mcp/blob/main/CONTRIBUTING.md Runs the MCP server in STDIO mode using Docker. This provides an isolated environment for the server. ```bash docker run -i --rm semgrep-mcp -t stdio ``` -------------------------------- ### Run Semgrep MCP with Docker Source: https://github.com/semgrep/mcp/blob/main/README.md Execute the Semgrep MCP package as a Docker container. Use the -t stdio flag for standard input/output. ```bash docker run -i --rm ghcr.io/semgrep/mcp -t stdio ``` -------------------------------- ### Docker MCP Server Configuration Source: https://github.com/semgrep/mcp/blob/main/README.md Configure the Semgrep MCP server to run using Docker. This JSON block specifies the Docker image and command to execute. ```json { "mcp": { "servers": { "semgrep": { "command": "docker", "args": [ "run", "-i", "--rm", "ghcr.io/semgrep/mcp", "-t", "stdio" ] } } } } ``` -------------------------------- ### Resources Source: https://github.com/semgrep/mcp/blob/main/README.md Expose data and content to LLMs. ```APIDOC ## Resources Expose data and content to LLMs - `semgrep://rule/schema`: Specification of the Semgrep rule YAML syntax using JSON schema - `semgrep://rule/{rule_id}/yaml`: Full Semgrep rule in YAML format from the Semgrep registry ``` -------------------------------- ### Run Semgrep MCP with Stdio Transport Source: https://github.com/semgrep/mcp/blob/main/README.md Execute the semgrep-mcp server using the stdio transport. This is the default mode and suitable for local integrations. The tool may appear to hang as it reads from stdin and writes to stdout. ```bash semgrep-mcp ``` -------------------------------- ### Configure Semgrep MCP for Cursor IDE Source: https://github.com/semgrep/mcp/blob/main/README.md Add this JSON configuration to your Cursor IDE's mcp.json file to integrate with semgrep-mcp. ```json { "mcpServers": { "semgrep": { "command": "uvx", "args": ["semgrep-mcp"] } } } ``` -------------------------------- ### Configure Semgrep AppSec Platform Token Source: https://github.com/semgrep/mcp/blob/main/README.md Set the SEMGREP_APP_TOKEN environment variable for connecting to Semgrep AppSec Platform. This can be done via CLI, Docker, or MCP config JSON. ```bash export SEMGREP_APP_TOKEN= ``` ```bash docker run -e SEMGREP_APP_TOKEN= ``` ```json "env": { "SEMGREP_APP_TOKEN": "" } ``` -------------------------------- ### Push Git Tag Source: https://github.com/semgrep/mcp/blob/main/CONTRIBUTING.md Pushes a Git tag to the origin repository. Replace `vX.Y.Z` with the actual version tag. ```bash git push origin vX.Y.Z ``` -------------------------------- ### Run MCP Server (SSE Mode - Docker) Source: https://github.com/semgrep/mcp/blob/main/CONTRIBUTING.md Runs the MCP server in SSE mode using Docker, exposing port 8000 for communication. This is suitable for applications requiring real-time analysis. ```bash docker run -p 8000:8000 semgrep-mcp ``` -------------------------------- ### Run Semgrep MCP Docker with Streamable HTTP Transport Source: https://github.com/semgrep/mcp/blob/main/README.md Deploy the semgrep-mcp server using Docker with the streamable-http transport. The server will listen on port 8000. ```bash docker run -p 8000:0000 ghcr.io/semgrep/mcp ``` -------------------------------- ### Run Semgrep MCP Docker with SSE Transport Source: https://github.com/semgrep/mcp/blob/main/README.md Deploy the semgrep-mcp server using Docker with the SSE transport. The server will listen on port 8000. ```bash docker run -p 8000:0000 ghcr.io/semgrep/mcp -t sse ``` -------------------------------- ### Bump Version Script Source: https://github.com/semgrep/mcp/blob/main/CONTRIBUTING.md Executes a script to bump the project version. It accepts 'patch', 'minor', or 'major' as an argument, defaulting to 'minor'. ```bash # takes one argument {patch, minor, major} with 'minor' as the default argument uv run python ./scripts/bump_version.py ``` -------------------------------- ### VS Code User Settings JSON Configuration Source: https://github.com/semgrep/mcp/blob/main/README.md Add this JSON block to your VS Code User Settings (JSON) file for manual configuration of the Semgrep MCP server. ```json { "mcp": { "servers": { "semgrep": { "command": "uvx", "args": ["semgrep-mcp"] } } } } ``` -------------------------------- ### Run Semgrep MCP with SSE Transport Source: https://github.com/semgrep/mcp/blob/main/README.md Execute the semgrep-mcp server using the SSE (Server-Sent Events) transport. This is a legacy transport protocol. ```bash semgrep-mcp -t sse ``` -------------------------------- ### Claude Code MCP Add Command Source: https://github.com/semgrep/mcp/blob/main/README.md Use this bash command to add the Semgrep MCP server to Claude Code. ```bash claude mcp add semgrep uvx semgrep-mcp ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.