MCP Local Auditor & Architect
Streams formatted audit event summaries to a Discord channel via webhook for real-time observability.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MCP Local Auditor & ArchitectAudit my Python script for security vulnerabilities and best practices"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
π‘οΈ MCP Local Auditor & System Architect V2
A dual-mode, zero-token-cost local engineering engine built on the Model Context Protocol (MCP). It dynamically switches between Production Code Auditor (enforcing 10 strict engineering pillars) and System Architect & Strategist (generating topologies and execution plans) via local models in LM Studio, backed by a fast AST security filter, dual data sinks (SQLite & DPO-ready JSON logs), and a real-time Discord notification daemon.
π§© The MCP Dual-Role Pipeline | βοΈ Engineering Autonomous Reliability |
A framework for synchronized, context-aware AI workflows | Pairs an Executor with a Critic in a localized environment |
β¨ Core Capabilities
Feature | Description |
Zero-Cost Local Critic | Offloads exhaustive validation loops to local GPUs via LM Studio without spending cloud tokens. |
Sub-Millisecond AST Sentinel | Rejects Python syntax errors and blocks high-risk calls ( |
Dynamic Dual Modes | Automatically detects whether input is raw code or high-level architecture/specs, executing context-specific validation prompts. |
Dual Data Persistence | Records execution metrics into SQLite ( |
Live Discord Telemetry | Background daemon monitors audit output files in real time and pushes structured embeds directly to Discord. |
Dynamic Model Discovery | Automatically queries LM Studio's active model endpoint, bypassing embedding engines dynamically. |
π The Standardized Context Bridge | βοΈ Separation of Concerns: Dual-Role Dynamic |
Decoupled Read/Write operations via universal MCP layer | Executor (generation) vs Reviewer (zero-temperature validation) |
Related MCP server: Portable MCP Toolkit
π System Architecture
[ User Submission / Agent Request via MCP ]
β
βΌ
[ Stage 1: Fast AST Sentinel ] ββββββββββββββββββββββββββ
(Syntax Parse & Danger Call Interception) β
β (Valid Code or Specs) β (Syntax / Security
βΌ β Violation)
[ Stage 2: Hybrid Dual-Role LLM ] β
(LM Studio Local Inference Server) β
βββ Role 1: 10-Pillar Code Audit β
βββ Role 2: Architecture & Master Plan β
β β
βΌ β
[ Stage 3: Multi-Sink Logger ] <ββββββββββββββββββββββββ
βββ SQLite DB (Metrics & Analytics)
βββ Atomic JSON Logs (DPO Datasets)
β
βΌ (File Write Event)
[ Daemon: Discord Watcher Loop ]
(Rich Embed Notifications pushed to Webhook)
π Dynamic Dual-Role Modes
The engine routes tasks automatically based on the payload structure passed to audit_submission:
1. Code Auditor Mode (Activated on Code Submissions)
Audits incoming implementations against 10 strict defensive engineering rules:
Logic & Edge Conditions: Null checks, division by zero, empty collections.
Resource Leaks & Performance: Unclosed context managers, algorithmic bottlenecks.
Defensive Boundaries: Type hints, data contracts via dataclasses, bounded loop guards.
Deterministic Contract: Enforces a rigid feedback schema (
STATUS: APPROVEDorSTATUS: REJECTED).
πΊοΈ Pipeline Architecture Mapping | β±οΈ Chronological Execution Workflow |
Orchestrator routing across MCP server and dual agents | Ingest β Query β Synthesize β Audit β Output pipeline |
2. System Architect & Strategist Mode (Activated on Specs/Plans)
Generates system designs for technical prompts without code:
Component Topologies: Data flow patterns, directory structures, modular interconnects.
Preemptive Risk Modeling: Concurrency bottlenecks, race conditions, failure points.
Master Execution Plans: Step-by-step phased roadmaps ready for direct implementation.
π‘ Real-Time Discord Watcher
watch_audit_logs.py runs as an asynchronous observer over the audit_logs/ directory, dispatching notifications whenever new audit artifacts are produced:
python watch_audit_logs.py
Automated Polling: Tracks
.jsonadditions with debounce guards.Markdown Formatting: Renders status tags (
APPROVED,REJECTED), duration metrics, summaries, and issue breakdowns.Zero Configuration Fallback: Operates headlessly in the background without halting the core MCP pipeline.
π The Autonomous Refinement Engine | π¦ Data Routing & State Management Payload |
Continuous feedback loop eliminating hallucination drift | Strict turn-based JSON schema preventing infinite loops |
π Quick Start
1. Prerequisites
Python 3.10+
LM Studio running an OpenAI-compatible Local Server at
http://localhost:1234/v1Any MCP-compatible host client
2. 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
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
3. Register with MCP Client
Add the server definition into your client's mcpServers configuration (e.g., mcp_config.json):
{
"mcpServers": {
"lmstudio-auditor": {
"command": "python",
"args": ["/path/to/mcp-local-auditor/auditor_bridge.py"]
}
}
}
4. Configure LM Studio
Launch LM Studio and load an instruction-tuned model (e.g.,
Qwen-2.5-Coder,DeepSeek-Coder).Open the Local Server tab.
Set the port (default:
1234) and click Start Server.
ποΈ Deployment Dependencies & Infrastructure | π Pipeline Characteristics & Extensibility |
Modular runtime stack connecting local MCP servers with LLMs | Guaranteed context alignment and drop-in extensibility |
π€ Agent Loop Protocol
To make your coding assistant iteratively fix its own mistakes, inject this instruction rule into your agent configuration:
# 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": Inspect `ACTIONABLE_FEEDBACK`, remediate reported issues, and re-submit.
- If STATUS == "APPROVED": Deliver final verified code to the user.
- Cap recovery loops at a maximum of 5 attempts.
π§ͺ Test Suite
Run the full pytest suite to validate AST guards, SQLite migrations, and mocked inference pipelines without needing a live LM Studio instance:
pytest test_auditor.py -v
π Support & Donations
If this project helps streamline your local AI engineering workflow, consider supporting development:
Ko-fi: https://ko-fi.com/xtanthaix
GitHub Sponsors: Available directly via repository profile
π License
Distributed under the MIT License. Free for personal, commercial, and open-source implementation.
This server cannot be deployed
Maintenance
Related MCP Connectors
Code intelligence platform for AI agents. 20 tools for architecture, security & impact analysis.
Enterprise code intelligence for M&A, security audits, and tech debt. Hosted server with 200k free.
Security reviews for coding agents: diffs checked against your org policy and live infrastructure.
Deterministic AI code review, with an audit record. Governance inside the agent loop.
Related MCP Servers
- FlicenseCqualityCmaintenanceEnterprise-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.28-
- AlicenseNot gradedqualityCmaintenanceProvides 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.2MIT
- AlicenseCqualityDmaintenanceA 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.36ISC
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to perform hybrid code search, get explanations, analyze relations and impacts, retrieve context packs, and generate documentation across ~45 languages via 17 MCP tools, all powered by a local vector database and LLM.2Apache 2.0