返回市场
代码审计MCP

代码审计MCP

作者:Bluestar-coder6 星标更新:2025-10-21

项目介绍

Code Audit MCP

English | 简体中文

基于Python + Go的人工智能代码安全审计系统,支持MCP(模型上下文协议)集成。它提供索引构建、调用链分析、污点追踪、规则驱动扫描、带有PoC提示的AI解释以及OSV漏洞检索。

功能

  • 后端(Go,gRPC+HTTP):抽象语法树/索引/调用链/污点/规则扫描
  • MCP(Python):统一工具接口,兼容MCP主机(例如,Claude Desktop)
  • 前端(React,可选):仪表板和漏洞列表
  • 规则库(YAML):内置常见漏洞规则

架构

  • backend/核心分析和服务接口cmd/server``internal``proto)
  • mcp/MCP服务器和工具入口python -m code_audit_mcp.server)
  • frontend/React前端(生产构建复制到release/frontend
  • proto/protobuf定义和代码生成(Go/Python)
  • rules/YAML规则库
  • scripts/:check-clean-state.ps1``build-release.ps1
  • release/外部发布目录server.exe``frontend/``rules/common/)

快速开始(Windows)

  • 先决条件:安装Python 3.11+``Go 1.24+前端需要Node.js 18+)
  • Python环境(建议使用虚拟环境)
cd mcp
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -e .
  • 启动后端(默认gRPC)localhost:50051HTTP localhost:8080)
cd backend
go mod download
go run ./cmd/server
# 或构建后运行:
# go build -o server.exe ./cmd/server
# .\server.exe -http-port 8080 -port 50051
  • 启动前端(可选)
cd frontend
npm install
npm start   # 访问 http://localhost:3000

发布构建

  • 一键脚本:
powershell -ExecutionPolicy Bypass -File scripts\build-release.ps1
  • 输出内容:release/server.exe``release/frontend/``release/rules/common/
  • 查看发布包说明:release/README-release.md
  • 预发布整洁检查:
powershell -ExecutionPolicy Bypass -File scripts\check-clean-state.ps1 -VerboseOutput

MCP配置(Claude Desktop)

mcpServers中添加以下段落:

{
  "mcpServers": {
    "code-audit-mcp": {
      "command": "python",
      "args": ["-m", "code_audit_mcp.server"]
    }
  }
}

目录结构

  • backend/抽象语法树/索引/调用链/污点/扫描(gRPC+HTTP)
  • mcp/MCP服务器和工具
  • frontend/React前端(可选)
  • proto/Proto定义和语言工件
  • rules/常见漏洞规则
  • release/外部发布目录

常见问题

  • gRPC连接失败:确保后端正在运行并监听localhost:50051
  • HTTP网关不可用:确认使用-http-port启动并打开localhost:8080
  • Web UI端口冲突:使用$Env:PORT=3001; npm start
  • AI使用:服务器返回提示,主机LLM生成结果;无需在服务器过程中配置模型密钥

许可证

MIT许可证