Skip to main content
Glama

✨ 核心特性

  • 零成本本地审查器: 通过 LM Studio 将繁重的代码审查迭代卸载到本地 GPU,无需消耗云端 token。

  • 亚毫秒级 AST 哨兵: 在浪费 GPU 算力之前捕获语法错误和危险的运行时调用(eval、exec、os.system、subprocess)。

  • 确定性契约: 强制执行结构化输出(APPROVED 与 REJECTED,附带具体的行级反馈),使智能体无需人工干预即可自动重构代码。

  • 双数据汇(DPO 飞轮):

    • SQLite(audit_history.db): 跟踪持续时间、类别和指标。

    • 单次审计 JSON(audit_logs/): 存储单次审计记录,便于从配对的拒绝/批准尝试中轻松构建 DPO / 微调数据集。


Related MCP server: tar-engine

🚀 快速开始

1. 前提条件

  • Python 3.10+

  • LM Studio 运行一个兼容 OpenAI 的本地服务器(http://localhost:1234/v1)

  • Antigravity 或任何兼容 MCP 的客户端

  1. 安装

# Clone the repository
git clone [https://github.com/xTanThaix/mcp-local-auditor.git](https://github.com/xTanThaix/mcp-local-auditor.git)
cd mcp-local-auditor

# Set up virtual environment
python -m venv .venv

# Activate virtual environment
# On Windows:
.venv\Scripts\activate
# On macOS/Linux:
source .venv/bin/activate

# Install dependencies
pip install -r requirements.txt

3. 注册 MCP 服务器

打开你的 Antigravity MCP 配置文件:

  • Windows: %USERPROFILE%\.gemini\config\mcp_config.json

  • macOS / Linux: ~/.gemini/config/mcp_config.json

在 mcpServers 中添加服务器定义:

{
  "mcpServers": {
    "lmstudio-auditor": {
      "command": "D:\\Hucdeline\\.venv\\Scripts\\python.exe",
      "args": ["D:\\Hucdeline\\auditor_bridge.py"]
    }
  }
}

注意: 将 D:\\Hucdeline 替换为你实际的项目目录路径。


4. 配置 LM Studio

  1. 打开 LM Studio 并加载任何指令微调的编码模型(例如 Qwen-2.5-Coder、DeepSeek-Coder、Llama-3)。

  2. 转到 本地服务器(开发者)选项卡。

  3. 将端口设置为 ...(e.g.,1234),然后点击 启动服务器。


🤖 智能体循环设置(自定义规则 / 技能)

将以下规则添加到你的 Antigravity 智能体(mcp-studio-loop):

# Mandatory MCP Code Audit Protocol
Every time code is generated or refactored, you MUST invoke the `audit_submission` tool:
- Arguments: `task_goal`, `output_content`, `strict_rules`
- If STATUS == "REJECTED": Read `ACTIONABLE_FEEDBACK`, refactor the code, and re-submit.
- If STATUS == "APPROVED": Output the final solution to the user.
- Maximum retry limit: 5 attempts before breaking loop.
  1. 配置 LM Studio 打开 LM Studio 并加载任何指令微调的编码模型(例如 Qwen-2.5-Coder、DeepSeek-Coder、Llama-3)。

转到本地服务器选项卡。

将端口设置为 xxxx,然后点击启动服务器。

🤖 智能体循环设置(自定义规则 / 技能) 将以下规则添加到你的 Antigravity 智能体(mcp-studio-loop):

Markdown

强制 MCP 代码审计协议

每次生成或重构代码时,你必须调用 audit_submission 工具:

  • 参数:task_goal、output_content、strict_rules

  • 如果 STATUS == "REJECTED":阅读 ACTIONABLE_FEEDBACK,重构代码并重新提交。

  • 如果 STATUS == "APPROVED":向用户输出最终解决方案。

  • 最大重试次数:中断循环前最多尝试 5 次。 🧪 测试 运行附带的 Pytest 测试套件,以验证 AST 检查、SQLite 迁移和模拟响应:

Bash pytest test_auditor.py -v

📸 真实场景审计实战(示例用法 / 使用示例)

以下是一个 MCP Local Auditor 拒绝未优化代码路径并给出可操作反馈的示例,促使编码智能体自我修复并重新验证: 示例用法:测试通过后,使用 "lmstudio-auditor" 工具逐一审计每个修改过的文件。

💖 支持与捐赠 如果这个项目为你节省了 API 成本,并帮助简化了你的本地 LLM 工作流,请考虑支持开发:

Ko-fi:https://ko-fi.com/xtanthaix

GitHub Sponsors:点击此仓库上的 Sponsor 按钮

📄 许可证 MIT 许可证。免费用于开源和商业用途。

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      C
      quality
      D
      maintenance
      Captures code modifications via AST analysis, generates reusable rules, and injects them into AI agent context with version audit and token-budgeted rule retrieval.
      28
      4 npm
      Apache 2.0
    • A
      license
      A
      quality
      B
      maintenance
      Audits AI agent skills for safety using static, semantic, adversarial, and supply-chain analysis, providing scores and risk flags. Can be run via CLI, CI, or as an MCP tool from Claude Code, Cursor, and Codex.
      5
      170 PyPI
      2
      Apache 2.0
    • A
      license
      A
      quality
      D
      maintenance
      Enforces AST-based architectural guardrails on AI-generated code, blocking writes that violate maintainability, security, or complexity rules and prompting immediate refactoring.
      2
      MIT