Skip to main content
Glama
xTanTHaix

MCP Local Auditor & Architect

🛡️ MCP Local Auditor & Architect

"Slides made with Gemini Notebook" A high-performance Model Context Protocol (MCP) server that turns your local LLM (via LM Studio) into an autonomous Dual-Role Critic & System Architect. It provides enterprise-grade code auditing, dynamic AST security screening, architectural planning, and real-time Discord observability—with zero cloud API costs.


✨ Key Features

  • 🎭 Hybrid Dual-Role Engine (LMStudio-DualRole-Pipeline):

    • Role 1 (Code Auditor): Enforces strict 10-point defensive code standards (Type Hinting, dataclass schemas, RADS bounded iterations, structured error tracing, and Axiom Aegis testing framework compliance).

    • Role 2 (System Architect & Strategist): Automatically activates when receiving natural-language plans, questions, or specs—producing complete component topologies, risk analyses, and actionable master execution plans.

  • ⚡ Sub-Millisecond AST Sentinel: Instant static analysis and security gate that intercepts syntax errors and dangerous runtime invocations (eval, exec, os.system, subprocess) before hitting the LLM.

  • 🔍 Dynamic Model Auto-Discovery: Automatically inspects the active model loaded in LM Studio and filters out embedding models. Supports explicit overrides via the AUDITOR_MODEL environment variable.

  • đź§  Deep Reasoning Support: Seamlessly captures reasoning traces from models with chain-of-thought capabilities (e.g., DeepSeek-R1 via reasoning_content).

  • đź’ľ Dual Data Sink (DPO Flywheel):

    • SQLite Database (audit_history.db): Tracks durations, status breakdowns, and categorized metrics (CODE_AUDIT, SYSTEM_ARCHITECTURE, SECURITY, SYNTAX).

    • Per-Audit JSON Traces (audit_logs/): Stores atomic audit artifacts to easily construct DPO (Direct Preference Optimization) / RLHF datasets.

  • 📡 Real-Time Discord Observability (watch_audit_logs.py): Standalone polling background daemon that streams debounced, formatted markdown summaries of audit events directly to your Discord channel.


Related MCP server: Portable MCP Toolkit

🚀 Quick Start

1. Prerequisites

  • Python 3.10+

  • LM Studio running an OpenAI-compatible Local Server (http://localhost:1234/v1)

  • Antigravity or any MCP-compatible client

  1. Installation

# 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. # URL for local LM Studio Server (Default: http://localhost:1234/v1)

LM_STUDIO_URL=http://localhost:1234/v1

Specific model name override (leave empty for auto-detection)

AUDITOR_MODEL=

Discord Webhook URL for real-time audit notifications

DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/your-webhook-url

⚙️ MCP Server Registration Open your Antigravity MCP config file:

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

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

Add the server definition inside mcpServers:

{
  "mcpServers": {
    "lmstudio-auditor": {
      "command": "D:\\Hucdeline\\.venv\\Scripts\\python.exe",
      "args": ["D:\\Hucdeline\\auditor_bridge.py"],
      "env": {
        "LM_STUDIO_URL": "http://localhost:1234/v1"
      }
    }
  }
}

đź’ˇ Note: Adjust the absolute paths to match your project's virtual environment Python interpreter and script path.

4. Configure LM Studio

  1. Open LM Studio and load any instruction-tuned coding model (e.g., Qwen-2.5-Coder, DeepSeek-Coder, Llama-3).

  2. Go to the Local Server (Developer) tab.

  3. Set Port to ...(e.g.,1234) and click Start Server.


🤖 Agent Loop Setup (Custom Rule / Skill)

Add the following rule to your Antigravity Agent (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. Configure LM Studio Open LM Studio and load any instruction-tuned coding model (e.g., Qwen-2.5-Coder, DeepSeek-Coder, Llama-3).

Go to the Local Server tab.

Set Port to xxxx and click Start Server.

🤖 Agent Protocol & Loop Rules Add the following rule to your autonomous coding agent's system prompt or custom skill file:

Mandatory MCP Code Audit & Strategy Protocol

  1. For every generated or refactored code unit, invoke the audit_submission tool:

    • Parameters: task_goal, output_content, strict_rules

  2. Interpret the return status:

    • If STATUS == "REJECTED": Analyze ACTIONABLE_FEEDBACK, refactor the code defensively, and re-submit (Max retries: 5).

    • If STATUS == "APPROVED": Proceed with execution or present the final code.

    • If STATUS contains Architecture / Planning: Adopt the recommended Master Execution Plan before writing code. đź§Ş Testing Run the included Pytest suite to verify AST checks, SQLite migrations, and mock responses:

Bash pytest test_auditor.py -v

📸 Real-World Audit in Action (Example Usage / Usage Example)

Here is an example of MCP Local Auditor rejecting an unoptimized code path with actionable feedback, prompting the coding agent to self-heal and re-verify: Example Usage: After the tests pass, audit each modified file one by one using the "lmstudio-auditor" tool.

đź’– Support & Donations If this project saved you API costs and helped streamline your local LLM workflow, consider supporting development:

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

GitHub Sponsors: Click the Sponsor button on this repository

đź“„ License MIT License. Free for open-source and commercial use.

A
license - permissive license
Not graded
quality - not tested
A
maintenance

Maintenance

–Maintainers
–Response time
–Release cycle
1Releases (12mo)
Commit activity

Related MCP Servers

  • F
    license
    C
    quality
    D
    maintenance
    Enterprise-grade code intelligence platform providing AI-powered code analysis, semantic search, security scanning, and automated refactoring capabilities. Integrates with local AI models for zero-cost operations while delivering comprehensive development workflow automation.
    2
    8
  • A
    license
    Not graded
    quality
    C
    maintenance
    Provides AI-powered code intelligence for any codebase using local LLMs and vector search, enabling semantic code search, pattern analysis, and context-optimized code generation with 90% token savings.
    2
    MIT
  • A
    license
    C
    quality
    D
    maintenance
    A privacy-first MCP server that provides local LLM-enhanced tools for code analysis, security scanning, and automated task execution using backends like Ollama and LM Studio. It enables symbol-aware code reviews and workspace exploration while ensuring that all code and analysis remain strictly on your local machine.
    36
    ISC
  • A
    license
    A
    quality
    A
    maintenance
    Enterprise-grade (40m+ lines) codebase intelligence in a zero-setup, private and local MCP: managed indexing, hybrid semantic search, polyglot code dependency graphs, and DB/API/infra knowledge. Benchmark: 61% less tokens, 84% fewer calls, 37x faster than standard AI grep.
    25
    1,742
    3,276
    AGPL 3.0

View all related MCP servers

Related MCP Connectors

  • Enterprise code intelligence for M&A, security audits, and tech debt. Hosted server with 200k free.

  • Deterministic AI code review, with an audit record. Governance inside the agent loop.

  • Zero-config MCP security scanner for AI-generated apps. 25K+ vulnerability patterns.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/xTanTHaix/mcp-dualrole-pipeline'

If you have feedback or need assistance with the MCP directory API, please join our Discord server