Back to MCP directory
publicPublicdnsLocal runtime

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

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client