AI tools
Give Claude Code, Codex, Google Antigravity or GitHub Copilot the c2n skill, live component APIs, examples and application conventions.
c2n provides two complementary tools for coding agents:
@c2n/skillteaches the agent how to build with c2n: inspect the project, load the theme once, check component APIs, and turn repeated styles or patterns into application components.@c2n/mcpexposes structured, version-aware component APIs, examples, gallery variants, presets, theme tokens and code generation through the Model Context Protocol.
When MCP is unavailable, the skill uses a compact bundled catalog for component discovery and reads installed packages’ custom-elements.json manifests for exact, version-correct APIs. MCP can also run by itself, but installing both gives an agent the component facts and the conventions for applying them well.
Install in an application
From the root of the application that will use c2n:
npm install --save-dev @c2n/skill
npx c2n-skill installThe installer defaults to all supported agents. It copies project-scoped skills and merges the c2n MCP server into existing configuration without replacing other servers.
| Agent | Skill location | MCP configuration |
|---|---|---|
| Claude Code | .claude/skills/c2n-components/ | .mcp.json |
| Codex | .agents/skills/c2n-components/ | .codex/config.toml |
| Google Antigravity | .agents/skills/c2n-components/ | .agents/mcp_config.json |
| GitHub Copilot | .github/skills/c2n-components/ | .vscode/mcp.json |
The installer also adds a short c2n rules block to the instructions file each agent loads in every session (CLAUDE.md for Claude Code, AGENTS.md for Codex, .github/copilot-instructions.md for GitHub Copilot): use a c2-* element instead of a native control even when the request does not mention c2n, check each component with get_component before using it, build the child elements a container expects, restyle only through documented CSS variables, and run validate_markup before finishing. With --no-mcp the block names the fallbacks instead: the installed node_modules/@c2n/components/custom-elements.json for the API and npx -y @c2n/mcp validate src for the check. Re-running the installer replaces that block in place and leaves the rest of the file alone. Use Copilot’s agent mode, where it can call MCP tools.
For Claude Code it also registers a PostToolUse hook in .claude/settings.json: after each Write, Edit or MultiEdit of a markup, script or stylesheet file (HTML, JSX/TSX, Vue, Svelte, Astro, MDX, JS/TS, CSS/SCSS/Less), c2n-mcp validate --hook checks that file and hands the problems back to the agent, which fixes them in the same turn. Files written another way, such as from a shell command, are not checked. --no-hook skips it. The same check runs in CI with npx -y @c2n/mcp validate src --strict (without --strict it exits 1 on errors only, so a native control, which is a warning, would pass); mark a deliberate native element with a c2n-ignore comment.
Install for only one agent when the project does not need every configuration:
npx c2n-skill install --agent claude
npx c2n-skill install --agent codex
npx c2n-skill install --agent antigravity
npx c2n-skill install --agent copilotComma-separated agents and a different project directory are supported. Use --no-mcp when only the offline skill is wanted.
npx c2n-skill install --agent codex,antigravity --project ./my-app
npx c2n-skill install --agent codex --no-mcpBehind a proxy or VPN
By default every configuration starts the server with npx -y @c2n/mcp@<version>, which downloads it from npm each time the agent launches it. When the agent’s environment cannot reach the registry (a corporate proxy, TLS inspection), the download fails, the agent quietly runs without the c2n tools and falls back to guessing component APIs. Install the server into the project instead; the installer then points every configuration at that copy, so starting it needs no network and it always matches the installed components:
npm install --save-dev @c2n/skill @c2n/mcp
npx c2n-skill install --agent copilot --mcp local--mcp auto (the default) picks the local copy whenever node_modules/@c2n/mcp exists; --mcp npx forces the download.
Re-run the installer after upgrading @c2n/skill; c2n-owned files are refreshed while unrelated MCP entries are preserved. Restart the agent after installation so it reloads project skills and MCP configuration.
Verify the setup
Ask the agent to use the c2n MCP server to list components, then inspect one component:
Use the c2n MCP server to list the available button components. Then inspect c2-button and tell me its attributes, slots and CSS variables.A connected agent should use list_components or search_components, followed by get_component. The server detects installed @c2n/* packages from the application root and reports their versions while serving its bundled offline registry.
If the MCP server does not appear, verify that it can start in the same project:
npx -y @c2n/mcp --versionIn VS Code, run MCP: List Servers, select c2n and choose Show Output to see why a server failed to start.
If that succeeds, restart the agent and check that its project root is the directory containing the generated configuration. Run npx c2n-skill install again if configuration was deleted or the package was upgraded.
A productive first prompt
Describe the application outcome and ask the agent to use both c2n tools. It can then select components from evidence instead of guessing their API.
Use the c2n-components skill and c2n MCP server to build a profile settings form.
Inspect each component before using it, install only the required @c2n packages,
load @c2n/theme once, and create app-level variants for styles that repeat.For an existing application, ask the agent to inspect the current token bridge and installed packages before changing code:
Use c2n to add an attachment picker to this application. Preserve its existing theme,
check the installed c2n versions, and verify the attachment API and examples through MCP first.The recommended sequence is search_components → get_component → get_examples → optionally get_presets → get_theme → generate_variant. Gallery examples provide complete usage and composition context; presets provide structured attributes and CSS values that are easier to turn directly into an application variant.
Inspiration from the gallery
Every gallery card on this site is available to agents. get_examples with view: "index" lists a component’s cards on one page, each with a summary of what it changes and a link to a light and a dark screenshot, and search_examples finds a look across all components (“glass”, “pill”, “underline input”). The CSS of a card is served theme-aware: a colour equal to a token’s value becomes var(--c2-theme--…, literal), so the copied look follows the application’s brand and dark mode. generate_variant with example turns a card into a reusable class or Lit subclass.
Use the c2n gallery for the settings page: browse the text-field and button looks,
pick ones that suit a calm, dense admin UI, and turn them into app variants.Manual MCP-only configuration
The installer is recommended, but any stdio MCP client can launch:
npx -y @c2n/mcpClaude Code project .mcp.json:
{
"mcpServers": {
"c2n": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@c2n/mcp"]
}
}
}Codex project .codex/config.toml:
[mcp_servers.c2n]
command = "npx"
args = ["-y", "@c2n/mcp"]GitHub Copilot in VS Code, .vscode/mcp.json (note the servers key):
{
"servers": {
"c2n": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@c2n/mcp"]
}
}
}Google Antigravity project .agents/mcp_config.json uses the same mcpServers.c2n command and arguments as the Claude JSON example, without requiring the type field.
llms.txt
Agents that can fetch a URL but have neither the MCP server nor the skill installed can read the site itself:
/llms.txtis the documentation map: every component with its tag, package, docs, API and gallery link, plus the guides, icon sets and example apps. It is generated from the same content the site renders./llms-full.txtis the full text of thec2n-componentsskill in one document: workflow, theming, variants, framework notes and the compact component catalog.
Both files point back to the MCP server and the installed manifests for exact APIs; neither replaces them.
Add c2n components to the application
The AI tools provide guidance and metadata; the components remain a normal application dependency. Install @c2n/components, which includes the theme:
npm install @c2n/componentsLoad the theme once near the application entry point, then import only the components the application uses, before their tags render:
import '@c2n/components/theme.css'
import '@c2n/components/button'
import '@c2n/components/text-field'Continue with Using c2n in an application for the application architecture and Theming for tokens, dark mode and component-level overrides.