Local-first MCP server in Go that analyzes Next.js App Router + Tailwind + shadcn/ui repositories and produces structured specs, critiques, and quality gates for AI coding agents like OpenCode and Codex.
Frontgate acts as a frontend quality layer between you and your AI coding agent. It:
- Analyzes your Next.js project's design tokens, spacing patterns, reusable components, routes, and shell layouts
- Builds art-directed specs from natural language tasks, combining repo context with your own visual references (see Visual References Workflow) so Codex/OpenCode generate layouts with premium identity
- Critiques generated UI diffs for spacing issues, component overuse, generic language, missing reuse, generic CTA copy, CDN font usage, gradient/shadow abuse, etc.
- Scores output across 10 weighted quality axes (spacing, hierarchy, layout balance, component reuse, token adherence, density, noise, template-likeness, UX clarity, product alignment)
- Gates changes with threshold-based approval/rejection and required corrective actions
- Go 1.22+
- Node.js (for Playwright MCP)
- Playwright MCP — required for the
critique_ui_outputtool to perform DOM/CSS render analysis. Without it, critique still works but skips the optional render analysis.
go build -o frontgate-mcp ./cmd/frontgate-mcpgo test ./...python3 scripts/smoke_mcp.pyOr against a specific project:
python3 scripts/smoke_mcp.py --project /absolute/path/to/your/next-app| Tool | Description |
|---|---|
analyze_ui_context |
Scans a Next.js project for framework, design tokens, spacing, primitives, routes, shell patterns, and visual risks |
build_ui_spec |
Produces an art-directed design brief that merges repo context with your references/ images (typography, color, layout, animation, anti-patterns, next/font guidance) |
critique_ui_output |
Audits diffs for spacing issues, generic CTA copy, CDN font usage, gradient/shadow abuse, raw primitives, and optional Playwright DOM/CSS metrics |
score_ui_quality |
Weighted scoring across 10 quality axes with axis-level explanations |
gate_ui_change |
Applies a quality threshold and blocks high-severity issues, returning required corrective actions |
get_design_guidelines |
Retrieves curated guidelines from the benchmarks/skills corpus, filtered by category or query, plus the current art brief |
list_visual_references |
Lists every reference image under references/ along with descriptions and the aggregated art brief |
add_visual_reference |
Adds/updates metadata for an existing reference image to further tune the art direction |
The project includes an opencode.json at the repo root. Add the frontgate and playwright blocks to your own opencode.json:
{
"mcp": {
"frontgate": {
"type": "local",
"command": ["/absolute/path/to/frontgate-mcp"],
"enabled": true,
"timeout": 120000
},
"playwright": {
"type": "local",
"command": ["npx", "@playwright/mcp@latest", "--isolated"],
"enabled": true,
"timeout": 25000
}
}
}Important: The
playwrightMCP server is required forcritique_ui_outputto run its optional DOM/CSS render analysis. If you omit it, critique will still work but will skip the Playwright-based analysis step.
Add to ~/.codex/config.toml:
[mcp_servers.frontgate]
command = "/absolute/path/to/frontgate-mcp"
startup_timeout_sec = 15
tool_timeout_sec = 120For Playwright support in Codex, configure the Playwright MCP server in your Codex setup as well.
Frontgate treats your reference board as part of the spec:
- Drop JPG/PNG/WEBP files into
references/(subdirectories such asreferences/generated-by-mcp/are also scanned; the repo already ships with 20 samples). - Run
list_visual_referencesto inspect the current art brief and descriptions for each image. - Use
add_visual_referenceto describe new images (description + optionalstyleandelements). Metadata is stored inreferences/references.json. - Every
build_ui_speccall pulls that art brief and forces the agent to respect it (color, typography, layout, motion, anti-patterns,next/fontusage). get_design_guidelinesalso includes the same art brief next to the benchmarks/skills corpus so you can mix deterministic heuristics with your aesthetic direction.
Font & animation guidance: the spec explicitly instructs the agent to load fonts via next/font (never <link>/@import from CDN) and to treat motion, gradients, and shapes as purposeful art direction. critique_ui_output flags CDN font usage, generic CTA copy, template layouts, and visual noise.
critique_ui_output shells out to Playwright via Node.js. The MCP attempts module resolution in this order:
render_request.working_dir/node_modules(so install Playwright in the target project:npm install -D playwright)- Existing
NODE_PATHentries - Global npm root (
npm root -g) — works if you runnpm install -g playwright
If none of these contain playwright, the tool will raise playwright package not found in current Node resolution path. Installing locally is still recommended because it keeps browsers/scripts versioned with the project.
frontgate-mcp/
cmd/frontgate-mcp/ # Entry point (main.go)
internal/
mcp/ # MCP server, tool registration
types/ # Shared types
repo/ # Repository analyzer
spec/ # Task-to-spec builder
critic/ # Diff critique engine
scoring/ # Weighted quality scoring
rules/ # Heuristic rules
parser/ # package.json and token parsers
playwright/ # Optional Playwright render runner
output/ # Output formatting
scripts/
smoke_mcp.py # Smoke test harness
frontgate_stdio_proxy.py # stdio proxy for debugging
run_frontgate.sh # Launch helper
benchmarks/ # Benchmarks
references/ # Visual reference images + references.json art brief
- Analyze — The agent calls
analyze_ui_contextwith your project path to understand your codebase's patterns - Spec — The agent calls
build_ui_specwith a task description to get a structured spec with constraints and acceptance criteria - Generate — The agent (Codex/OpenCode) implements the spec
- Critique — The agent calls
critique_ui_outputwith the generated diff - Score — The agent calls
score_ui_qualityto get weighted scores - Gate — The agent calls
gate_ui_changeto check if the output passes quality thresholds
Currently targets:
- Next.js App Router
- Tailwind CSS
- shadcn/ui (with Radix UI primitives)
DaisyUI detection is supported. Other frameworks may partially work but are not officially supported.
- Narrow to Next.js App Router + Tailwind + shadcn/ui
- Route understanding is structural, not semantic
- Token extraction is strongest when CSS variables exist
- Playwright render analysis depends on the target project having a usable local runtime and the
playwrightpackage - Critique is heuristic-based, not a substitute for product judgment