mcp

A MCP server for using Semgrep to scan code for security vulnerabilities.

GitHub Stars

529

User Rating

Not Rated

Favorites

0

Views

20

Forks

49

Issues

34

Installation
Difficulty
Intermediate
Estimated Time
10-20 minutes
Requirements
Python 3.7 or higher
Semgrep latest version

Installation

Installation

Prerequisites

Please specify required software and versions:
Python: 3.7 or higher
Semgrep: Latest version

Installation Steps

1. Clone Repository

bash
git clone https://github.com/semgrep/mcp.git
cd mcp

2. Install Dependencies

bash
pip install -r requirements.txt

3. Start Server

bash
python server.py

Troubleshooting

Common Issues

Issue: Server won't start Solution: Check Python version and reinstall dependencies. Issue: Semgrep not found Solution: Ensure Semgrep is installed correctly.

Configuration

Configuration

Basic Configuration

Semgrep Setup

Edit ~/.semgrep/config.yml to add the MCP server:
yaml
mcp:
  command: python
  args: ["server.py"]

Environment Variables

Set the following environment variables as needed:
bash
export SEMGREP_API_KEY="your-api-key"

Configuration Example

yaml
mcp:
  command: python
  args: ["server.py"]
  env:
    SEMGREP_API_KEY: "your-api-key"

Examples

Examples

Basic Usage

Here are basic usage examples for the MCP server:

Programmatic Usage

python
import requests

response = requests.get('http://localhost:8000/scan', params={
    'code': 'sample code'
})
print(response.json())

Running a Security Scan

bash
python mcp.py --scan /path/to/code

Use Cases

Automatically detect vulnerabilities during code reviews.
Integrate into CI/CD pipelines to perform security checks before deployment.
Ensure compatibility with existing code when adding new code.
Continuously monitor the security of applications under development.