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)
๐ 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
Response:
2. Codemod Replace
Response:
3. Search Docs
Response:
4. Token Converter
5. Validate Component
Response:
6. Theme Preview
๐ง Development
Project Structure
Available Scripts
Adding 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
Tests 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
local-only server
The server can only run on the client's local machine because it depends on local resources.
Enables developers and designers to work with the Carbon Design System through tools for generating components, applying codemods, validating accessibility, converting design tokens, and searching documentation.