Unofficial MCP Server for USWDS

io.github.bibekpdlv0.2.0更新于 Oct 9, 2026

Unofficial USWDS MCP: official markup, class-aware validator, and page composer for AI tools.

已验证STDIO仅桌面Developer ToolsKnowledge & Memory

概览

AI 生成的概览

为助手提供官方 USWDS 组件标记、可识别类名的校验器和页面生成器,用于构建合规的美国政府网页。

功能
提供随包分发的官方美国网页设计系统(USWDS)标记与指南。工具可返回组件和模板 HTML、根据结构化区块组装完整页面、查询真实类名与工具类,并检索 USWDS 文档和无障碍指南。校验器检查片段或整页中不存在的 usa- 类名、必需结构、ARIA 关联、表单结构、标题层级和重复 id,并给出修复建议。所有工具均为只读。
适用场景
当助手编写或审查基于 USWDS 的界面,且你希望标记来自官方模板而非模型记忆时使用。适合构建服务页面、审查现有 USWDS 标记,以及检查 CSS 导入和脚本等项目集成问题。
运行要求
通过 stdio 在本地运行,通常以 npx uswds-mcp 启动,需要 Node.js 和 npm。数据随包提供,无需网络访问、API 密钥或数据导入步骤。仅支持桌面 MCP 客户端。
安装前请注意
非官方且独立,与 GSA、TTS 或官方 USWDS 团队无隶属或背书关系。校验属于静态分析:无法判断颜色对比度、渲染页面的阅读顺序或真实屏幕阅读器行为,仅使用 USWDS 组件也不等于符合 Section 508。自定义的非 usa- 类名不会被校验,上游示例中尖括号内的文本为占位内容。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Unofficial MCP Server for USWDS,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

uswds-mcp

Make AI-generated government UI actually USWDS-compliant.

An MCP server that gives Claude, Cursor, Copilot, Windsurf and any other MCP client the official U.S. Web Design System markup, a validator that knows every real USWDS class, and a page composer that outputs accessible, validated pages.

Unofficial and independent. Not affiliated with, endorsed by, or maintained by GSA, TTS, or the official USWDS team. See NOTICE.md.

The problem

LLMs write USWDS from memory. They invent usa-btn, forget the usa-overlay that makes the mobile menu work, put usa-card markup without its container, and wire up accordions to nothing. The result looks plausible and is subtly broken.

uswds-mcp closes that loop:

text
recommend_uswds_structure  →  get_component_markup  →  compose_uswds_page  →  validate_uswds_markup        (what to use)          (official HTML)         (accessible page)       (fix until 0 errors)
WithoutWith uswds-mcp
Class names recalled from memoryOfficial HTML rendered from the @uswds/uswds templates (178 snippets, ~70 components and page templates, every variant)
"Looks right"Validator rejects any usa-* class that is not in the USWDS stylesheet, with a did-you-mean
Missing structure goes unnoticedBEM, required children, ARIA wiring, form control structure, header overlay, scripts, heading order, duplicate ids, link/image/button names
Stock template outputcompose_uswds_page builds pages from your real sections; zero axe-core violations in CI

What a validator finding looks like

jsonc
{  "severity": "error",  "rule": "unknown-class",  "message": "\"usa-alrt\" is not a class defined by USWDS.",  "selector": "div.usa-alrt",  "snippet": "<div class=\"usa-alrt usa-alert--eror\">",  "suggestion": "Did you mean \"usa-alert\"?"}

Findings carry the offending element, a fix suggestion, the component to look up, and a docs link, so the model can repair its own output.

Quick start

sh
npx -y uswds-mcp

Add it to your MCP client:

json
{  "mcpServers": {    "uswds": { "command": "npx", "args": ["-y", "uswds-mcp"] }  }}

Claude Code: claude mcp add uswds -- npx -y uswds-mcp

Setup for Claude Desktop, Cursor, VS Code, Windsurf and others: docs/CLIENTS.md. Ready-made configs are in examples/.

