Tailwind Context Resolver Mcp

io.github.vola-trebla由 GitHub 账号 vola-trebla 发布v0.2.0更新于 Oct 24, 2026

Resolves Tailwind CSS design tokens and validates utility classes against the local project config.

发布方自己的服务:Tailwind App

已验证STDIO仅桌面开发者工具AI 与机器学习

概览

AI 生成的概览

让助手读取项目已解析的 Tailwind CSS v3 主题,并据此校验工具类字符串。

可以做什么
加载项目的 tailwind.config.js 或 .ts,并通过四个工具暴露解析后的设计系统。resolve_theme_tokens 返回某个命名空间(如 colors.brand、spacing)下的令牌;validate_class_string 把 className 字符串拆分为有效与无效类并提示冲突;detect_css_conflicts 报告相互冲突的工具类,例如 flex 与 grid;get_config_summary 报告 Tailwind 版本、前缀、被定制的主题分区和插件。校验基于令牌,而非完整的 PostCSS/JIT 流程。
适用场景
当助手在带有自定义调色板、间距刻度、前缀或品牌令牌的项目中编写 Tailwind 类时适用,可让它对照真实配置而非默认主题检查类名。最适合在已有的 Tailwind v3 代码库中做组件或界面相关工作。
运行要求
以 stdio 在本地运行,通常用 npx 启动。需要 Node.js 18+,以及项目中的 tailwind.config.js 或 tailwind.config.ts。仅支持 Tailwind CSS v3,v4 的 CSS 配置格式不受支持。未声明需要账号、API 密钥或环境变量。
安装前请注意
会读取项目的 Tailwind 配置,因此应指向预期的项目目录。它只读取和校验,不会修改文件,也不会向第三方发送数据。不要求任何凭据。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Tailwind Context Resolver Mcp,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

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

其他 MCP 客户端

参照 仓库 中的启动说明。

README

tailwind-context-resolver-mcp 🎨🐸

[npm version] [npm downloads] [CI] [License: MIT]

An MCP server that loads your project's tailwind.config.ts/js and exposes its actual design system to AI agents — so they stop hallucinating class names.


🤔 The Problem

AI agents generate Tailwind classes based on training data — the default Tailwind docs. Your project is not the default docs.

You have a custom color palette. A non-standard spacing scale. Maybe a prefix like tw-. Brand tokens like bg-brand-primary. The agent doesn't know any of this. It guesses.

The result:

jsx
// Agent confidently generates this:<div className="bg-primary-500 text-brand p-18 tw-flex-center">
// Your project has:// - bg-brand-primary (not bg-primary-500)// - no "text-brand" token// - spacing.18 = 4.5rem (ok actually)// - no "flex-center" utility// - no "tw-" prefix

The agent can't validate what it writes because it has no access to your resolved config. It's working from memory of the default theme — not yours.


✅ The Fix

This MCP server runs the Tailwind resolver locally and gives agents a typed, queryable interface to your actual config. Before writing a component, the agent can ask:

  • "What brand colors exist in this project?"
  • "Is p-18 a valid spacing value here?"
  • "Does this project use a custom prefix?"
  • "Is bg-brand-primary flex grid a valid class string?"

🛠️ Tools

resolve_theme_tokens

Query any namespace in the resolved Tailwind theme. Returns all design tokens as flat key-value pairs.

namespace: "colors.brand" → { primary: "#3b82f6", secondary: "#8b5cf6", danger: "#ef4444" }namespace: "spacing"      → { "1": "0.25rem", "2": "0.5rem", "18": "4.5rem", ... }namespace: "fontFamily"   → { sans: ["Inter", "sans-serif"], mono: [...] }

Use before generating components to discover what tokens actually exist.

validate_class_string

Validates a Tailwind className string against the project's resolved config. Returns valid classes, invalid (hallucinated) classes, and conflict warnings.

json
{  "valid_classes": ["bg-brand-primary", "text-white", "p-4", "hover:bg-brand-secondary", "flex"],  "invalid_classes": ["bg-fake-token", "text-brand"],  "warnings": ["Conflicting multiple layout models: flex, grid"],  "config_prefix": ""}

Use to catch hallucinated design tokens before writing code.

detect_css_conflicts

Detects conflicting Tailwind utilities — e.g. flex + grid, or absolute + fixed on the same element.

json
{  "conflicts": [{ "classes": ["flex", "grid"], "reason": "multiple layout models" }],  "has_conflicts": true}

get_config_summary

Returns a compact overview: Tailwind version, prefix, which theme sections are customized, active plugins.

json
{  "tailwind_version": "3.4.19",  "prefix": "",  "theme_extensions": ["colors", "spacing", "fontFamily"],  "total_colors": 142,  "total_spacing": 34,  "plugins": ["@tailwindcss/forms"]}

Use first to understand the project's design system before querying specific tokens.


🚀 Setup

Claude Desktop

Add to your claude_desktop_config.json:

json
{  "mcpServers": {    "tailwind-context-resolver": {      "command": "npx",      "args": ["-y", "tailwind-context-resolver-mcp"]    }  }}

Cursor / VS Code / Any MCP client

json
{  "tailwind-context-resolver": {    "command": "npx",    "args": ["-y", "tailwind-context-resolver-mcp"]  }}

📋 Requirements

  • Tailwind CSS v3 — v4 uses a CSS-based config format and is not supported (the server will tell you clearly)
  • Node.js 18+
  • A tailwind.config.js or tailwind.config.ts in your project

🔧 How It Works

The server uses the same config loading strategy as the Tailwind CLI:

  1. jiti loads your tailwind.config.ts at runtime — no ts-node required
  2. tailwindcss/resolveConfig merges your config with Tailwind defaults to produce the full resolved theme
  3. Tools perform token-based class validation — checking that bg-brand-primary maps to an actual colors.brand.primary token — without running the full PostCSS/JIT pipeline

This approach is fast, stable, and works with any Tailwind v3 project without additional configuration.


📖 Agent Workflow Example

1. get_config_summary       → understand the project's design system2. resolve_theme_tokens     → query specific namespaces before writing classes   (namespace: "colors.brand", "spacing")3. validate_class_string    → validate the className string before committing it4. detect_css_conflicts     → final sanity check for conflicting utilities

🐸 Part of the MCP Toolbelt

Built alongside:


License

MIT

来源:README.md,提交 2e58837

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.2.0最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分

其他 Tailwind 集成