# ai-quality-gate

Runs AI-written code through ESLint and Prettier, fixes what it can and hands the leftovers back to the agent.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed, Gemini CLI · ★ 31
- Author: mustafacagri
- License: MIT · policy=link-only · description only; the file stays with the author
- Source: https://github.com/mustafacagri/ai-quality-gate
- Updated: 2026-10-07
- HTML: https://affpapa.org/en/nevibecode/mcp/ai-quality-gate

## What it does

Your agent calls the `quality_fix` tool after editing files. The server lints them with a bundled set of 627 ESLint rules plus Prettier, auto-corrects the fixable part, then returns the rest as text the model can act on. Phase one takes roughly 2–8 seconds and always runs. SonarQube is optional and slower — around 30–60 seconds — so the write-check-fix loop stays short when you skip it.

Formatting follows your project's Prettier config, while the lint rules come from the server. Your indentation stays as it is; the quality bar becomes the same for everyone who plugged the gate in. A call only happens if the editor tells the agent to make it: add a rule like “after every code change, call `quality_fix` before saying done”. Without that rule the server just sits idle.

Node.js 20.10+ or 21.1+ has to be on `PATH`. The project root is found automatically by walking up from the working directory until `package.json` or `tsconfig.json` shows up; set `PROJECT_ROOT` when your layout breaks that guess. Phase two wants a running SonarQube, `sonar-scanner` and `SONAR_HOST_URL`, `SONAR_TOKEN`, `SONAR_PROJECT_KEY`. Leave them out and you still get the ESLint half.

## Requirements
- Needs: Node.js (commands run via npx)
- Environment variables: `PROJECT_ROOT`, `SONAR_HOST_URL`, `SONAR_TOKEN`, `SONAR_PROJECT_KEY`, `ENABLE_I18N_RULES` — keys and tokens: ask the human for the values, never commit them or put them in shared files.

## Install

### Claude Code (native platform)

**Platform CLI**
```bash
claude mcp add --env PROJECT_ROOT=<PROJECT_ROOT> --env SONAR_HOST_URL=<SONAR_HOST_URL> --env SONAR_TOKEN=<SONAR_TOKEN> --env SONAR_PROJECT_KEY=<SONAR_PROJECT_KEY> --env ENABLE_I18N_RULES=<ENABLE_I18N_RULES> --transport stdio ai-quality-gate -- npx -y ai-quality-gate
```
Replace <…> with your own values

### Codex

**Platform CLI**
```bash
codex mcp add ai-quality-gate --env PROJECT_ROOT=<PROJECT_ROOT> --env SONAR_HOST_URL=<SONAR_HOST_URL> --env SONAR_TOKEN=<SONAR_TOKEN> --env SONAR_PROJECT_KEY=<SONAR_PROJECT_KEY> --env ENABLE_I18N_RULES=<ENABLE_I18N_RULES> -- npx -y ai-quality-gate
```
Replace <…> with your own values

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "mcpServers": {
        "ai-quality-gate": {
            "command": "npx",
            "args": [
                "-y",
                "ai-quality-gate"
            ],
            "env": {
                "PROJECT_ROOT": "<PROJECT_ROOT>",
                "SONAR_HOST_URL": "<SONAR_HOST_URL>",
                "SONAR_TOKEN": "<SONAR_TOKEN>",
                "SONAR_PROJECT_KEY": "<SONAR_PROJECT_KEY>",
                "ENABLE_I18N_RULES": "<ENABLE_I18N_RULES>"
            }
        }
    }
}
```
Replace <…> with your own values

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "servers": {
        "ai-quality-gate": {
            "type": "stdio",
            "command": "npx",
            "args": [
                "-y",
                "ai-quality-gate"
            ],
            "env": {
                "PROJECT_ROOT": "<PROJECT_ROOT>",
                "SONAR_HOST_URL": "<SONAR_HOST_URL>",
                "SONAR_TOKEN": "<SONAR_TOKEN>",
                "SONAR_PROJECT_KEY": "<SONAR_PROJECT_KEY>",
                "ENABLE_I18N_RULES": "<ENABLE_I18N_RULES>"
            }
        }
    }
}
```
Replace <…> with your own values

### Gemini CLI

**Platform CLI**
```bash
gemini mcp add -e PROJECT_ROOT=<PROJECT_ROOT> -e SONAR_HOST_URL=<SONAR_HOST_URL> -e SONAR_TOKEN=<SONAR_TOKEN> -e SONAR_PROJECT_KEY=<SONAR_PROJECT_KEY> -e ENABLE_I18N_RULES=<ENABLE_I18N_RULES> ai-quality-gate npx -y ai-quality-gate
```
Replace <…> with your own values

## When to use it
- lint fresh agent output before a commit
- strip unused imports without a manual pass
- apply project Prettier settings to generated files
- return a concrete fix list to the model
- attach a SonarQube scan to the same tool call

## Example prompts
- Run `quality_fix` on the files you just changed and list what's left.
- Gate the edited files and fix the reported issues.
- Check the code before you tell me the task is done.

## Similar
- [Front-End Checklist](https://affpapa.org/en/nevibecode/mcp/front-end-checklist.md) — MCP server · ★ 74559
- [Codebase Memory](https://affpapa.org/en/nevibecode/mcp/codebase-memory.md) — MCP server · ★ 47392
- [Serena MCP: the IDE for your agent](https://affpapa.org/en/nevibecode/mcp/serena-mcp-the-ide-for-your-agent.md) — MCP server · ★ 30677
- [Repomix](https://affpapa.org/en/nevibecode/mcp/repomix.md) — MCP server · ★ 29027
- [Repowise](https://affpapa.org/en/nevibecode/mcp/repowise.md) — MCP server · ★ 7891
- [sem](https://affpapa.org/en/nevibecode/mcp/sem.md) — MCP server · ★ 3422

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