No network, API key, or ingest step needed: the data ships in the package.

Tools

ToolUse
get_component_markupOfficial HTML for a component/page template and its variants (accordion, footer + slim, sign-in, ...). Understands everyday names (dropdown → select).
compose_uswds_pageBuild a full page from structured sections: hero, content, alert, summary box, cards, process list, step indicator, accordion, table, form, contact.
validate_uswds_markupValidate fragments or full pages: real class names, component structure, forms, ARIA, accessibility basics.
find_uswds_classesLook up real classes, including utilities and responsive variants (margin top 2, tablet grid col 6).
generate_uswds_pageQuick start from free-text requirements; returns an editable section spec, bracketed placeholders, and its own validation.
recommend_uswds_structureUSWDS-first structure for a service or page.
search_uswdsSearch docs, accessibility and usage guidance (with synonym expansion).
get_component / get_pattern / get_templateStructured guidance, plus the canonical markup for components.
get_uswds_integration_recipeFramework setup for Next.js, Vite/React, static HTML, Rails, Drupal.
validate_uswds_project_setupCatch wrong CSS import paths, missing scripts, CDN use, copied dist, global CSS risk.

All tools are read-only. See docs/TOOLS.md for arguments and recommended sequences.

Resources: uswds://component/{slug}, uswds://pattern/{slug}, uswds://template/{slug}, uswds://token/{category}, uswds://package/{name} Prompts: build_agency_website, build_service_page, audit_uswds_page, convert_page_to_uswds, integrate_uswds_in_project

Example

"Build a page where residents renew a fishing permit: eligibility, fees table, steps, FAQ, contact."

The model calls compose_uswds_page and gets back a complete page with banner, skipnav, header (with usa-overlay), breadcrumbs, summary box, striped table with caption and scoped headers, process list, accordion, contact details, slim footer and identifier, plus a list of the placeholders that still need real content, and a validation result.

Prefer to see it first? Run the scorecard:

sh
npm run eval
text
scenario                        unknown classes  errors  warnings  axe violations'Apply for housing assistance'  0                0       0         0'Renew a fishing permit'        0                0       0         0...

Does it help?

In a small test (5 tasks, same model, with and without the server) pages built with uswds-mcp had 0 validator errors on 5 of 5 pages, versus 1 of 5 without it. The model did not invent class names in either case; what it missed without the tools was structure, such as the header overlay that makes the mobile menu work, banner internals, and accordion button types. It is a small, single-run sample, so see the caveats and method in docs/COMPARISON.md.

How it works

  1. Ingest (npm run ingest): renders every official @uswds/uswds twig template with its JSON fixtures into canonical HTML, extracts all class names from the official stylesheet, and indexes the official docs (uswds-site).
  2. Validate against ground truth: the validator is tested against every official snippet (they must pass) and against a corpus of 30 typical LLM mistakes (they must be caught).
  3. Stay current: docs and markup come from the same USWDS version (enforced by a test), and a monthly workflow re-ingests and opens a PR.

Current data: USWDS 3.14.0.

Limits

  • Static analysis. It cannot judge color contrast, reading order on rendered pages, or real screen-reader behavior. USWDS components do not by themselves make a site Section 508 compliant; keep testing with axe, keyboard and screen readers.
  • Custom (non-usa-) classes are allowed and not validated.
  • Upstream fixture text in angle brackets (e.g. <Project title>) is placeholder content.

Develop

sh
npm installnpm test         # unit, self-consistency over official markup, MCP end-to-end, axe-corenpm run evalnpm run ingest   # refresh from upstream

See CONTRIBUTING.md and the CHANGELOG.

License

MIT. See NOTICE.md for USWDS attribution and the licensing notes for indexed USWDS material.

来源:README.md,提交 6424844

工具

0
工具元数据尚未被收录。

版本历史

1
  1. v0.2.0最新Oct 9, 2026