Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Carbon MCPgenerate a PrimaryCard component with compact and icon props"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
carbon-mcp
Local MCP (Model Context Protocol) server for the Carbon Design System β Advanced MVP for internal demos and production use.
π§ Status: Proposal Submitted to Carbon
This project is a proposal submitted to the Carbon Design System repository.
Issue: #20855
Status: Awaiting maintainer feedback
Proposed: Add to Carbon monorepo or create official
carbon-design-system/carbon-mcprepository
The Carbon team is reviewing this proposal. Once feedback is received, the code will be adapted accordingly.
π Quickstart
Clone repo
git clone https://github.com/SandeepBaskaran/carbon-mcp.git cd carbon-mcpInstall dependencies
npm install # or pnpm installConfigure environment (optional)
cp .env.example .env # Edit .env to add API keys if needed (FIGMA_TOKEN, GITHUB_TOKEN)Start the server
npm run devServer will start on
http://localhost:4000Test it out
# List available tools curl http://localhost:4000/tools # Generate a component (dry-run) curl -X POST http://localhost:4000/tool/generateComponent \ -H "Content-Type: application/json" \ -d '{"component_name": "PrimaryCard", "dry_run": true}'
π οΈ Tools (MVP)
Developer Tools
generateComponentβ Generate Carbon React component + Storybook story + tests (dry-run default)codemodReplaceβ Apply codemods to convert existing components to Carbon equivalents (dry-run default)validateComponentβ Validate component against Carbon patterns and accessibility guidelinestokenConverterβ Convert design tokens (JSON) to CSS variables, SCSS maps, and JS tokens
Documentation Tools
searchDocsβ Search local Carbon docs index with semantic/keyword matching
Designer Tools
themePreviewβ Generate static HTML previews for Carbon theme variants (light/dark/custom)figmaSyncβ Scaffold for Figma token sync (requires FIGMA_TOKEN in environment)
π Safety & Destructive Operations
All destructive changes (writing to disk, modifying files) require:
confirm_destructive: truedry_run: false
Recommended workflow:
Run with
dry_run: true(default) to preview changesReview the output/patches
Run again with
dry_run: falseandconfirm_destructive: trueto apply
Example: Generate Component (Safe Workflow)
# Step 1: Dry-run to preview
curl -X POST http://localhost:4000/tool/generateComponent \
-H "Content-Type: application/json" \
-d '{
"component_name": "PrimaryCard",
"dry_run": true,
"explain": true
}'
# Step 2: Apply changes
curl -X POST http://localhost:4000/tool/generateComponent \
-H "Content-Type: application/json" \
-d '{
"component_name": "PrimaryCard",
"dry_run": false,
"confirm_destructive": true
}'π API Reference
Endpoints
Method | Endpoint | Description |
GET |
| Health check |
GET |
| List all available tools |
GET |
| Get schema for specific tool |
POST |
| Execute a tool |
Tool Examples
1. Generate Component
POST /tool/generateComponent
{
"component_name": "PrimaryCard",
"props": {
"compact": "boolean",
"icon": "string"
},
"target_path": "src/components/PrimaryCard",
"dry_run": true,
"explain": true
}Response:
{
"files": [
{
"path": "src/components/PrimaryCard/PrimaryCard.tsx",
"content": "import React from 'react'..."
}
],
"changed_files": [],
"dry_run": true,
"logs": [...],
"trace_id": "genc-1234567890",
"explanation": "Generated Carbon React component..."
}2. Codemod Replace
POST /tool/codemodReplace
{
"codemod_name": "btn-old-to-carbon",
"files_glob": "src/**/*.{tsx,jsx}",
"dry_run": true
}Response:
{
"dry_run_result": "3 files would be modified",
"patches": [
{
"file": "src/pages/Home.tsx",
"patch": "@@ -1,6 +1,6 @@..."
}
],
"changed_files": ["src/pages/Home.tsx"],
"logs": [...],
"trace_id": "codemod-1234567890"
}3. Search Docs
POST /tool/searchDocs
{
"query": "Carbon Button aria roles",
"k": 5
}Response:
{
"results": [
{
"title": "Button β Carbon React",
"path": "docs/components/button.md",
"snippet": "The Button component supports kinds: primary, secondary...",
"score": 0.98
}
],
"logs": [...],
"trace_id": "search-1234567890"
}4. Token Converter
POST /tool/tokenConverter
{
"input_path": "tokens/tokens.json",
"outputs": ["css_vars", "scss_map", "js_tokens"],
"output_dir": "tokens",
"dry_run": true
}5. Validate Component
POST /tool/validateComponent
{
"file_path": "src/components/MyButton/MyButton.tsx",
"rules": ["props", "accessibility", "tokens"]
}Response:
{
"valid": false,
"errors": [],
"warnings": [
{
"type": "warning",
"rule": "accessibility",
"message": "Icon-only buttons should have aria-label"
}
],
"logs": [...],
"trace_id": "validate-1234567890"
}6. Theme Preview
POST /tool/themePreview
{
"themes": ["white", "g10", "g90", "g100"],
"output_path": "theme-previews",
"dry_run": true
}π§ Development
Project Structure
carbon-mcp/
βββ src/
β βββ server/
β β βββ index.ts # Server bootstrap
β β βββ toolRegistry.ts # Tool registration
β β βββ tools/ # Tool handlers
β β βββ generateComponent.ts
β β βββ codemodReplace.ts
β β βββ searchDocs.ts
β β βββ tokenConverter.ts
β β βββ validateComponent.ts
β β βββ themePreview.ts
β β βββ figmaSync.ts
β βββ lib/ # Utilities
β β βββ logger.ts
β β βββ fileUtils.ts
β β βββ templateUtils.ts
β β βββ codemodUtils.ts
β β βββ diffUtils.ts
β β βββ tokenUtils.ts
β βββ schemas/ # JSON schemas
β βββ templates/ # Component templates
βββ package.json
βββ tsconfig.json
βββ README.mdAvailable Scripts
npm run dev # Start development server with hot reload
npm run build # Build TypeScript to dist/
npm start # Run production server
npm test # Run tests
npm run lint # Lint codeAdding a New Tool
Create handler in
src/server/tools/myTool.tsCreate schema in
src/schemas/myTool.jsonRegister in
src/server/toolRegistry.tsUpdate this README
π§ͺ Testing
npm testTests use Jest + ts-jest. Test files are located next to source files with .test.ts extension.
π Security & Privacy
No secrets in logs: The logger automatically redacts sensitive keys (tokens, passwords, API keys)
Telemetry opt-in: Set
ANALYTICS_ENABLED=truein.envto enable (disabled by default)File access: Tools only access files within the repo root
Audit trails: All operations are logged with trace IDs for auditing
π Environment Variables
Variable | Required | Description |
| No | Server port (default: 4000) |
| No | Figma Personal Access Token for figmaSync |
| No | GitHub token for PR automation |
| No | Enable telemetry (default: false) |
| No | Carbon version to use (default: latest) |
π Common Codemods
btn-old-to-carbon
Replaces old <button className="btn-old"> with Carbon <Button kind="primary">
class-to-style
Refactors className styles that match Carbon tokens into token usage
replace-grid
Swaps custom grid with Carbon Grid
image-to-asset
Converts inline base64 images to static assets
π€ Contributing
Follow TypeScript best practices
Add tests for new tools
Update schemas and documentation
Keep tools deterministic and idempotent
Use dry-run by default for destructive operations
π License
MIT
π Resources
Made with β€οΈ for the Carbon Design System community
This server cannot be installed
Resources
Looking for Admin?
Admins can modify the Dockerfile, update the server description, and track usage metrics. If you are the server author, to access the admin panel.