MCP 服务器 Semgrep 静态代码分析工具可帮助开发者高效地对代码进行静态分析,检测潜在的安全问题、样式不一致等问题,还支持自定义规则,提升代码质量。
要使用 MCP 服务器 Semgrep 静态代码分析工具,您首先需要安装 Semgrep 工具并配置环境变量。
您可以通过多种方式安装 Semgrep:
npm install -g semgrep
pip install semgrep
brew install semgrep
sudo apt-get install semgrep
# 或者
curl -sSL https://install.semgrep.dev | sh
pip install semgrep
安装完成后,请将 Semgrep 工具的路径添加到您的系统环境变量中,以便后续使用。
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.
Show me only scan results related to SQL injection vulnerabilities.
Find all "magic numbers" in the code and suggest replacing them with named constants.
rules:
- id: inconsistent-z-index
pattern: z-index: $Z
message: "Z-index $Z 可能与项目分层系统不兼容"
languages: [css, scss]
severity: WARNING
rules:
- id: deprecated-import
pattern: import $X from 'old-library'
message: "正在使用一个已弃用的库。建议使用 'new-library'"
languages: [javascript, typescript]
severity: WARNING
├── src/
│ ├── config.ts # 服务器配置文件
│ └── index.ts # 程序入口和所有处理程序实现
├── scripts/
│ └── check-semgrep.js # Semgrep 检测和安装辅助工具
├── build/ # 编译后的 JavaScript 文件(构建后生成)
└── tests/ # 单元测试文件
详细使用说明请参考:
本项目采用 MIT 许可证,详情请见 LICENSE 文件。
欢迎社区开发者积极参与本项目的开发与维护。如您有任何问题或建议,请通过以下方式联系我们:
感谢您的支持与合作!