@mohantn/gate-keeper
v2.3.8
Published
Real-time code quality gates & dependency graph for AI-assisted development. MCP server for Claude Code, GitHub Copilot, and any MCP-compatible agent.
Maintainers
Readme
What it is
Gate Keeper is a pure MCP tool server that analyzes code (TypeScript/JS via SonarJS, C# via SonarAnalyzer.CSharp), assigns quality ratings (0–10), and exposes a live dependency graph through 7 MCP tools and a web dashboard.
The AI agent (Claude Code, Copilot, Cline, etc.) calls the MCP tools to understand code quality before editing and verify quality after edits. Gate Keeper provides the analysis — how the AI uses it is up to the agent and its tool-use policy.
Install
npm install -g @mohantn/gate-keeperInstalls two CLI commands: gate-keeper and gk.
Quick Start
gate-keeper setup # Install deps, build, start daemon
gate-keeper daemon # Start the daemon (ports 5378 / 5379)
gate-keeper mcp # Start MCP server (stdio JSON-RPC)
gate-keeper dashboard # Open http://localhost:5378/viz
gate-keeper status # Check daemon health| Command | Description |
|---------|-------------|
| gate-keeper setup | First-time setup: install deps, build, start daemon |
| gate-keeper daemon | Start the daemon (ports 5378 / 5379) |
| gate-keeper mcp | Start the MCP server (stdio JSON-RPC, consumed by AI agents) |
| gate-keeper dashboard | Open the live dashboard in browser |
| gate-keeper status | Check daemon health |
| gk <command> | Short alias for any command |
MCP Tools — 7 Tools
All tools are available via a single MCP server: gate-keeper mcp
| Tool | Input | Output | When to use |
|------|-------|--------|-------------|
| register_repo | repo_path (required) | { repo, isNew, scanTriggered } | Session start — register the repo with the daemon |
| get_quality_rules | None | Scoring thresholds and deduction rules (static) | Session start — understand what's enforced |
| get_file_context | file_path (required), from_cache (optional, default false) | Full quality dossier: rating, violations, imports, dependents, trend | Before AND after editing a file |
| get_method_context | file_path (required), method_name (optional) | Method-level blast radius: calls, dependents, all methods | Before editing a specific method |
| get_dependency_graph | repo (optional) | Full graph in compact LLM-optimized format | Architecture analysis, full repo context |
| get_graph_summary | repo (optional) | Pre-computed analytics: hotspots, worst files, coupling | Session start — codebase overview |
| get_codebase_health | directory (optional), max_files (optional) | Avg rating, distribution, worst files, fix order | After bulk changes (3+ files) |
Key Behavioral Details
register_repo— Only triggers a scan if the repo is new (no cached data). Safe to call multiple times.get_file_context— Whenfrom_cache=truefetches cached data from SQLite (fast). Default (false) runs a full analysis. External hook scripts should passfrom_cache=truefor pre-edit context and omit it for post-edit verification.get_dependency_graph— Returns the full graph which may be large. Useget_graph_summaryfor pre-computed analytics instead.
VS Code / Copilot / Cline Setup
Create .vscode/mcp.json in your project:
{
"servers": {
"gate-keeper": {
"command": "gate-keeper",
"args": ["mcp"]
}
}
}Works with both global install and local clone — gate-keeper is always on PATH.
Architecture
AI Agent (Claude Code / Copilot / Cline)
│
├── MCP tools via stdio JSON-RPC
│ └── gate-keeper mcp
│ └── 7 tools: register_repo, get_file_context, etc.
│
▼
┌──────────────────────────────────────────────────────────────┐
│ Daemon (port 5378 + 5379) │
│ │
│ IPC endpoints: /repo-register, /analyze, /repos, /health │
│ API endpoints: /api/graph, /api/file-detail, /api/trends, │
│ /api/cycles, /api/hotspots, /api/scan, ... │
│ WebSocket: Live updates to dashboard clients │
│ │
│ UniversalAnalyzer pipeline: │
│ readFile → MetricsExtractor → DependencyExtractor │
│ → SonarJS/CSharpAnalyzer → CoverageAnalyzer │
│ → RatingCalculator → SqliteCache → WebSocket │
│ │
└──────────────────────────────────────────────────────────────┘
│
▼
┌──────────────────────────────────────────────────────────────┐
│ SQLite Cache (~/.gate-keeper/cache.db) │
│ Tables: analyses, rating_history, repositories, positions │
└──────────────────────────────────────────────────────────────┘C# Analysis
Gate Keeper analyzes C# files (.cs) through a dual-mode system:
| Mode | When used | Capabilities |
|------|-----------|-------------|
| Roslyn | dotnet 8+ SDK detected | Full AST analysis: violations, type resolution, method calls |
| Regex fallback | No dotnet SDK | Structural analysis: dependencies, metrics, method extraction |
Build the Roslyn analyzer:
npm run build:csharpQuality Workflow
At session start:
// AI agent calls via MCP:
register_repo({ repo_path: "/path/to/project" })
get_quality_rules({})
get_graph_summary({})Before editing a file:
get_file_context({ file_path: "/path/to/file.ts", from_cache: true })
get_method_context({ file_path: "/path/to/file.ts", method_name: "myFunction" })After editing a file:
get_file_context({ file_path: "/path/to/file.ts" })
// ↑ This triggers re-analysis and returns the new ratingAfter bulk changes (3+ files):
get_codebase_health({ directory: "/path/to/project" })Troubleshooting
| Symptom | Cause | Fix |
|---------|-------|-----|
| Daemon won't start | Missing runtime dependency or port conflict | Run npm install -g @mohantn/gate-keeper again, or kill processes on 5378/5379 |
| Agent can't call MCP tools | MCP server not configured | Add .vscode/mcp.json or configure Claude Code settings |
| get_file_context returns no data | Repo hasn't been registered yet | Call register_repo first to trigger initial scan |
| Dashboard shows no data | Daemon not running or repo not scanned | Run gate-keeper daemon then call register_repo |
License
MIT — see LICENSE.
