mcpField
T
Tailwind Shades

Tailwind Shades

远程服务
tailwindshades.bourhaouta.com开发工具782 周前更新

关于 Tailwind Shades

Tailwind Shades 是供 Tailwind CSS Agent 使用的 MCP 服务,可生成调色板并返回 Tailwind 定义的颜色值,避免依赖猜测。它支持 Tailwind v1 至 v4,并可通过远程 HTTP 或本地 stdio 接入。

主要功能

  1. 01从 CSS 颜色生成 50–950 色阶
  2. 02查找最接近的 Tailwind 色阶
  3. 03按版本获取默认调色板
  4. 04转换为 OKLCH、hex 或 RGB
  5. 05生成符合 WCAG AA 的可读配色

适用场景

  1. 01为 Tailwind 主题添加品牌色板
  2. 02为颜色选择现有 Tailwind 类
  3. 03获取项目版本对应的准确默认色值

MCP 相关

该服务向 MCP 客户端提供五种只读工具和 `add_brand_color` 提示词。可通过 Streamable HTTP 远程连接,也可在本地通过 stdio 运行。

配置

远程服务无需本地安装。选择你使用的客户端,复制配置或使用一键安装。

服务地址https://tailwindshades.bourhaouta.com/mcp
一键复制安装命令
Claude CodeTerminal
Cursor.cursor/mcp.json
VS Code.vscode/mcp.json
Claude Desktopclaude_desktop_config.json
Windsurf~/.codeium/windsurf/mcp_config.json

命令在终端中运行;JSON 粘贴到对应客户端的 MCP 配置后重启。需要授权的服务会在首次连接时提示登录。

安装包
npmtailwindshades-mcp1.6.0

工具

