CodeGuardian MCP
Supports validation of Express backends, detecting API contract mismatches and dead code.
Supports validation of FastAPI backends, detecting API contract mismatches and dead code.
Validates JavaScript code against the codebase, detecting AI hallucinations, dead code, and bad imports.
Supports validation of Next.js projects, detecting API contract mismatches and code issues across full-stack applications.
Validates Python code against the codebase, detecting AI hallucinations, dead code, and bad imports.
Supports validation of React projects, detecting API contract mismatches and mismatched function calls against the codebase.
Validates TypeScript code against the codebase, detecting AI hallucinations, dead code, and bad imports.
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., "@CodeGuardian MCP validate the function getUserById in my codebase"
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.
CodeGuardian MCP
The Problem
AI coding assistants hallucinate. They generate code that compiles fine but breaks at runtime:
// [X] AI generates this:
const user = getUserById(id); // Function doesn't exist!
// [OK] Your codebase has:
const user = findUserById(id); // Correct function nameCommon AI Hallucinations:
[CRITICAL] Calling
getUserById()when your codebase hasfindUserById()[CRITICAL] Using methods that aren't on your classes
[CRITICAL] Importing from modules that don't export what they claim
[CRITICAL] Creating dead code that nothing ever uses
Related MCP server: CodeTruth MCP Server
The Solution
CodeGuardian validates AI-generated code against your actual codebase before you run it.
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ AI Generates │────▶│ CodeGuardian │────▶│ Issues Found │
│ Code │ │ Validates │ │ + Suggestions │
└─────────────────┘ └──────────────────┘ └─────────────────┘
│ │ │
▼ ▼ ▼
Vibe Coding AST Parsing Fix Before
Confidently Symbol Matching RuntimeInstallation
Prerequisites
Node.js v20 or higher (Download)
Install from npm
# Using npx (no install needed — recommended)
npx codeguardian-mcp
# Or install globally
npm install -g codeguardian-mcp
# Or with pnpm
pnpm add -g codeguardian-mcpInstall from source (for contributors)
git clone https://github.com/codegoddy/codeguardian_mcp.git
cd codeguardian_mcp
pnpm install
pnpm run buildConnecting to Your MCP Client
Add CodeGuardian to your MCP client config. No cloning or building required — npx handles everything.
Claude Desktop (claude_desktop_config.json):
{
"mcpServers": {
"codeguardian": {
"command": "npx",
"args": ["-y", "codeguardian-mcp"]
}
}
}Windsurf (mcp_config.json):
{
"mcpServers": {
"codeguardian": {
"command": "npx",
"args": ["-y", "codeguardian-mcp"]
}
}
}Cursor (.cursor/mcp.json):
{
"mcpServers": {
"codeguardian": {
"command": "npx",
"args": ["-y", "codeguardian-mcp"]
}
}
}OpenCode (opencode.json in your project root):
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"codeguardian": {
"type": "local",
"command": ["npx", "-y", "codeguardian-mcp"],
"enabled": true
}
}
}Gemini CLI (settings.json):
{
"mcpServers": {
"codeguardian": {
"command": "npx",
"args": ["-y", "codeguardian-mcp"]
}
}
}Claude Code (CLI):
claude mcp add --transport stdio codeguardian -- npx -y codeguardian-mcpRestart your IDE / MCP client for the changes to take effect. You should see CodeGuardian's tools become available.
Note: If you installed globally (
npm install -g codeguardian-mcp), you can use"command": "codeguardian-mcp"with no args instead ofnpx.
Quick Start
The two primary tools that handle everything for you:
start_validation — Full Project Health Check
Scans your entire codebase for hallucinations, dead code, and bad imports. Best for on-demand audits.
Where to run: From the specific subdirectory you want to validate (e.g.,
frontend/orbackend/), not the monorepo root.
# Example: Validate frontend only
cd /path/to/your/project/frontend
start_validation({
projectPath: "/path/to/your/project/frontend",
language: "typescript"
})
# Example: Validate backend only
cd /path/to/your/project/backend
start_validation({
projectPath: "/path/to/your/project/backend",
language: "python"
})This runs in the background (no timeouts). Check progress and get results with:
get_validation_status({ jobId: "..." })— poll progressget_validation_results({ jobId: "..." })— get the final report
start_guardian — Real-Time File Watcher
Watches your project and automatically validates files as you (or your AI) edit them. Runs continuously in the background.
Where to run: From the project root directory (monorepo root). Guardian will auto-detect and watch all subprojects (frontend, backend, etc.).
# Run from project root (monorepo root)
cd /path/to/your/project
start_guardian({
projectPath: "/path/to/your/project",
language: "typescript" // or "python" or "auto"
})Once running, it catches issues in real-time across all subprojects. Use these companion tools:
get_guardian_alerts— see current issues found by the watcherget_guardian_status— check which guardians are activestop_guardian— stop a guardian when done
Tip: These two tools handle everything without needing to call individual validation tools manually.
start_validationfor focused audits on specific subdirectories,start_guardianfor continuous protection across the entire project.
Features
AI Hallucination Detection
Catches non-existent functions, classes, and methods with 95% confidence
Confidence Scoring
Every issue includes a confidence score (0-100%) and detailed reasoning
Score | Level | Action |
0-49 | Critical | REJECT - Major hallucinations detected |
50-69 | Low | REVIEW - Multiple issues need attention |
70-89 | Medium | CAUTION - Minor issues, review suggested |
90-100 | High | ACCEPT - Code is safe to use |
Dead Code Detection
Finds exported functions and classes that nothing imports
API Contract Validation
Detects mismatches between frontend and backend — wrong endpoints, missing fields, type incompatibilities
Multi-Language Support
TypeScript / JavaScript — full support
Python — full support
Full-Stack Projects
Automatically detects full-stack projects (e.g. React + FastAPI, Next.js + Express) and validates each language correctly.
Real-Time Validation
Validates code immediately after generation with sub-second response times
What It Catches
Type | Example | Severity | Confidence |
Non-existent function |
| Critical | 95% |
Non-existent class |
| Critical | 95% |
Bad import |
| Critical | 93% |
Missing dependency |
| Critical | 95% |
Wrong method |
| Medium | 70% |
Wrong param count |
| High | 88% |
Dead export | Exported function nothing imports | Medium | 85% |
Hardcoded credentials |
| Critical | 85% |
API contract mismatch | Frontend calls endpoint that doesn't exist on backend | Critical | 90% |
How It Works
┌─────────────────────────────────────────────────────────────┐
│ CodeGuardian Pipeline │
├─────────────────────────────────────────────────────────────┤
│ 1. AST Parsing │
│ └─> Uses tree-sitter to parse your codebase │
│ └─> Extracts all symbols (functions, classes, methods) │
│ │
│ 2. Context Building │
│ └─> Builds searchable index of project symbols │
│ └─> Caches for fast subsequent validations │
│ │
│ 3. Validation │
│ └─> Compares AI-generated code against index │
│ └─> Flags anything that doesn't exist │
│ │
│ 4. Suggestions │
│ └─> Uses fuzzy matching to suggest corrections │
│ └─> Provides confidence scores and reasoning │
└─────────────────────────────────────────────────────────────┘All Tools
Primary Tools (start here)
Tool | Description |
| Full project scan — runs in background, no timeouts. Use for on-demand audits. |
| Real-time file watcher — validates files as they change. Use for continuous protection. |
Validation Job Tools
Tool | Description |
| Poll progress of a |
| Get final results when a validation job completes |
Guardian Tools
Tool | Description |
| Get current issues found by active guardians |
| Check which guardians are running |
| Stop a specific guardian or all guardians |
Individual Tools
Tool | Description |
| Validate a single code snippet against your project's symbols |
| Build/rebuild project symbol index (usually auto-called) |
| Show what files depend on what — understand the blast radius of changes |
API Contract Tools
Tool | Description |
| Validate frontend/backend API contract compatibility |
| Generate a detailed API contract validation report |
What It Skips (No False Positives)
[OK] External packages (npm/pip) - not your code
[OK] Built-ins (
console.log,print,Math.random)[OK] New code being created in the same snippet
[OK] Entry points (
index.ts,main.py)[OK] Test files
Limitations
No Python type inference — CodeGuardian uses static AST analysis, not a type system. It cannot resolve types through variable assignments, function return values, or chained calls. For example, if
db.query(User)returns aQueryobject and you call.filter()on it, CodeGuardian cannot verify that.filter()is a valid method because it doesn't track the return type ofdb.query(). This would require building a mini mypy-style type checker, which is out of scope. Python method calls on dynamically-typed variables are skipped to avoid false positives.Doesn't catch logic errors (that's still on you)
Dynamic code (
eval, reflection) can't be trackedMethod calls on untyped objects may be skipped to avoid false positives
Very large monorepos (>1000 files) should use
start_validationwith batching
Contributing
We welcome contributions! Please see our Contributing Guide for details.
License
MIT License - see LICENSE file for details.
Available Tools
12 toolsbuild_contextB
Build or rebuild project context including symbols, git history, and intent signals. Usually auto-called by other tools.
Inputs: projectPath (required), language, maxFiles, forceRebuild, +1 more.
get_api_contract_reportC
Generate a detailed API Contract validation report with recommendations.
Inputs: projectPath (required).
get_dependency_graphA
The Ultimate Impact Analysis tool for Vibe Coders. Analyzes what files or symbols depend on a target. Use this to understand the "blast radius" of your changes. If you provide a 'symbol', it traces semantic call chains. Set 'includeSource: true' to get a bundled Markdown of all affected code, perfect for pasting into an AI prompt for safe refactoring.
Inputs: target (required), language (required), depth, symbol, +3 more.
get_guardian_alertsA
Get pending alerts from all active Guardians. Returns a compact summary with a pointer to the full LLM-readable alerts file (codeguardian-alerts.json) in the project root.
Inputs: summaryOnly, clearAfterRead.
get_guardian_statusA
Get the current status of VibeGuard. Use this when the user asks for 'vibeguard status', 'what is running', or 'agent health'. Lists all active agents.
Inputs: no named parameters.
get_validation_resultsA
Retrieve final results for a completed validation job. Results are also saved to codeguardian-report.json at the project root, readable by file tools.
Inputs: jobId (required), limit, offset, fileFilter, +2 more.
get_validation_statusA
Check progress of a validation job. Poll every 3-5s until status is 'complete' or 'failed'.
Inputs: jobId (required).
start_guardianB
Activate a VibeGuard Agent. You can start multiple Guardians to watch different parts of your codebase (e.g., one for 'Frontend', one for 'Backend'). Each Guardian watches its own path and language.
Inputs: projectPath (required), mode, language, agent_name.
start_validationA
Start a background validation job for large codebases (>50 files) to avoid timeouts. In monorepos, run this on a scoped subdirectory (e.g., frontend/ or backend/) rather than the repo root. Use 'get_validation_status' to poll for progress. Results are saved to codeguardian-report.json at the project root (readable by file tools, NOT inside .codeguardian/).
Inputs: language (required), projectPath (required), batchSize, strictMode, +2 more.
stop_guardianA
Stop a specific Guardian Agent or all active Guardians.
Inputs: agent_name.
validate_api_contractsA
Validate API contracts between frontend and backend. Detects mismatches in endpoints, types, and parameters before runtime errors occur.
Inputs: projectPath (required), includeTypes, includeEndpoints, includeParameters.
validate_codeA
Validate code snippets or single-file changes for hallucinations, missing dependencies, and dead code in one pass. For full-project or monorepo-wide audits, use start_validation on a scoped subdirectory (e.g., frontend/ or backend/).
Inputs: language (required), projectPath (required), newCode, sessionId, +3 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 12 tools
Most tools have clear, distinct purposes, especially the lifecycle pairs for guardians and validation jobs. The main confusion risk is between validate_code and start_validation, which are distinguished primarily by codebase size, and validate_api_contracts vs get_api_contract_report, which could be seen as overlapping.
Tool names consistently follow a verb_noun pattern with get_, start_, stop_, and validate_ prefixes. There are no mixed casing or naming style violations, making the tool surface predictable.
Twelve tools is well within the sweet spot for a domain with multiple sub-areas: code validation, guardian lifecycle, alert retrieval, dependency analysis, and API contract checking. Each tool contributes a distinct capability without bloating the surface.
The set covers the main validation workflow (start/status/results), guardian lifecycle (start/stop/status/alerts), and API contract validation/reporting. A notable gap is the absence of a cancel or stop operation for background validation jobs, since stop_guardian only applies to Guardians.
Related MCP Connectors
Checks AI-written code for leaked keys and made-up packages, on your machine. Never uploads code.
Codebase intelligence for AI agents — dead code, blast radius, ownership.
Proves AI-generated Python does what you asked: lint, types, security, sandbox run, exact fixes.
Deterministic validation for AI-generated artifacts: JSON Schema, OpenAPI response, SQL syntax.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceEnables AI coding tools to query your live codebase for routes, import graph, domain context, and blast radius, eliminating hallucinations about project structure.37 npm80MIT
- AlicenseNot gradedqualityCmaintenanceA verification layer that lets AI agents safely delete code in large codebases by assessing usage paths and providing risk statuses.7MIT
- AlicenseAqualityDmaintenanceEnables evaluation of AI-generated code across 45 specialized dimensions using deterministic pattern matching and optional LLM-powered deep review, acting as an independent quality gate.31160 npm7MIT
- AlicenseNot gradedqualityBmaintenanceStatic analysis for vibe-coded apps. Flags security, reliability, performance, and AI quality issues in code generated by Cursor, v0, Bolt, and Copilot.893 npm15MIT