|
1 | | -# 🛡️ DevGuardian MCP Server: v2 — The Autonomous Engineering Edition |
| 1 | +# DevGuardian MCP Server — v3 Autonomous Engineering Ecosystem |
2 | 2 |
|
3 | | -> An AI-powered, **Project-Aware** coding assistant MCP server built with **Gemini 2.0 Flash** and **UV**. |
4 | | -> Plug it into **Antigravity** or **Claude Desktop** and get a full AI engineering team: debugging, reviewing, testing, deploying, and securing your code — all autonomously. |
| 3 | +> An AI-powered, project-aware coding assistant MCP server built with Gemini 2.0 Flash and UV. |
| 4 | +> Plug it into Antigravity or Claude Desktop and get a full AI engineering team: debugging, reviewing, testing, deploying, and securing your code — all autonomously. |
5 | 5 |
|
6 | 6 | --- |
7 | 7 |
|
8 | | -## 🌟 What makes DevGuardian a "Monster"? |
| 8 | +## What is DevGuardian? |
9 | 9 |
|
10 | | -DevGuardian v2 is no longer a single script. It is a **multi-agent autonomous engineering ecosystem**: |
| 10 | +DevGuardian v3 is a multi-agent autonomous engineering ecosystem. It goes far beyond a single script — it reads your entire project structure before acting, uses a team of AI agents to validate work iteratively, and now actively repairs its own CI failures. |
11 | 11 |
|
12 | | -1. **🧠 Project DNA Awareness** — Before writing a single line of code, DevGuardian reads your `README`, `pyproject.toml`, full file tree, and import graph. It generates code that *fits your architecture*. |
13 | | -2. **🤖 Agent Swarm** — A 3-agent pipeline (Coder → Tester → Reviewer) that builds features autonomously, finds bugs, and returns production-ready code. |
14 | | -3. **🧪 TDD Auto-Pilot** — Generates pytest tests, runs them, reads failures, fixes the source code, and loops until green. |
15 | | -4. **🌐 GitHub PR Reviewer** — Connects to live GitHub PRs, reads the diffs, and posts a structured expert review. |
16 | | -5. **🐳 DevOps Generator** — Produces a production-grade `Dockerfile`, `docker-compose.yml`, and GitHub Actions `ci.yml` by reading your project stack. |
17 | | -6. **🏗️ God-Mode Mass Refactoring** — Applies a single instruction across **every Python file** in the project simultaneously. |
18 | | -7. **🛡️ Pre-Push Security Gate** — Actively blocks accidental pushes of API keys, tokens, and passwords. |
| 12 | +**Core Design Principles:** |
| 13 | + |
| 14 | +1. **Project DNA Awareness** — Before writing a single line of code, DevGuardian reads your README, `pyproject.toml`, full file tree, and import graph. It generates code that fits your architecture, not generic boilerplate. |
| 15 | +2. **Agent Swarm with Adversarial Review** — A 3-agent pipeline (Coder → Tester → Reviewer) that loops until the code is production-ready. If the Reviewer rejects the code, it sends specific feedback back to the Coder for another pass (up to 3 iterations). |
| 16 | +3. **Semantic Memory** — DevGuardian remembers your coding style preferences and lessons learned across sessions, stored locally in `.devguardian_memory.json`. |
| 17 | +4. **Sandbox Execution** — The Tester agent actually runs the generated code in a safe subprocess to catch runtime errors, not just look for them visually. |
| 18 | +5. **Self-Healing CI** — If a push to `main` fails CI checks, a repair job automatically triggers DevGuardian to diagnose and fix the issue, then re-pushes a repair commit. |
19 | 19 |
|
20 | 20 | --- |
21 | 21 |
|
22 | | -## ✨ Complete Tool Reference (27 Tools) |
| 22 | +## Tool Reference (31 Tools) |
| 23 | + |
| 24 | +### Autonomous Agents |
23 | 25 |
|
24 | | -### 🤖 Autonomous Agents |
25 | 26 | | Tool | Description | |
26 | 27 | |---|---| |
27 | | -| 🤖 `agent_swarm` | **3-Agent Pipeline**: Coder → Tester → Reviewer. Builds features, audits for bugs, returns production-ready code. | |
28 | | -| 🚀 `autonomous_engineer` | **Stateful LangGraph Agent**: Plans, executes tools in loops, verifies work, and self-corrects. | |
| 28 | +| `agent_swarm` | 3-agent pipeline (Coder, Tester, Reviewer) with adversarial feedback loops and sandbox execution. Loops until code is accepted. | |
| 29 | +| `autonomous_engineer` | Stateful LangGraph agent that plans, executes tools in loops, verifies work, and self-corrects. | |
| 30 | + |
| 31 | +### AI Code Intelligence |
29 | 32 |
|
30 | | -### 🧠 AI Code Intelligence |
31 | 33 | | Tool | Description | |
32 | 34 | |---|---| |
33 | | -| `debug_error` | Analyze errors & stack traces; get root cause + fix with project context | |
34 | | -| `explain_code` | Understand what any code does in plain English | |
35 | | -| `review_code` | Full project-aware codebase review: bugs, security, performance, style | |
36 | | -| `generate_code` | Generate clean code tailored to your project's architecture | |
37 | | -| `improve_code` | Refactor and improve existing code consistently | |
| 35 | +| `debug_error` | Analyze errors and stack traces; returns root cause and exact fix with full project context. | |
| 36 | +| `explain_code` | Understand what any code does in plain English. | |
| 37 | +| `review_code` | Project-aware code review covering bugs, security, performance, and style. | |
| 38 | +| `generate_code` | Generate clean code tailored to your project's architecture. | |
| 39 | +| `improve_code` | Refactor and improve existing code consistently. | |
| 40 | + |
| 41 | +### Quality and Testing |
38 | 42 |
|
39 | | -### 🔬 Quality & Testing |
40 | 43 | | Tool | Description | |
41 | 44 | |---|---| |
42 | | -| 🧪 `test_and_fix` | **TDD Auto-Pilot**: generates pytest tests, runs them, fixes source until tests pass | |
43 | | -| 🌐 `review_pull_request` | **GitHub PR Reviewer**: fetches PR diffs from GitHub & performs AI code review | |
| 45 | +| `test_and_fix` | TDD Auto-Pilot: generates pytest tests, runs them, fixes source until tests pass. | |
| 46 | +| `review_pull_request` | Fetches PR diffs from GitHub and performs an AI-powered code review. | |
| 47 | + |
| 48 | +### DevOps and Infrastructure |
44 | 49 |
|
45 | | -### 🐳 DevOps & Infrastructure |
46 | 50 | | Tool | Description | |
47 | 51 | |---|---| |
48 | | -| 🐳 `dockerize` | Auto-generates `Dockerfile` + `docker-compose.yml` for your project | |
49 | | -| 🚀 `generate_ci` | Auto-generates `.github/workflows/ci.yml` (linting, testing, Docker) | |
| 52 | +| `dockerize` | Auto-generates `Dockerfile` and `docker-compose.yml` tailored to your stack. | |
| 53 | +| `generate_ci` | Auto-generates `.github/workflows/ci.yml` with linting, testing, Docker, and self-healing jobs. | |
| 54 | +| `generate_gitignore` | Analyzes your project structure and generates a tailored `.gitignore`. Asks for permission before including `.env` patterns. | |
| 55 | + |
| 56 | +### Architecture and Documentation |
50 | 57 |
|
51 | | -### 🏗️ Mass Operations |
52 | 58 | | Tool | Description | |
53 | 59 | |---|---| |
54 | | -| 🏗️ `mass_refactor` | **God-Mode**: applies one instruction across ALL Python files simultaneously | |
| 60 | +| `generate_architecture_map` | Analyzes internal imports and generates a Mermaid.js dependency diagram of your project. | |
| 61 | +| `generate_technical_docs` | Generates a high-density technical architecture summary using Gemini. | |
| 62 | + |
| 63 | +### Mass Operations |
| 64 | + |
| 65 | +| Tool | Description | |
| 66 | +|---|---| |
| 67 | +| `mass_refactor` | Applies a single instruction across every Python file in the project simultaneously. | |
| 68 | + |
| 69 | +### Security |
55 | 70 |
|
56 | | -### 🛡️ Security |
57 | 71 | | Tool | Description | |
58 | 72 | |---|---| |
59 | | -| 🛂 `validate_env` | Validates `.env` file format safely — never exposes secret values | |
60 | | -| 🔍 `security_scan` | Scans repo for 20+ credential types + missing `.gitignore` rules | |
| 73 | +| `validate_env` | Validates `.env` file format safely — never exposes secret values. | |
| 74 | +| `security_scan` | Scans the repo for 20+ credential types and missing `.gitignore` coverage. | |
| 75 | + |
| 76 | +### Git Suite |
61 | 77 |
|
62 | | -### ⚡ Version Control (Git Suite) |
63 | 78 | | Tool | Description | |
64 | 79 | |---|---| |
65 | | -| ⭐ `smart_commit` | **AI reads your diff → writes commit message → scans for leaks → commits!** | |
66 | | -| `git_status` | Show working tree status | |
67 | | -| `git_add` | Stage files for commit | |
68 | | -| `git_commit` | Commit with a custom message | |
69 | | -| `git_push` | Push to remote **(Protected by Security Gate)** | |
70 | | -| `git_pull` | Pull from remote | |
71 | | -| `git_log` | View commit history | |
72 | | -| `git_diff` | Show staged or unstaged diffs | |
73 | | -| `git_branch` | List all branches | |
74 | | -| `git_checkout` | Switch or create branches | |
75 | | -| `git_stash` | Stash / unstash changes | |
76 | | -| `git_reset` | Reset HEAD (soft, mixed, hard) | |
77 | | -| `git_remote` | List configured remotes | |
| 80 | +| `smart_commit` | AI reads your diff, writes a commit message, scans for credential leaks, then commits. | |
| 81 | +| `git_status` | Show working tree status. | |
| 82 | +| `git_add` | Stage files for commit. | |
| 83 | +| `git_commit` | Commit with a custom message. | |
| 84 | +| `git_push` | Push to remote (protected by the security gate). | |
| 85 | +| `git_pull` | Pull from remote. | |
| 86 | +| `git_log` | View commit history. | |
| 87 | +| `git_diff` | Show staged or unstaged diffs. | |
| 88 | +| `git_branch` | List all branches. | |
| 89 | +| `git_checkout` | Switch or create branches. | |
| 90 | +| `git_stash` | Stash or unstash changes. | |
| 91 | +| `git_reset` | Reset HEAD (soft, mixed, hard). | |
| 92 | +| `git_remote` | List configured remotes. | |
78 | 93 |
|
79 | 94 | --- |
80 | 95 |
|
81 | | -## 🚀 Setup |
| 96 | +## Setup |
82 | 97 |
|
83 | | -### 1. Prerequisites |
| 98 | +### Prerequisites |
84 | 99 | - [UV](https://docs.astral.sh/uv/getting-started/installation/) installed |
85 | 100 | - Python 3.10+ |
86 | 101 | - Git installed |
87 | 102 | - A [Gemini API Key](https://aistudio.google.com/app/apikey) (free) |
88 | 103 |
|
89 | | -### 2. Create virtual environment & install dependencies |
| 104 | +### Installation |
| 105 | + |
90 | 106 | ```bash |
91 | 107 | cd DevGuardian |
92 | 108 | uv venv |
93 | 109 | uv pip install -e . |
94 | 110 | ``` |
95 | 111 |
|
96 | | -### 3. Configure your API key |
| 112 | +### Configure your API key |
| 113 | + |
97 | 114 | ```bash |
98 | 115 | copy .env.example .env |
99 | 116 | # Open .env and paste your Gemini API key |
100 | 117 | # Optionally add GITHUB_TOKEN for private repo PR reviews |
101 | 118 | ``` |
102 | 119 |
|
103 | | -### 4. Test the server runs |
| 120 | +### Test the server runs |
| 121 | + |
104 | 122 | ```bash |
105 | 123 | uv run devguardian |
106 | 124 | ``` |
| 125 | + |
107 | 126 | You should see no errors — the server waits for MCP connections on stdio. |
108 | 127 |
|
109 | 128 | --- |
110 | 129 |
|
111 | | -## 🔌 MCP Configuration |
| 130 | +## MCP Configuration |
112 | 131 |
|
113 | 132 | ### Antigravity (VS Code) |
114 | 133 | Add to your `.gemini/settings.json`: |
@@ -145,86 +164,102 @@ Add to `%APPDATA%\Claude\claude_desktop_config.json`: |
145 | 164 |
|
146 | 165 | --- |
147 | 166 |
|
148 | | -## 💡 Usage Examples |
| 167 | +## Usage Examples |
149 | 168 |
|
150 | | -### 🤖 Agent Swarm — Build a feature with 3 AI agents |
| 169 | +**Agent Swarm — Build a feature with 3 AI agents** |
151 | 170 | > "DevGuardian, use the agent swarm to create a rate-limiting utility for our API." |
152 | | -→ Coder writes a `RateLimiter` class, Tester finds 5 edge cases, Reviewer incorporates all fixes and returns the final production-ready file. |
| 171 | +> Coder writes a `RateLimiter` class. Tester finds edge cases. Reviewer rejects and sends feedback. Coder fixes. Reviewer accepts on pass 2. Final production-ready file is returned. |
153 | 172 |
|
154 | | -### 🧪 TDD Auto-Pilot — Test-driven bug fixing |
| 173 | +**TDD Auto-Pilot — Test-driven bug fixing** |
155 | 174 | > "Run test_and_fix on `devguardian/tools/debugger.py`" |
156 | | -→ DevGuardian writes pytest tests, runs them, reads the failures, patches the source, and loops until all tests go green. |
| 175 | +> DevGuardian writes pytest tests, runs them, reads the failures, patches the source, and loops until all tests go green. |
157 | 176 |
|
158 | | -### 🌐 GitHub PR Review — Review any live PR |
| 177 | +**PR Review — Review any live pull request** |
159 | 178 | > "Review PR #42 in myorg/myrepo" |
160 | | -→ DevGuardian fetches the diff from GitHub and gives you a structured review: Bugs, Security, Performance, Style, and a final verdict. |
| 179 | +> DevGuardian fetches the diff from GitHub and produces a structured review covering bugs, security, performance, and style. |
161 | 180 |
|
162 | | -### 🐳 Dockerize a project in seconds |
163 | | -> "Dockerize this project." |
164 | | -→ DevGuardian reads your stack from `pyproject.toml`, generates a multi-stage `Dockerfile` and `docker-compose.yml`, and writes them to your project root. |
| 181 | +**Architecture Map — Visualize your codebase** |
| 182 | +> "Generate an architecture map for this project." |
| 183 | +> DevGuardian scans all internal imports and produces a Mermaid.js dependency diagram showing how every file connects to every other file. |
165 | 184 |
|
166 | | -### 🏗️ Mass Refactoring |
167 | | -> "Add type hints to all function signatures in the project." |
168 | | -→ DevGuardian scans every `.py` file, rewrites functions that need type hints, and reports all 14 files it modified. |
| 185 | +**Smart .gitignore — Context-aware generation** |
| 186 | +> "Generate a gitignore for this project." |
| 187 | +> DevGuardian reads your tech stack and file structure. It asks for your permission before including `.env` patterns, then generates a tailored file — not a generic template. |
169 | 188 |
|
170 | | -### 🛡️ Push Code Safely |
| 189 | +**Push Code Safely** |
171 | 190 | > "Push my changes to main." |
172 | | -→ DevGuardian scans all staged files. If it finds `api_key = "AIzaSy..."` hardcoded anywhere, it **BLOCKS the push** and tells you exactly which file and line contains the secret. |
| 191 | +> DevGuardian scans all staged files. If it detects a hardcoded API key or token, it blocks the push and reports the exact file and line number. |
173 | 192 |
|
174 | 193 | --- |
175 | 194 |
|
176 | | -## 📁 Project Structure |
| 195 | +## Project Structure |
| 196 | + |
177 | 197 | ``` |
178 | 198 | DevGuardian/ |
179 | | -├── .env.example ← Copy to .env, add your API key |
180 | | -├── .gitignore ← Comprehensive security-focused rules |
181 | | -├── pyproject.toml ← UV project config (dependencies) |
182 | | -├── Dockerfile ← 🐳 Auto-generated production container |
183 | | -├── docker-compose.yml ← 🐳 Auto-generated service orchestration |
| 199 | +├── .env.example Copy to .env and add your API key |
| 200 | +├── .gitignore Security-focused ignore rules |
| 201 | +├── pyproject.toml UV project config and dependencies |
| 202 | +├── Dockerfile Production container |
| 203 | +├── docker-compose.yml Service orchestration |
184 | 204 | ├── README.md |
185 | 205 | ├── tests/ |
186 | | -│ └── test_debugger.py ← 🧪 TDD Auto-Pilot generated tests |
| 206 | +│ └── test_debugger.py TDD-generated test suite |
187 | 207 | ├── .github/ |
188 | 208 | │ └── workflows/ |
189 | | -│ └── ci.yml ← 🚀 Auto-generated GitHub Actions CI/CD |
| 209 | +│ └── ci.yml GitHub Actions CI/CD with self-healing job |
190 | 210 | └── devguardian/ |
191 | | - ├── server.py ← Robust MCP server (27 tools, logging, error handling) |
| 211 | + ├── server.py MCP server entry point (31 tools) |
192 | 212 | ├── agents/ |
193 | | - │ ├── engineer.py ← Single stateful LangGraph agent |
194 | | - │ └── swarm.py ← 🤖 3-Agent Swarm (Coder + Tester + Reviewer) |
| 213 | + │ ├── engineer.py Stateful LangGraph autonomous agent |
| 214 | + │ └── swarm.py 3-Agent Swarm v3 with adversarial loops |
195 | 215 | ├── tools/ |
196 | | - │ ├── debugger.py ← debug_error |
197 | | - │ ├── code_helper.py ← explain, review, generate, improve |
198 | | - │ ├── git_ops.py ← Full git suite + ⭐ smart_commit |
199 | | - │ ├── tdd.py ← 🧪 TDD Auto-Pilot |
200 | | - │ ├── github_review.py ← 🌐 GitHub PR Reviewer |
201 | | - │ ├── infra.py ← 🐳 Dockerfile + CI/CD generator |
202 | | - │ └── mass_refactor.py ← 🏗️ God-Mode mass refactoring |
| 216 | + │ ├── debugger.py debug_error |
| 217 | + │ ├── code_helper.py explain, review, generate, improve |
| 218 | + │ ├── git_ops.py Full git suite + smart_commit |
| 219 | + │ ├── tdd.py TDD Auto-Pilot |
| 220 | + │ ├── github_review.py GitHub PR Reviewer |
| 221 | + │ ├── infra.py Dockerfile, CI/CD, and gitignore generators |
| 222 | + │ ├── architect.py Architecture mapping and technical docs |
| 223 | + │ ├── self_healing.py CI failure detection and repair engine |
| 224 | + │ └── mass_refactor.py Mass codebase refactoring |
203 | 225 | └── utils/ |
204 | | - ├── gemini_client.py ← Gemini 2.0 Flash wrapper (lazy init) |
205 | | - ├── file_reader.py ← 🧠 Project DNA Context Builder |
206 | | - ├── security.py ← 🛡️ Pre-push secret gate & .env validator |
207 | | - └── memory.py ← Threading & Agent state management |
| 226 | + ├── gemini_client.py Gemini 2.0 Flash wrapper |
| 227 | + ├── file_reader.py Project DNA context builder |
| 228 | + ├── security.py Pre-push security gate and .env validator |
| 229 | + ├── memory.py Persistent semantic memory (JSON-based) |
| 230 | + └── executor.py Safe subprocess execution sandbox |
208 | 231 | ``` |
209 | 232 |
|
210 | 233 | --- |
211 | 234 |
|
212 | | -## 🔐 Enterprise-Grade Security |
| 235 | +## Security Model |
213 | 236 |
|
214 | | -- **Anti-Leak Shield**: `security.py` detects 20+ credential types (AWS, GitHub, OpenAI, Google, Stripe, Slack…) before any `git push` or `smart_commit`. |
215 | | -- **Smart Detection**: Only flags **hardcoded quoted values** — never false-positives on `os.getenv()` calls. |
216 | | -- **`.env` Safety**: `validate_env` reviews your `.env` file format — shows keys but **never exposes values**. |
| 237 | +- **Anti-Leak Shield**: `security.py` detects 20+ credential types (AWS, GitHub, OpenAI, Google, Stripe, Slack) before any `git push` or `smart_commit`. |
| 238 | +- **Precise Detection**: Only flags hardcoded quoted values — no false positives on `os.getenv()` calls. |
| 239 | +- **Env Safety**: `validate_env` reviews your `.env` file structure — shows keys but never exposes values. |
| 240 | +- **Permission-Based Gitignore**: The `generate_gitignore` tool asks for explicit user permission before adding `.env` patterns — nothing is done without your approval. |
217 | 241 | - **Local Execution**: Your code never leaves your machine except for Gemini API calls. |
218 | 242 |
|
219 | 243 | --- |
220 | 244 |
|
221 | | -## 🐳 Docker |
| 245 | +## CI/CD Pipeline |
| 246 | + |
| 247 | +The pipeline runs on every push and pull request to `main`: |
| 248 | + |
| 249 | +1. **lint** — Ruff checks code style and format |
| 250 | +2. **test** — Pytest runs the full test suite with coverage |
| 251 | +3. **Self-Healing Repair** — Triggers only if lint or test fails. Uses the Agent Swarm to diagnose, fix, and re-push a repair commit automatically. |
| 252 | +4. **build** — Builds the Python package |
| 253 | +5. **docker** — Builds the Docker image |
| 254 | + |
| 255 | +--- |
| 256 | + |
| 257 | +## Docker |
222 | 258 |
|
223 | 259 | ```bash |
224 | | -# Build and run DevGuardian in a container |
225 | 260 | docker compose up --build |
226 | 261 | ``` |
227 | 262 |
|
228 | 263 | --- |
229 | 264 |
|
230 | | -*Built with ❤️ by **Karan** using Gemini 2.0 Flash + LangGraph + MCP SDK + UV* |
| 265 | +*Built by Karan using Gemini 2.0 Flash, LangGraph, MCP SDK, and UV.* |
0 commit comments