返回 MCP 目录
public公开dns本地运行

Semgrep

Semgrep MCP Server是一个基于Model Context Protocol (MCP)的服务器,用于通过Semgrep扫描代码中的安全漏洞,支持多种集成方式和工具。

article

README

🚀 Semgrep MCP 服务器

Semgrep MCP 服务器是一个强大的工具,它基于 Semgrep 实现了 MCP 协议相关功能。通过它,用户可以更高效地进行代码扫描等操作,无论是使用 Docker 快速部署,还是手动基于 Python 安装,都能轻松上手。

🚀 快速开始

运行服务器

semgrep-mcp-serve

示例 Python SSE 客户端

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": [
                        {
                            "filename": "hello_world.py",
                            "content": "def hello(): print('Hello, World!')",
                        }
                    ]
                },
            )
            print(results)


if __name__ == "__main__":
    import asyncio
    asyncio.run(main())

📦 安装指南

使用 Docker 安装并运行

docker run -it --rm semgrep/mcp:latest

手动安装(基于 Python)

  1. 安装 Python:
    • Windows:
      # 安装 Python 3.x
      choco install python3
      
    • macOS:
      # 使用 Homebrew 安装 Python 3
      brew install python
      
  2. 安装 Semgrep 和 MCP 服务器:
    pip install semgrep mcp-server
    

📚 文档与资源

官方链接

社区与支持

🔧 贡献与开发

提交代码

  1. Fork 仓库并克隆到本地:
    git clone https://github.com/semgrep/mcp-server.git
    cd mcp-server
    git checkout main
    
  2. 创建功能分支并提交代码:
    git checkout -b feature/your-feature-name
    # 进行代码修改
    git add .
    git commit -m "添加新功能"
    git push origin feature/your-feature-name
    

提交 Pull Request

  • GitHub Issues 中创建问题或提出功能请求。
  • 为每个功能或修复创建独立的 Pull Request。

🛠️ 其他工具

👥 社区项目

help

运行方式说明

cloud

托管运行

托管运行通常表示这个 MCP Server 由服务方环境承载,用户一般按页面提供的连接方式或授权流程接入,不需要在本地长期启动一个 MCP 进程

  1. 打开服务方连接页
  2. 完成授权或复制端点
  3. 在 MCP 客户端中连接
terminal

本地运行 / 其它方式

本地运行通常需要用户在自己的电脑或服务器上安装依赖,把 server_config 复制到 MCP 客户端,并按 env_schema 补齐环境变量、密钥或其它配置

  1. 复制 server_config
  2. 安装所需依赖
  3. 补齐环境变量后重启客户端