
Design Constraint Validator
io.github.CseperkePapp由 GitHub 账号 CseperkePapp 发布v2.3.0更新于 Oct 24, 2026
Validate design tokens for accessibility, scales, and design-system constraint consistency.
概览
一个本地 MCP 服务器,让助手按无障碍、比例和阈值约束校验设计令牌,并解释校验结果。
- 可以做什么
- 校验设计令牌(内联或来自文件),检查 WCAG 对比度、阈值、顺序与跨轴约束,可输出汇总表,违规时以非零状态退出。解释单个令牌的来源、别名、依赖项与被依赖项及别名链。导出令牌依赖图的节点与边。列出给定输入下生效的约束。把违规转换为通俗文字说明及机器可读事实。为违规计算一个经过验证的满足值,但不写入任何内容。
- 适用场景
- 适合在设计系统或令牌集上工作时使用,让助手检查对比度、字体与间距层级以及策略阈值,并解释某个令牌为何不通过。它关注值之间的关系,而不是 JSON 结构本身。
- 运行要求
- 作为本地进程通过 stdio 运行,从 npm 包 design-constraint-validator 安装;需要 Node.js 18 或更高版本并支持 ESM。未声明认证、环境变量或请求头。它从工作目录读取令牌 JSON 和可选的配置文件(如 dcv.config.json)。
安装
在 SourceWeft 中
- 打开 控制台中的 Design Constraint Validator,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
Design Constraint Validator (DCV)
Mathematical constraint validator for design systems — ensuring consistency, accessibility, and logical coherence.
[npm version] [npm downloads] [CI] [SBOM] [Supply Chain Security] [License: MIT] [Node]
Design Constraint Validator (DCV) validates design constraints across token sets and styles:
- ✅ Accessibility: WCAG text contrast, perceptual lightness floor/ceilings
- ✅ Order & Monotonicity: increasing typography scales, spacing hierarchies
- ✅ Thresholds & Policies: min/max ranges, cross-axis guards (size × weight × contrast)
- ✅ Graph Intelligence: Hasse/poset graph export; "why" explanations with implicated edges
This is not a schema linter; it's a reasoning validator for values and relationships.
Installation
After a local install, the shorter dcv bin is available (e.g. npx dcv --help).
Requirements: Node.js ≥ 18.x (ESM)
Quick Start
DCV validates your tokens against your constraints. From an empty directory:
These one-offs use the full package name because the bare
dcvbin name on npm belongs to an unrelated package. Afternpm i -D design-constraint-validator, use the shorternpx dcv ….
Example output (validate):
Exit code is 1 when violations are found, 0 when clean (use --fail-on off to always exit 0). The built-in WCAG/threshold defaults target the bundled example token ids, so disable them (as above) when validating your own token names.
Programmatic API
See API Reference for complete programmatic usage.
Use from AI agents (MCP)
DCV ships a second binary, dcv-mcp, that exposes the validator over MCP stdio for agent clients. Add it to a Claude Desktop or generic MCP client config like this:
The server exposes six read-only, JSON-returning tools:
validate- validate inlinetokensor atokensPathagainst inlineconstraintsor a config file.why- explain provenance, aliases, dependencies, dependents, and alias chain for one token id.graph- return token dependencynodesandedges.list-constraints- enumerate the active constraints (WCAG pairs, thresholds, order/lightness scales, cross-axis) for the given input.explain- turn a violation into plain-English text plus machine-readable facts.suggest-fix- compute a verified satisfying value for a violation (WCAG color, threshold/monotonic boundary) without writing anything.
The three derivation tools (list-constraints, explain, suggest-fix) stay read-only — they return suggestions; applying them is up to you (dcv set / dcv patch). See AI Guide for the full agent loop.
Tool failures are returned as structured JSON: { "ok": false, "error": { "code": "...", "message": "..." } }.
Documentation
For Everyone
- Getting Started - 5-minute tutorial
- Features & Complete Guide - All features, examples, and FAQ
- Examples - Sample projects and use cases
For Users
- Constraints - All 5 constraint types in detail
- CLI Reference - Complete command documentation
- Configuration - Config file options
- Concepts - Core terminology and defaults
For Developers
- API Reference - Programmatic usage
- Architecture - Internal design
- Adapters - Input/output formats
Additional Resources
- Prior Art / Method - Design rationale (Decision Themes, receipts)
- AI Guide - Using DCV with ChatGPT/Claude/Copilot
- Contributing - Contribution guidelines
- Security - Supply chain security measures
Why Constraints, Not Conventions?
Conventional linters catch schema issues ("has a value, has a type"). DCV enforces relationships that matter to users and brand integrity:
- Legible contrast under all themes and states
- Proper hierarchical spacing/typography (monotonic scales)
- Coherent cross-axis behavior (e.g., weight increases with size where needed)
- Policy conformance (AA/AAA, internal thresholds)
This transforms tokens from "bags of numbers" into a formal design system.
Comparison: Schema Linters vs DCV
DCV is not affiliated with Anima's
design-tokens-validator(schema-focused).
Input Formats
DCV accepts token JSON (flat or nested) and optional policy JSON. Adapters normalize common ecosystems:
- Style Dictionary - See examples/style-dictionary/
- Tokens Studio JSON - See examples/tokens-studio/
- DTCG (Design Tokens Community Group) — reads the 2025.10 stable spec (structured sRGB colors, structured dimensions,
{alias}references,$extensionspassthrough; non-sRGB spaces warn rather than mis-calculate; composite types out of scope). See examples/dtcg/
Full adapter documentation: Adapters
DCV & DecisionThemes
DCV is the standalone validation engine — use it for any token system.
DecisionThemes (coming 2026) is a complete design system framework built on DCV:
- 5-axis decision model (Tone, Emphasis, Size, Density, Shape)
- VT/DT pipeline (Value Themes + Decision Themes → deterministic CSS configs)
- Studio UI + Hub marketplace for sharing Decision Systems
DCV powers DecisionThemes' validation layer — but works perfectly standalone. Preview: www.decisionthemes.com
Method & Prior Art
The Design Constraint Validator engine is based on a theming and validation method published as defensive prior art.
To understand the underlying architecture (Decision Themes / Value Themes, deterministic compute, post-compute validation and receipts):
These documents keep the method openly implementable and prevent patent lock-up.
Security & Supply Chain
SBOM (Software Bill of Materials)
DCV generates CycloneDX-compliant SBOMs for supply chain transparency:
- CI Builds: SBOM artifacts on every CI run (90-day retention)
- Version tags: SBOM artifacts for release tags
- GitHub Releases: SBOM files (JSON + XML) attached when a GitHub Release is created
- Manual: Run
npx @cyclonedx/cyclonedx-npmin project root
Download:
Roadmap
- Plugin API for custom constraints
- VS Code diagnostics (inline explain)
- Cross-axis packs (typography × weight × contrast)
- Signed / attestable receipts —
dcv validate --receiptalready emits environment + input content hashes today; cryptographic signing is the roadmap part - UI graph explorer (node inspector, violations focus)
Philosophy
Constraints, not conventions.
Design systems need mathematical guarantees. This validator:
- Enforces relationships - Typography hierarchies, color progressions
- Validates accessibility - WCAG contrast with alpha compositing
- Explains violations - Provenance tracing shows why rules fail
- Scales with complexity - Incremental validation of 1000s of tokens
Related Projects
This is the core validation engine. For a complete decision-driven design system with a 5-axis framework (Tone, Emphasis, Size, Density, Shape) and theme configurator UI, see DecisionThemes (coming soon).
Contributing
Contributions welcome! See CONTRIBUTING.md
License
MIT © Cseperke Papp
来源:README.md,提交 be0a35f
工具
0版本历史
1- v2.3.0最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分