c2n Web Components

io.github.code2nguyen由 GitHub 帳號 code2nguyen 發布v1.0.23更新於 Nov 7, 2026

Exact APIs, examples, theme tokens and markup validation for the c2n (c2-*) Lit web components.

已驗證STDIO僅桌面知識與記憶開發者工具

概覽

AI 產生的概覽

本機 MCP 伺服器,為助理提供 c2n(c2-*)Lit Web 元件的 API、範例、主題權杖與標記驗證。

可以做什麼
  • 列出並搜尋元件,含標籤、套件、分類、說明與已安裝版本
  • 檢視單一元件的完整 API:屬性、插槽、事件、原生 CSS 部件及帶主題權杖的 CSS 變數
  • 瀏覽用法範例與展示樣式,並跨所有元件搜尋樣式
  • 取得精選預設集與 --c2-theme--* 權杖,含安裝與對應片段
  • 依覆寫值、預設集或展示卡片產生 CSS 類別、HTML 加樣式、Lit 子類別或 JSON 形式的變體程式碼
  • 透過工具或命令列,依已安裝元件 API 驗證標記與 CSS
適用情境
在使用 c2n Web 元件建置或調整介面時適用:希望助理引用準確的元件 API、複製展示樣式、產生變體,或檢查標記中未知的標籤、屬性、插槽、事件與變數。
執行需求
以 stdio 在本機執行,通常透過 npx 啟動 @c2n/mcp npm 套件,因此需要 Node.js 與 npm。應在專案目錄中執行;選用環境變數 C2N_PROJECT_ROOT 指定回報哪個專案已安裝的 @c2n/* 套件。註冊表已隨套件打包,安裝後呼叫工具不需網路。
安裝前請注意
此伺服器只提供元件資訊,不會安裝套件或直接修改應用程式。驗證會讀取專案原始檔;掛鉤模式還會從標準輸入讀取內容,並將結果寫入標準錯誤、以結束碼 2 回傳。安裝選用的 skill 套件會在專案設定中註冊 Claude Code 掛鉤。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 c2n Web Components,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

@c2n/mcp

Model Context Protocol server that exposes the c2n web components to AI agents: component APIs (attributes, slots, events, native CSS parts, CSS variables with their theme tokens), usage and gallery examples, curated presets, the @c2n/theme tokens, variant code generation and the application workflow guides. Everything is bundled in data/registry.json, so it works offline in any project.

[c2n Web Components MCP server]

Use

The server uses stdio and can be launched by any MCP host:

bash
npx -y @c2n/mcp

Claude Code project .mcp.json:

json
{ "mcpServers": { "c2n": { "type": "stdio", "command": "npx", "args": ["-y", "@c2n/mcp"] } } }

Codex project .codex/config.toml:

toml
[mcp_servers.c2n]command = "npx"args = ["-y", "@c2n/mcp"]

Google Antigravity project .agents/mcp_config.json uses the same mcpServers command/args structure as the Claude example. The @c2n/skill package can install the skill and merge these configurations automatically.

Run the server from a project directory: it reports which @c2n/* packages are installed and serves the bundled API when the installed version differs. The registry is packaged locally, so tool calls do not require network access after installation.

Use c2n-mcp --version to inspect the installed server version and c2n-mcp --help for CLI usage.

The MCP server supplies structured component facts; it does not install component packages or edit an application by itself. Pair it with @c2n/skill when you also want the agent to follow c2n's application, theming and variant conventions. See the AI tools guide for the complete setup and example prompts.

Verify the connection

Restart the agent after adding its MCP configuration, then ask it to use the c2n MCP server to list components or inspect c2-button. A connected client should expose the tools below and report @c2n/* packages installed in the current project. If the server cannot start, run npx -y @c2n/mcp --version in that project to distinguish an npm/runtime problem from an MCP client configuration problem.

Tools

ToolPurpose
list_componentsEvery component with tag, package, category, description, installed version
search_componentsFree-text search across names, descriptions, attributes, slots, events, examples, icons
get_componentFull API of one component, CSS variables grouped by part/state with their theme token
get_examplesUsage rows and gallery cards; view: "index" lists every look (summary, screenshot)
search_examplesFind a look across every component's gallery ("glass", "pill", "underline")
get_presetsCurated presets as CSS variable values
get_themeThe --c2-theme--* tokens, install/mapping snippets; per-component mapping with tag
generate_variantCSS class / HTML + style / Lit subclass / JSON from overrides, a preset or a gallery card
validate_markupChecks markup/CSS you wrote: native controls to replace, unknown tags/attributes/slots/events/variables
get_workflow_guideworkflow, theming, variant-components, frameworks

Gallery cards are served with a generated summary of what they change and CSS whose colours follow the --c2-theme--* tokens wherever a literal equals a token's value (var(--c2-theme--color-outline, #d4d4d8)), so a copied card follows the application's theme and dark mode. Each card also links light and dark PNG captures hosted with the docs site (gallery-shots/<component>/<slug>.<theme>.png, written by apps/ui/scripts/gallery-shots.mjs in the Pages deploy).

Validate from the command line

validate_markup is also a CLI, for CI and editor hooks. It reads HTML, JSX/TSX, Vue, Svelte, Astro, Angular and Lit templates and CSS, and checks them against the API of the @c2n/* packages the project has installed:

bash
npx -y @c2n/mcp validate src            # exit 1 on errorsnpx -y @c2n/mcp validate src --strict   # warnings fail too (native controls, box styling on a c2 host)npx -y @c2n/mcp validate --hook         # Claude Code PostToolUse hook: reads the payload on stdin

It reports native <button>/<input>/<select>/<textarea>/<dialog>/<details>/<progress> elements that a c2-* element replaces, unknown c2-* tags, attributes, slots and --c2-* variables (with "did you mean"), events a c2-* element does not fire (with its event list), a static camelCase attribute the element ignores (rowKey for row-key), and box styling on a c2-* host (border, padding, background, box-shadow, outline; a radius alone is fine). A line holding c2n-ignore, or the line after a comment holding it, is skipped. In hook mode the findings go to stderr with exit code 2, which Claude Code hands back to the agent; npx -y @c2n/skill install registers that hook in .claude/settings.json.

Resources: c2n://components, c2n://components/{tag}, c2n://theme, c2n://guide/{topic}.

Development

  • data/registry.json is an ignored build artifact. npm run build:tools (repo root) regenerates it from the component manifests, docs content, presets and theme, then compiles dist/ and refreshes the committed skill fallback.
  • dev, inspect, smoke and npm pack automatically build the registry when needed.
  • npm run smoke -w packages/tools/mcp spawns the server over stdio and checks every tool.
  • npm run inspect -w packages/tools/mcp opens the MCP Inspector against the source entry (node src/cli.ts, Node 24 type stripping).

來源:packages/tools/mcp/README.md,提交 14ff619

工具

10

list_components

List components

Lists every c2n component (tag, package, category, one-line description, installed version in the current project).

輸入參數formatkeywordcategoryinstalledOnly

get_component

Get component API

Full API of one component: install/import lines, attributes, slots, events, native CSS parts, CSS variables grouped by semantic target and state (with the theme token each follows), composition and preset names. Examples are served by get_examples.

輸入參數tag必填formatinclude

search_components

Search components

Free-text search across component names, descriptions, attributes, slots, events, example labels and icon names. Use it to find the component for a UI need ("dropdown", "dialog", "avatar with status", "arrow icon").

輸入參數limitquery必填

get_examples

Get examples

Markup examples of a component: usage rows from the docs, styled gallery cards (the looks shown on the docs site, each with a summary of what it changes and light/dark screenshots) and the landing preview. Start with `view: "index"` to see every look on one page, then fetch the chosen card by its slug.

輸入參數tag必填kindviewlabellimitqueryformatoffsetsection

search_examples

Search gallery looks

Search every component's gallery for a look or a use case ("compact", "glass", "pill", "danger", "underline input", "KPI"): returns matching cards across components with their summary and screenshot. Fetch one with get_examples `label: <slug>`.

輸入參數taglimitquery必填

get_presets

Get presets

Curated presets of a component ("inspiration" looks): base markup plus each preset as CSS variable values and attributes.

輸入參數tag必填nameformat

get_theme

Get theme tokens

The @c2n/theme design tokens (--c2-theme--*) with light/dark defaults, how to install and map your own tokens, and dark mode. With `tag`: which of that component's variables follow which token.

輸入參數tagformat

generate_variant

Generate a variant component

Turns CSS variable / attribute overrides of a component into copy-paste code: a CSS class, HTML + <style>, a Lit subclass registered under your own tag, or JSON. Validates variable and attribute names against the component API. Start from a curated preset with `preset`, or from a gallery card with `example` (its slug or label).

輸入參數csstag必填htmlname必填formatpresetexampleattributes

validate_markup

Validate markup

Checks HTML, JSX, Vue, Svelte, Astro, Angular or Lit markup and CSS you wrote against the installed c2n API: native controls a c2-* element replaces (<button>, <input>, <select>, <textarea>, <dialog>, <details>, <progress>), unknown c2-* tags, attributes, slots, events and --c2-* variables (with "did you mean"), and box styling on a c2-* host. Lists the imports that register the elements used. Call it on every file you write before finishing.

輸入參數code必填formatfilename

get_workflow_guide

Get workflow guide

The c2n application workflow guides: `workflow` (theme once, use tags, name what repeats), `theming`, `variant-components`, `frameworks` (plain HTML, Lit, Astro, React, Vue, SSR).

輸入參數topic

版本歷史

7
  1. v1.0.23最新Nov 7, 2026
  2. v1.0.22Nov 7, 2026
  3. v1.0.21Nov 5, 2026
  4. v1.0.20Nov 3, 2026
  5. v1.0.19Nov 3, 2026
  6. v1.0.18Oct 29, 2026
  7. v1.0.17Oct 25, 2026

評分

已滿足適用檢查項的 90%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分
  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具必需15 分
  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分