ai-quality-gate — Claude Code MCP server: ESLint gate for AI code
Runs AI-written code through ESLint and Prettier, fixes what it can and hands the leftovers back to the agent.
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-gateWhat ai-quality-gate 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.
What it helps with
- 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 for the agent
- Run
quality_fixon 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.
How to install ai-quality-gate
Platform CLI
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-gateReplace <…> with your own values
Platform CLI
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-gateReplace <…> with your own values
Config file
{
"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
Config file
{
"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
Platform CLI
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-gateReplace <…> with your own values
Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about ai-quality-gate
How do I install ai-quality-gate in Claude Code?
Run claude mcp add ai-quality-gate -e SONAR_TOKEN=<SONAR_TOKEN> -- npx -y ai-quality-gate. For the fuller setup with project and SonarQube variables, use the second form with --env PROJECT_ROOT=<PROJECT_ROOT>, SONAR_HOST_URL, SONAR_TOKEN, SONAR_PROJECT_KEY, ENABLE_I18N_RULES and --transport stdio.
What does ai-quality-gate do?
It exposes the quality_fix tool: ESLint and Prettier run over the code, automatic problems get fixed, and whatever remains is reported back to the agent. SonarQube can be added as a second phase.
Is SonarQube required?
No. The ESLint and Prettier phase runs on its own; SonarQube needs sonar-scanner plus SONAR_HOST_URL, SONAR_TOKEN and SONAR_PROJECT_KEY.