5
参数类型必填说明
namestring否代码中使用的颜色名称,例如 "brand"。默认使用最接近的 Tailwind 颜色,并替换该名称对应的 Tailwind 自带调色板(例如 red);除非用户希望如此,否则请传入名称。
colorstring是任意 CSS 颜色:hex(#db4d53)、rgb()、hsl()、oklch() 或命名颜色
plainboolean否当 output 为 live 或 shopify 时:输出普通的 :root 块,而不是 @theme,适用于不使用 Tailwind 的项目(例如 Dawn 主题)
formatenum否颜色格式。v4 默认使用 oklch,较早版本默认使用 hexoklch | hex | rgb
outputenum否theme:主 CSS 文件使用的 v4 @theme 块。config:用于 tailwind.config.js 中 theme.extend.colors 的对象。css:普通 CSS 变量。live(仅限 v4):用于运行时选取颜色(用户、租户或 CMS 设置)的 CSS;所有色阶都跟随一个变量 --color-<name>,并在浏览器中通过相对颜色重新构建,此调色板作为回退值。shopify(仅限 v4):除 live 外,还提供 settings_schema.json 颜色设置以及用于 snippets/css-variables.liquid 的 Liquid 行,适用于商家在主题编辑器中选择颜色的 Shopify 主题。每个部分都会注明应放入的文件。v4 默认使用 theme,较早版本默认使用 configtheme | config | css | live | shopify
semanticboolean否当 output 为 live 或 shopify 时:同时添加 --color-<name>-foreground,供彩色背景上的文字使用。根据运行时颜色,在白色和最深色阶中选择对比度更高的一种
tailwindVersionenum否项目使用的 Tailwind CSS 主版本。默认为 44 | 3 | 2 | 1

详细介绍

tailwindshades-mcp

Tailwind Shades MCP connector – tool definition quality and endpoint health on Glama

一个 MCP 服务,可为 AI Agent 提供真实的 Tailwind CSS 调色板,让它们不再猜测色阶。支持 Tailwind v4、v3、v2 和 v1。

让 Agent “为我的主题添加品牌颜色 #db4d53”,它便会按照项目的 Tailwind 格式生成完整的 50 到 950 调色板,并将 #db4d53 准确设为 brand-500。它与 Tailwind Shades 编辑器扩展和 tailwindshades.bourhaouta.com 使用相同的引擎。

设置

远程(无需安装)

将 Agent 连接到 https://tailwindshades.bourhaouta.com/mcp(Streamable HTTP,无需 API 密钥)。

Claude Code

claude mcp add --transport http --scope user tailwindshades https://tailwindshades.bourhaouta.com/mcp

Cursor(~/.cursor/mcp.json,或项目中的 .cursor/mcp.json)

{
  "mcpServers": {
    "tailwindshades": { "url": "https://tailwindshades.bourhaouta.com/mcp" }
  }
}

VS Code(.vscode/mcp.json)

{
  "servers": {
    "tailwindshades": { "type": "http", "url": "https://tailwindshades.bourhaouta.com/mcp" }
  }
}
本地(stdio)

使用 npx 在你的计算机上运行,因此不会有任何内容离开本机。需要 Node.js 20 或更高版本。

Claude Code

claude mcp add --scope user tailwindshades -- npx -y tailwindshades-mcp

Cursor(~/.cursor/mcp.json,或项目中的 .cursor/mcp.json)

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

VS Code(.vscode/mcp.json)

{
  "servers": {
    "tailwindshades": { "command": "npx", "args": ["-y", "tailwindshades-mcp"] }
  }
}

其他 Agent:使用上面的 URL,或运行 npx -y tailwindshades-mcp 作为 stdio 服务。它也已列入 MCP Registry,名称为 io.github.bourhaouta/tailwindshades。

工具

这五种工具均为只读。

generate_palette

根据一种颜色生成完整的调色板,可直接粘贴使用。

输入默认值
color必填:任意 CSS 颜色(#db4d53、rgb()、hsl()、oklch() 或颜色名称)
name最接近的 Tailwind 颜色;它会替代 Tailwind 自带的调色板,因此工具会发出警告
tailwindVersion4(也支持 3、2、1)
formatv4 使用 oklch,更早版本使用 hex(也支持 rgb)
outputv4 使用 theme,更早版本使用 config(也支持 css,以及 v4 的 live 和 shopify)
plain、semanticfalse:搭配 live 或 shopify 时,使用普通的 :root 区块而不是 @theme,并生成 --color-<name>-foreground

live 适用于运行时选取的颜色(用户、租户或 CMS 设置):生成 CSS,使每个色阶都跟随一个变量,并在浏览器中重新构建。shopify 会为 Shopify 主题添加颜色设置和 Liquid 行,商家可在主题编辑器中选取颜色。参见运行时选取的颜色。

返回代码,以及以结构化数据提供的色阶、与输入颜色相符的色阶和最接近的 Tailwind 颜色。

代码以一条注释开头,其中列出易于阅读的组合:通过 WCAG AA(4.5:1)标准的文字和背景类,并基于实际色阶进行测试。Agent 会用它们来设置按钮和文本,因此红色品牌会使用 bg-brand-600 text-white,而不是未通过测试的 bg-brand-500 text-white:

/* Readable pairs (WCAG AA, 4.5:1 or more):
   button     bg-brand-600 text-white      5.09:1
   text       bg-white text-brand-600      5.09:1
   badge      bg-brand-100 text-brand-700  5.43:1
   dark mode  bg-brand-950 text-brand-400  5.33:1
   avoid      bg-brand-500 text-white      4.03:1 */
find_closest_tailwind_color

找出外观最接近某种颜色的 Tailwind 色阶,例如 #db4d53 → red-500,并提供 Tailwind 的颜色值、色差,以及差异是否可见。Agent 可用它来选择现有类,而不是使用任意值;也可据此判断是否需要自定义调色板。

get_tailwind_palette

获取 Tailwind 自带的默认颜色,与 Tailwind 的定义完全一致:可以是完整颜色(blue),也可以是单个色阶(slate-500),支持 Tailwind v4、v3、v2 或 v1。v4 的值采用 oklch(),更早版本采用 hex。Agent 可用它代替凭记忆编写 Tailwind 默认值。

list_tailwind_colors

列出某个版本的 Tailwind 默认颜色名称(v4 中有 26 种,包括 mauve、olive、mist 和 taupe),以及各颜色包含的色阶,并以其 500 色阶作为示例。

convert_color

将任意 CSS 颜色转换为 oklch()、hex 和 rgb,并按 Tailwind 格式输出。当 Tailwind v4 项目只需要一个 oklch() 值,而非完整调色板时,非常实用。

提示词

add_brand_color

参数:color 和可选的 name(默认值为 brand)。它会要求 Agent 查找项目使用的 Tailwind 版本,调用 generate_palette,并将代码粘贴到主题中。Claude Code 等客户端会将其显示为斜杠命令。

自行托管

该包还会导出 createServer(),它会创建一个包含所有工具和提示词的全新 McpServer。使用 MCP TypeScript SDK 为其提供服务,例如,在任何符合 Web 标准的运行时中通过 HTTP 提供服务(上面的远程服务就是通过 Next.js 路由运行的):

import { createMcpHandler } from '@modelcontextprotocol/server'
import { createServer } from 'tailwindshades-mcp'

const handler = createMcpHandler(createServer)

export const POST = (request: Request) => handler.fetch(request)

更多

许可证

MIT © Omar Bourhaouta

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。