This MCP Server Semgrep tool integrates Semgrep static analysis capabilities with AI assistants like Claude, enabling code analysis, security vulnerability detection, and quality improvements through a conversational interface. It scans entire projects to identify potential issues, security vulnerabilities, and style inconsistencies.
# Using npm
npm install -g mcp-server-semgrep
# Using pnpm
pnpm add -g mcp-server-semgrep
# Using yarn
yarn global add mcp-server-semgrep
# Using npm
npm install -g git+https://github.com/Szowesgad/mcp-server-semgrep.git
# Using pnpm
pnpm add -g git+https://github.com/Szowesgad/mcp-server-semgrep.git
# Using yarn
yarn global add git+https://github.com/Szowesgad/mcp-server-semgrep.git
git clone https://github.com/Szowesgad/mcp-server-semgrep.git
cd mcp-server-semgrep
# Using pnpm (recommended)
pnpm install
# Using npm
npm install
# Using yarn
yarn install
# Using pnpm
pnpm run build
# Using npm
npm run build
# Using yarn
yarn build
The installation process automatically checks for Semgrep. If not found, you can install it using:
# Using pnpm
pnpm add -g semgrep
# Using npm
npm install -g semgrep
# Using yarn
yarn global add semgrep
# Using pip
pip install semgrep
# On macOS
brew install semgrep
# On Linux
curl -sSL https://install.semgrep.dev | sh
claude_desktop_config.json
):{
"mcpServers": {
"semgrep": {
"command": "node",
"args": [
"/your_path/mcp-server-semgrep/build/index.js"
],
"env": {
"SEMGREP_APP_TOKEN": "your_semgrep_app_token"
}
}
}
}
Could you scan my source code in the /projects/my-application directory for potential security issues?
Analyze the z-index values in the project's CSS files and identify inconsistencies and potential layer conflicts.
Create a Semgrep rule that detects improper use of input sanitization functions.
rules:
- id: inconsistent-z-index
pattern: z-index: $Z
message: "Z-index $Z may not comply with the project's layering system"
languages: [css, scss]
severity: WARNING
rules:
- id: deprecated-import
pattern: import $X from 'old-library'
message: "You're using a deprecated library. Consider using 'new-library'"
languages: [javascript, typescript]
severity: WARNING
Show me only scan results related to SQL injection vulnerabilities.
Find all "magic numbers" in the code and suggest replacing them with named constants.
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "semgrep" '{"command":"node","args":["/your_path/mcp-server-semgrep/build/index.js"],"env":{"SEMGREP_APP_TOKEN":"your_semgrep_app_token"}}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"semgrep": {
"command": "node",
"args": [
"/your_path/mcp-server-semgrep/build/index.js"
],
"env": {
"SEMGREP_APP_TOKEN": "your_semgrep_app_token"
}
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"semgrep": {
"command": "node",
"args": [
"/your_path/mcp-server-semgrep/build/index.js"
],
"env": {
"SEMGREP_APP_TOKEN": "your_semgrep_app_token"
}
}
}
}
3. Restart Claude Desktop for the changes to take effect