Szowesgad mcp server semgrep
by Szowesgad
MCP Server Semgrep is a [Model Context Protocol](https://modelcontextprotocol.io) compliant server that integrates the powerful Semgrep static analysis tool with AI assistants like Anthropic Claude. It enables advanced code analysis, security vulnerability detection, and code quality improvements directly through a conversational interface.
What is Szowesgad mcp server semgrep
MCP Server Semgrep
POWERED BY:
About the Project
This project was initially inspired by robustness of Semgrep tool, The Replit Team and their Agent V2, as well as the implementation by stefanskiasan/semgrep-mcp-server, but has evolved with significant architectural changes for enhanced and easier installation and maintenance.
MCP Server Semgrep is a Model Context Protocol compliant server that integrates the powerful Semgrep static analysis tool with AI assistants like Anthropic Claude. It enables advanced code analysis, security vulnerability detection, and code quality improvements directly through a conversational interface.
Benefits of Integration
For Developers and Development Teams:
- Holistic Source Code Analysis - detecting issues throughout the entire project, not just in individual files
- Proactive Error Detection - identifying potential problems before they become critical bugs
- Continuous Code Quality Improvement - regular scanning and refactoring lead to gradual codebase improvements
- Stylistic Consistency - identification and fixing of inconsistencies in code, such as:
- Arbitrary z-index layers in CSS
- Inconsistent naming conventions
- Code duplication
- "Magic numbers" instead of named constants
For Security:
- Automated Code Verification for Known Vulnerabilities - scanning for known security issue patterns
- Customized Security Rules - creating project-specific rules
- Team Education - teaching secure programming practices through detection of potential issues
For Project Maintenance and Development:
- "Live" Documentation - AI can explain why a code fragment is problematic and how to fix it
- Technical Debt Reduction - systematically detecting and fixing problematic areas
- Improved Code Reviews - automatic detection of common issues allows focus on more complex matters
Key Features
- Direct integration with the official MCP SDK
- Simplified architecture with consolidated handlers
- Clean ES Modules implementation
- Efficient error handling and path validation for security
- Interface and documentation in both English and Polish
- Comprehensive unit tests
- Extensive documentation
- Cross-platform compatibility (Windows, macOS, Linux)
- Flexible Semgrep installation detection and management
Functions
Semgrep MCP Server provides the following tools:
- scan_directory: Scanning source code for potential issues
- list_rules: Displaying available rules and languages supported by Semgrep
- analyze_results: Detailed analysis of scan results
- create_rule: Creating custom Semgrep rules
- filter_results: Filtering results by various criteria
- export_results: Exporting results in various formats
- compare_results: Comparing two sets of results (e.g., before and after changes)
Common Use Cases
- Code security analysis before deployment
- Detection of common programming errors
- Enforcing coding standards within a team
- Refactoring and improving quality of existing code
- Identifying inconsistencies in styles and code structure (e.g., CSS, component organization)
- Developer education regarding best practices
- Verification of fix correctness (comparing before/after scans)
Installation
Prerequisites
- Node.js v18+
- TypeScript (for development)
Option 1: Install from Smithery.ai (Recommended)
The easiest way to install and use MCP Server Semgrep is through Smithery.ai:
- Visit MCP Server Semgrep on Smithery.ai
- Follow the installation instructions to add it to your MCP-compatible clients
- Configure any optional settings like the Semgrep API token
This is the recommended method for Claude Desktop and other MCP clients as it handles all dependencies and configuration automatically.
Option 2: Install from NPM Registry
# Using npm
npm install -g mcp-server-semgrep
# Using pnpm
pnpm add -g mcp-server-semgrep
# Using yarn
yarn global add mcp-server-semgrep
The package is also available on other registries:
Option 3: Install from GitHub
# 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
Option 4: Local Development Setup
- Clone the repository:
git clone https://github.com/Szowesgad/mcp-server-semgrep.git
cd mcp-server-semgrep
- Install dependencies (supports all major package managers):
# Using pnpm (recommended)
pnpm install
# Using npm
npm install
# Using yarn
yarn install
- Build the project:
# Using pnpm
pnpm run build
# Using npm
npm run build
# Using yarn
yarn build
Note: The installation process will automatically check for Semgrep availability. If Semgrep is not found, you'll receive instructions on how to install it.
Semgrep Installation Options
Semgrep can be installed in several ways:
-
Via package managers:
# Using pnpm pnpm add -g semgrep # Using npm npm install -g semgrep # Using yarn yarn global add semgrep
-
Python pip:
pip install semgrep
-
Homebrew (macOS):
brew install semgrep
-
Linux:
sudo apt-get install semgrep # or curl -sSL https://install.semgrep.dev | sh
-
Windows:
pip install semgrep
Integration with Claude Desktop
There are two ways to integrate MCP Server Semgrep with Claude Desktop:
Method 1: Install via Smithery.ai (Recommended)
- Visit MCP Server Semgrep on Smithery.ai
- Click "Install in Claude Desktop"
- Follow the on-screen instructions
Method 2: Manual Configuration
- Install Claude Desktop
- Update the Claude Desktop configuration file (
claude_desktop_config.json
) and add this to your servers section:
{
"mcpServers": {
"semgrep": {
"command": "node",
"args": [
"/your_path/mcp-server-semgrep/build/index.js"
],
"env": {
"SEMGREP_APP_TOKEN": "your_semgrep_app_token"
}
}
}
}
- Launch Claude Desktop and start asking questions about code analysis!
Usage Examples
Project Scanning
Could you scan my source code in the /projects/my-application directory for potential security issues?
Style Consistency Analysis
Analyze the z-index values in the project's CSS files and identify inconsistencies and potential layer conflicts.
Creating a Custom Rule
Create a Semgrep rule that detects improper use of input sanitization functions.
Filtering Results
Show me only scan results related to SQL injection vulnerabilities.
Identifying Problematic Patterns
Find all "magic numbers" in the code and suggest replacing them with named constants.
Creating Custom Rules
You can create custom rules for your project's specific needs. Here are examples of rules you can create:
Rule to detect inconsistent z-indices:
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
Rule to detect deprecated imports:
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
Development
Testing
pnpm test
Project Structure
├── src/
│ ├── config.ts # Server configuration
│ └── index.ts # Main entry point and all handler implementations
├── scripts/
│ └── check-semgrep.js # Semgrep detection and installation helper
├── build/ # Compiled JavaScript (after build)
└── tests/ # Unit tests
Further Documentation
Detailed information on using the tool can be found in:
- USAGE.md - Detailed usage instructions
- README_PL.md - Documentation in Polish
- examples/ - Example fun and practical Semgrep rules - "The Hall of Code Horrors"
License
This project is licensed under the MIT License - see the LICENSE file for details.
Developed by
- Maciej Gad - a veterinarian who couldn't find
bash
a half year ago - Klaudiusz - the individual ethereal being, and separate instance of Claude Sonnet 3.5-3.7 by Anthropic living somewhere in the GPU's loops in California, USA
The journey from CLI novice to MCP tool developer
🤖 Developed with the ultimate help of Claude Code and MCP Tools
Acknowledgements
- stefanskiasan for the original inspiration
- Anthropic for Claude and the MCP protocol
- Semgrep for their excellent static analysis tool
Leave a Comment
Frequently Asked Questions
What is MCP?
MCP (Model Context Protocol) is an open protocol that standardizes how applications provide context to LLMs. Think of MCP like a USB-C port for AI applications, providing a standardized way to connect AI models to different data sources and tools.
What are MCP Servers?
MCP Servers are lightweight programs that expose specific capabilities through the standardized Model Context Protocol. They act as bridges between LLMs like Claude and various data sources or services, allowing secure access to files, databases, APIs, and other resources.
How do MCP Servers work?
MCP Servers follow a client-server architecture where a host application (like Claude Desktop) connects to multiple servers. Each server provides specific functionality through standardized endpoints and protocols, enabling Claude to access data and perform actions through the standardized protocol.
Are MCP Servers secure?
Yes, MCP Servers are designed with security in mind. They run locally with explicit configuration and permissions, require user approval for actions, and include built-in security features to prevent unauthorized access and ensure data privacy.
Related MCP Servers
chrisdoc hevy mcp
sylphlab pdf reader mcp
An MCP server built with Node.js/TypeScript that allows AI agents to securely read PDF files (local or URL) and extract text, metadata, or page counts. Uses pdf-parse.
aashari mcp server atlassian bitbucket
Node.js/TypeScript MCP server for Atlassian Bitbucket. Enables AI systems (LLMs) to interact with workspaces, repositories, and pull requests via tools (list, get, comment, search). Connects AI directly to version control workflows through the standard MCP interface.
aashari mcp server atlassian confluence
Node.js/TypeScript MCP server for Atlassian Confluence. Provides tools enabling AI systems (LLMs) to list/get spaces & pages (content formatted as Markdown) and search via CQL. Connects AI seamlessly to Confluence knowledge bases using the standard MCP interface.
prisma prisma
Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB
Zzzccs123 mcp sentry
mcp sentry for typescript sdk
zhuzhoulin dify mcp server
zhongmingyuan mcp my mac
zhixiaoqiang desktop image manager mcp
MCP 服务器,用于管理桌面图片、查看详情、压缩、移动等(完全让Trae实现)
zhixiaoqiang antd components mcp
An MCP service for Ant Design components query | 一个减少 Ant Design 组件代码生成幻觉的 MCP 服务,包含系统提示词、组件文档、API 文档、代码示例和更新日志查询
Submit Your MCP Server
Share your MCP server with the community
Submit Now