@agent-guardrail/mcp-server
by albetsurya
README.md
<div align="center">

# AgentGuardrail
**Universal AI Coding Guardrails — Keep your AI build on course.**
[](https://nodejs.org/)
[](https://www.typescriptlang.org/)
[](https://ts.sdk.modelcontextprotocol.io/v2/)
[](LICENSE)
[Quick Start](#-quick-start) · [Screenshots](#-screenshots) · [Capabilities](#-five-core-capabilities) · [Integrations](#-platform-integrations) · [Architecture](#-architecture--security)
</div>
---
## Why AgentGuardrail?
AI coding assistants write code rapidly, but conversational *vibe coding* introduces four recurring engineering failures:
1. **Scope Drift** — Agents eagerly add unapproved features (payment gateways, extra frameworks, refactors) mid-sprint without surfacing cost or timeline impact.
2. **Session Amnesia** — Switching between Cursor, Claude Code, or Codex forces you to re-explain the product goal, stack decisions, and current blockers.
3. **Unverified "Done" Claims** — Models frequently report tasks finished without running tests or linking verifiable evidence.
4. **Unclear Next Steps** — Backlogs balloon into speculative lists instead of focusing on one deliverable slice at a time.
**AgentGuardrail** solves this by placing a deterministic, local-first guardrail layer between you and your coding agents. It exposes a token-efficient **6-tool MCP contract** (`guardrail_read`, `guardrail_project`, `guardrail_plan`, `guardrail_scope_guard`, `guardrail_verify`, `guardrail_handoff`), **4 resources** (`guardrail://...`), **3 workflow prompts**, a **terminal CLI (`agent-guard`)**, and **portable Agent Skills** backed by human-readable JSON state inside `.agentguardrail/`.
> AgentGuardrail is a **project workflow guardrail**, not an autonomous coding agent or a universal execution security sandbox. MCP governs structured project state and verification evidence; preventing arbitrary host file writes or shell commands outside AgentGuardrail requires each coding host's native hooks and permissions.
---
## 🎯 Five Core Capabilities
| Capability | Purpose | Guardrail Enforcement |
| :--- | :--- | :--- |
| **1. Project Compass** | Captures product outcome, target users, constraints, and approved non-goals. | Rejects silent brief mutations until explicitly approved by a human. |
| **2. Scope Guard** | Evaluates new feature requests against the agreed MVP boundary. | Blocks direct scope expansion; forces a qualitative impact proposal (`SCOPE-*`) requiring explicit approval. |
| **3. Next Action Engine** | Calculates the highest-priority ready task inside the active milestone. | Respects task dependencies (with cycle detection) and prevents multi-task sprawl. |
| **4. Verification Gate** | Enforces acceptance criteria and distinguishes verification provenance (`host_observed` with exit code, `human_confirmed`, or `agent_reported`). | Completion tools reject missing proof (`VERIFICATION_REQUIRED`), validate exit codes, and support `--require-trusted` / `require_trusted`. |
| **5. Context Handoff** | Serializes decisions, modified files, blockers, and next actions. | Allows Claude Code, Codex, Cursor, Antigravity, and OpenCode to resume seamlessly with zero transcript dependency. |
---
## 📸 Screenshots
### Discovery, Scope Guard & Project Status
Catching unapproved scope creep mid-sprint and preserving explicit MVP boundaries from the terminal:

### Verification Gate & Cross-Agent Handoff
Blocking premature task completion until concrete test proof is recorded, then generating a resumable handoff snapshot:

---
## 🚀 Quick Start
### Prerequisites
- **Node.js** `22.14+`
### Zero-Clone Usage (`npx` / `pnpm dlx`)
Run directly in any repository without cloning or building manually:
```bash
# Auto-detect AI hosts, install skills, and safely merge MCP config in one command
npx @agent-guardrail/cli setup
# Run interactive beginner-friendly project discovery
npx @agent-guardrail/cli init --interactive
# Or with pnpm dlx
pnpm dlx @agent-guardrail/cli init --interactive
# Check repository state & integrity
npx @agent-guardrail/cli status
npx @agent-guardrail/cli doctor
```
Configure your coding agent's MCP server using:
```json
{
"command": "npx",
"args": ["-y", "@agent-guardrail/mcp-server"],
"env": {
"AGENT_GUARDRAIL_ROOT": "/ABSOLUTE/PATH/TO/TARGET/PROJECT"
}
}
```
### Local Source Setup (Contributors)
```bash
git clone https://github.com/albetsurya/agent-guardrail.git
cd agent-guardrail
corepack enable
pnpm install --frozen-lockfile
pnpm check
pnpm build
pnpm verify:release
```
---
## 🔌 Platform Integrations
AgentGuardrail ships a single shared MCP server (`@agent-guardrail/mcp-server`) over `stdio` alongside canonical Agent Skills (`skills/`) synchronized across five ecosystems:
| AI Host | MCP Transport | Native Packaging & Skills | Config Template |
| :--- | :--- | :--- | :--- |
| **Claude Code** | `stdio` | `.claude-plugin/plugin.json`, `.mcp.json`, `skills/` | [claude-code.mcp.json](examples/platforms/claude-code.mcp.json) |
| **OpenAI Codex** | `stdio` | `.codex-plugin/plugin.json`, `skills/` | [codex-config.toml](examples/platforms/codex-config.toml) |
| **Cursor** | `stdio` | `plugin.json`, `mcp.json`, `skills/` | [cursor.mcp.json](examples/platforms/cursor.mcp.json) |
| **Google Antigravity** | `stdio` | `.antigravity-plugin/plugin.json`, `mcp_config.json`, `rules/agent-guardrail.md`, `skills/` | [antigravity.mcp_config.json](examples/platforms/antigravity.mcp_config.json) |
| **OpenCode** | `stdio` | `opencode.json` (`mcp.servers`), `.opencode/skills/` | [opencode.json](examples/platforms/opencode.json) |
To install canonical skills or configure MCP in a target project without cloning (core guardrail skills by default, or opt-in to the optional Anti-Slop quality skills `anti-slop-code`, `anti-slop-copywriting`, `anti-slop-ui`, and `anti-slop-human`):
```bash
# One-command interactive setup (auto-detects hosts + merges MCP config safely)
npx @agent-guardrail/cli setup
# One-command setup with lifecycle hooks (strict allowed_paths enforcement) + Anti-Slop skills
npx @agent-guardrail/cli setup --with-antislop --with-hooks --strict-hooks --yes
# Global user-home install or update across projects
npx @agent-guardrail/cli setup --global --with-antislop --update
# Or granular zero-clone commands
npx @agent-guardrail/cli inventory
npx @agent-guardrail/cli audit --fail-on-findings
npx @agent-guardrail/cli skills list
npx @agent-guardrail/cli skills install --target opencode --dry-run
npx @agent-guardrail/cli skills install --target claude-code --with-antislop
npx @agent-guardrail/cli skills remove --target claude-code
npx @agent-guardrail/cli mcp-config --target cursor
# Or install via native plugin / skills ecosystems (once published/hosted)
agy plugin install https://github.com/albetsurya/agent-guardrail
npx skills add albetsurya/agent-guardrail
# Or from a local repository checkout
node scripts/skills.mjs install --target claude-code --dest /PATH/TO/TARGET/PROJECT --with-antislop
```
---
## 🛡 Architecture & Security
```text
[ Claude Code ] [ Codex ] [ Cursor ] [ Antigravity ] [ OpenCode ]
│ │ │ │ │
└──────────────┴────────────┴───────┬───────┴───────────────┘
│ stdio JSON-RPC (MCP SDK v2)
▼
┌────────────────────────────────────────────────────────────────────┐
│ @agent-guardrail/mcp-server & @agent-guardrail/cli │
└────────────────────────────────┬───────────────────────────────────┘
▼
┌────────────────────────────────────────────────────────────────────┐
│ @agent-guardrail/core (Deterministic Domain & Guardrail Engine) │
│ • Zod v4 strict validation & state machines │
│ • Atomic temp-file writes + exclusive .write.lock (stale PID safe)│
│ • Optimistic revision control (REVISION_CONFLICT) │
│ • Symlink-escape prevention (root, directory, leaf file checks) │
│ • Corrupt JSON quarantine snapshots (.backups/) │
└────────────────────────────────┬───────────────────────────────────┘
▼
.agentguardrail/ (Local JSON/MD)
```
### Core Guarantees
- **Token-Efficient MCP Contract**: Only 6 cohesive tools (~77% fewer tool definitions than naive 1:1 mappings) preserve LLM context window space alongside other MCP servers.
- **Zero Cloud & Zero Telemetry**: 100% local-first execution; `src/` contains zero network clients or arbitrary shell execution (`child_process` banned in core/server source via AST security tests).
- **Clean Packaging**: Publishable workspace tarballs exclude test suites, `.tsbuildinfo`, `.env`, and runtime state.
---
## 📚 Documentation
- [Product Requirements](docs/product-requirements.md) — Goals, non-goals, and user workflows
- [Architecture](docs/architecture.md) — Monorepo layout and modular core design
- [CLI Specification](docs/cli.md) — Complete `agent-guard` command surface and exit codes
- [MCP Tool Contract](docs/mcp-tools.md) — Schemas for the 6 tools, 4 `guardrail://` resources, and 3 prompts
- [End-to-End Walkthrough](examples/workflows/empty-to-done.md) — Complete lifecycle from empty folder to verified handoff
- [Platform Compatibility](docs/platform-compatibility.md) — Host capabilities and validation status
- [Platform Install Guide](docs/platform-install.md) — Step-by-step setup per IDE/agent
- [Security Model](docs/security.md) & [Security Policy](SECURITY.md) — Threat model, symlink jails, and responsible disclosure
- [Contributing](CONTRIBUTING.md), [Code of Conduct](CODE_OF_CONDUCT.md), and [Third-Party Notices](THIRD_PARTY_NOTICES.md) — Contributor workflow and MIT attribution
- [Changelog](CHANGELOG.md) — Release history
---
## 📄 License
Distributed under the **MIT License**. See [LICENSE](LICENSE) for full details.
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues