llm-powered-code-auditor-service
A dedicated MCP endpoint designed to execute rigorous, structured evaluations of source code artifacts. It leverages sophisticated Large Language Models (LLMs) to pinpoint flaws, suggest optimizations, and deliver constructive feedback. This utility robustly manages integrations across various LLM vendors and incorporates intelligent context partitioning for extremely large project repositories.
Author

crazyrabbitLTC
Quick Info
Actions
Tags
Intelligent Code Quality Assurance Platform
This specialized MCP mechanism provides automated code scrutiny leveraging Repomix for repository traversal and advanced LLM reasoning capabilities.
Core Functionalities
- Repository Flattening: Systematically linearizes codebases using the Repomix utility.
- AI-Driven Analysis: Applies Large Language Models to assess code quality and adherence to standards.
- Structured Feedback Generation: Produces formal audit reports detailing identified shortcomings and improvement pathways.
- Vendor Agnostic: Seamlessly interacts with diverse LLM backends (e.g., OpenAI, Anthropic, Google Gemini).
- Context Window Management: Features adaptive segmentation logic to handle massive code volumes efficiently.
Deployment Guide
bash
Obtain the source repository
git clone https://github.com/yourusername/code-review-server.git cd code-review-server
Install required libraries
npm install
Compile the application assets
npm run build
Configuration Setup
Initialize the operational environment variables by duplicating the example configuration file:
bash cp .env.example .env
Modify .env to specify your primary LLM supplier and authenticate via your secret key:
bash
LLM Endpoint Selection
LLM_PROVIDER=ANTHROPIC ANTHROPIC_API_KEY=your_anthropic_secret_key_here
Operational Mode
As an MCP Node
This service adheres to the Model Context Protocol (MCP) specification, enabling interoperability with any compliant client:
bash
Initiate the audit server
node build/index.js
The exposed primary functionalities are:
repository_mapping: Uses Repomix to generate a sequential text representation of the entire codebase.quality_assessment: Executes the deep-dive code review via the configured LLM.
Tool Selection Rationale
This platform offers two distinct operational modes tailored for specific analytical requirements:
repository_mapping
Invoke this function when the objective is to: - Obtain a bird's-eye perspective on the project's architecture and layout. - Convert the repository structure into a linear, readable text stream for preliminary examination. - Catalog the file system hierarchy and content summaries without performing deep functional scrutiny. - Pre-process the source for a subsequent, more granular evaluation. - Rapidly isolate specific code segments of interest across the project.
Appropriate Scenarios: - "I need a structural blueprint of this repository before commencing an audit." - "Display the file and directory inventory for this codebase." - "Provide a serialized overview of the code organization."
quality_assessment
Invoke this function when the objective is to: - Conduct an exhaustive evaluation of code robustness and adherence to established standards. - Pinpoint specific implementation defects such as security exploits, performance bottlenecks, or logic errors. - Acquire actionable, prescriptive advice for code enhancement. - Generate a granular review complete with quantified risk ratings for identified issues. - Benchmark the codebase quality against industry best practices.
Appropriate Scenarios: - "Scan this entire codebase specifically for potential security vulnerabilities." - "Analyze the runtime efficiency implications within these designated Python source files." - "Generate a comprehensive quality report detailing architectural strengths and weaknesses." - "Suggest concrete refactorings to improve long-term code maintainability."
Parameter Utilization Guidance:
- specific_files: Restrict the analysis scope to a defined subset of files.
- file_extensions: Narrow the focus by file suffix (e.g., only .java, .py).
- depth_setting: Choose 'superficial' for rapid checks or 'in_depth' for meticulous examination.
- priority_vectors: Direct the LLM's attention towards critical domains (e.g., safety, speed, clarity).
Command-Line Interface (CLI) Utility
For validation and immediate local testing, an auxiliary CLI script is included:
bash
node build/cli.js
Options:
- --targets <file_a,file_b>: Specify targeted source files.
- --formats <.html,.css>: Include only files matching these extensions.
- --depth <shallow|deep>: Review granularity level (default: deep).
- --priorities <safety,efficiency>: Areas for focused analysis.
Example Invocation:
bash node build/cli.js ./application_source --formats .ts,.tsx --depth deep --priorities safety,clarity
Engineering and Maintenance
bash
Execute unit and integration verification suites
npm test
Enable continuous recompilation for active development
npm run watch
Launch the integrated MCP protocol debugging utility
npm run inspector
LLM Provider Connectivity
The auditor service establishes direct communication pathways with several leading LLM vendor APIs:
- OpenAI (Default inference engine: gpt-4o)
- Anthropic (Default inference engine: claude-3-opus-20240307)
- Gemini (Default inference engine: gemini-1.5-pro)
Vendor Selection Configuration
Designate the active LLM endpoint within the .env file:
bash
Choose the active backend system
LLM_PROVIDER=GEMINI # Options: OPEN_AI, ANTHROPIC, or GEMINI
Corresponding API Credentials (Ensure the key for the selected provider is present)
OPENAI_API_KEY=your-openai-key ANTHROPIC_API_KEY=your-anthropic-key GEMINI_API_KEY=your-gemini-key
Model Selection Overrides
Specific model identities can be manually set to override default selections:
bash
Optional: Specify exact models to utilize
OPENAI_MODEL=gpt-4-turbo-2024-04-09 ANTHROPIC_MODEL=claude-3-5-sonnet GEMINI_MODEL=gemini-2.5-flash
Operational Flow of LLM Interaction
- The
quality_assessmentroutine initiates, first using Repomix to serialize the project structure. - Source code segments are meticulously organized and fragmented, ensuring compliance with the LLM's input context window capacity.
- A highly detailed query prompt is constructed, parameterized by the desired focus areas and analysis depth.
- This bundled prompt and code payload are transmitted securely to the selected external LLM service.
- The resulting output from the LLM is processed and mapped into a standardized data structure.
- The final, structured evaluation report is returned to the client.
The internal logic incorporates resilient API call mechanisms, including automated retry attempts for transient network faults, and rigorous input formatting to maximize the signal-to-noise ratio in the LLM's response.
Audit Output Schema
The final assessment is encapsulated in a predictable JSON structure:
{ "assessment_summary": "Concise overview of the code functionality and quality level", "identified_defects": [ { "defect_class": "SECURITY|PERFORMANCE|QUALITY|MAINTAINABILITY", "risk_level": "CRITICAL|MODERATE|MINOR", "issue_detail": "In-depth explanation of the anomaly found", "locations": [45, 98], // Line numbers affected "remediation_suggestion": "Specific code change recommended" } ], "acknowledged_merits": ["List of positive coding attributes observed"], "global_improvement_directives": ["High-level strategic advice for the project"] }
Licensing Terms
Proprietary Under MIT License
