@atomixstudio/mcp 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,325 @@
1
+ # @atomixstudio/mcp
2
+
3
+ MCP (Model Context Protocol) server for the Atomix Design System.
4
+
5
+ Enables AI coding tools to consume and query design tokens — works with **Cursor, GitHub Copilot, Windsurf, Cline, Claude, Zed**, and more.
6
+
7
+ ## Supported AI Coding Tools
8
+
9
+ | Tool | Rules File | MCP Support |
10
+ |------|-----------|-------------|
11
+ | Cursor | `.cursorrules` | Native |
12
+ | GitHub Copilot | `.github/copilot-instructions.md` | Via MCP extension |
13
+ | Windsurf | `.windsurfrules` | Native |
14
+ | Cline | `.clinerules` | Native |
15
+ | Continue | `.continuerules` | Native |
16
+ | Zed | `.zed/assistant/rules.md` | Native |
17
+ | Claude Desktop | MCP config | Native |
18
+ | VS Code + Extensions | Various | Via MCP |
19
+ | Amazon Q IDE | MCP config | Native |
20
+ | Warp | MCP config | Native |
21
+ | ChatGPT | MCP config | Native |
22
+
23
+ ## Quick Start
24
+
25
+ ```bash
26
+ # Install dependencies
27
+ cd packages/atomix-mcp
28
+ npm install
29
+
30
+ # Build the server
31
+ npm run build
32
+
33
+ # Test locally
34
+ npm start
35
+ ```
36
+
37
+ ## AI Tool Integration
38
+
39
+ ### Cursor Integration
40
+
41
+ The server is pre-configured in `.cursor/mcp.json`. After building, restart Cursor to enable the MCP server.
42
+
43
+ ### Other Tools
44
+
45
+ Generate rules for any supported tool:
46
+
47
+ ```
48
+ # Generate rules for a specific tool
49
+ getAIToolRules({ tool: "copilot", projectName: "My App", strict: true })
50
+
51
+ # Generate rules for ALL tools at once
52
+ getAIToolRules({ tool: "all", projectName: "My App" })
53
+
54
+ # Get a setup guide
55
+ getAIToolSetupGuide({ projectName: "My App" })
56
+ ```
57
+
58
+ ## Available Tools
59
+
60
+ ### `getToken`
61
+
62
+ Get a specific token by its path.
63
+
64
+ ```
65
+ getToken("colors.static.brand.primary")
66
+ → {
67
+ path,
68
+ value,
69
+ cssVariable,
70
+ tier: "primitive" | "semantic",
71
+ mutable: boolean,
72
+ guidance: "...",
73
+ usage
74
+ }
75
+ ```
76
+
77
+ ### `listTokens`
78
+
79
+ List all tokens in a category (filters by tier).
80
+
81
+ ```
82
+ listTokens("colors")
83
+ listTokens("colors", { tier: "semantic" })
84
+ listTokens("spacing", { subcategory: "scale" })
85
+ ```
86
+
87
+ ### `getComponentTokens`
88
+
89
+ Get tokens for a specific component.
90
+
91
+ ```
92
+ getComponentTokens("button")
93
+ getComponentTokens("button", { variant: "primary", size: "md" })
94
+ ```
95
+
96
+ ### `validateUsage`
97
+
98
+ Check if a value follows the design system.
99
+
100
+ ```
101
+ validateUsage("#ff0000")
102
+ → { valid: false, issue: "Hardcoded hex color", suggestion: "Use token..." }
103
+ ```
104
+
105
+ ### `searchTokens`
106
+
107
+ Search for tokens by name or value.
108
+
109
+ ```
110
+ searchTokens("brand")
111
+ → Matches: colors.static.brand.primary, colors.static.brand.primaryLight, ...
112
+ ```
113
+
114
+ ### `getAIToolRules` ⭐ NEW
115
+
116
+ Generate design system rules for any supported AI coding tool.
117
+
118
+ ```
119
+ getAIToolRules({ tool: "cursor", projectName: "My App", strict: true })
120
+ getAIToolRules({ tool: "copilot", projectName: "My App" })
121
+ getAIToolRules({ tool: "all", projectName: "My App" }) // All tools at once
122
+ ```
123
+
124
+ ### `listAITools`
125
+
126
+ List all supported AI coding tools.
127
+
128
+ ```
129
+ listAITools()
130
+ → { count: 7, tools: [{ id, name, rulesFile, description }, ...] }
131
+ ```
132
+
133
+ ### `getAIToolSetupGuide`
134
+
135
+ Get a complete setup guide for integrating Atomix with AI tools.
136
+
137
+ ```
138
+ getAIToolSetupGuide({ projectName: "My App" })
139
+ → Full markdown setup guide
140
+ ```
141
+
142
+ ### `exportMCPConfig` ⭐ NEW
143
+
144
+ Generate MCP configuration files for AI tools.
145
+
146
+ ```
147
+ exportMCPConfig({ tool: "cursor" })
148
+ → { path: ".cursor/mcp.json", content: "...", instructions: "..." }
149
+
150
+ exportMCPConfig({ tool: "claude-desktop" })
151
+ → { path: "~/Library/Application Support/Claude/claude_desktop_config.json", ... }
152
+
153
+ exportMCPConfig({ tool: "all" })
154
+ → Configs for all 5 supported MCP tools
155
+ ```
156
+
157
+ **Supported MCP tools**: cursor, claude-desktop, windsurf, continue, vscode
158
+
159
+ ### `getSetupInstructions` ⭐ NEW
160
+
161
+ Get detailed step-by-step setup instructions for a specific AI tool.
162
+
163
+ ```
164
+ getSetupInstructions({ tool: "cursor" })
165
+ → Complete setup guide with MCP config, verification steps, etc.
166
+
167
+ getSetupInstructions({ tool: "copilot" })
168
+ → Instructions for GitHub Copilot (uses rules file, not MCP)
169
+ ```
170
+
171
+ ### `generateCursorRules` (deprecated)
172
+
173
+ Use `getAIToolRules({ tool: "cursor" })` instead.
174
+
175
+ ## Token Tier System
176
+
177
+ Atomix uses a 3-tier token hierarchy:
178
+
179
+ | Tier | Mutable | Purpose | AI Usage |
180
+ |------|---------|---------|----------|
181
+ | **Primitive** | No | Raw values (hex colors, px values) | Read-only reference |
182
+ | **Semantic** | Yes | Purpose-driven tokens | Primary API for styling |
183
+ | **Component** | Yes | Component-specific assignments | Via Designer UI |
184
+
185
+ **Rule**: AI tools should use **semantic tokens** (Tier 2) in generated code, never primitives directly.
186
+
187
+ ## Resources
188
+
189
+ The server exposes token data as MCP resources:
190
+
191
+ - `atomix://tokens/all` — Complete token reference
192
+ - `atomix://tokens/colors` — Color tokens
193
+ - `atomix://tokens/typography` — Typography tokens
194
+ - `atomix://tokens/spacing` — Spacing tokens
195
+ - `atomix://components` — Component token mappings
196
+
197
+ ## Development
198
+
199
+ ```bash
200
+ # Watch mode
201
+ npm run dev
202
+
203
+ # Build
204
+ npm run build
205
+
206
+ # Sync component tokens from Atomix Lab
207
+ npm run sync
208
+
209
+ # Run tests
210
+ npm test
211
+
212
+ # Run stress tests (all 10 scenarios)
213
+ npm run test:stress
214
+
215
+ # Run specific stress test scenario
216
+ npm run test:scenario -- 5
217
+ ```
218
+
219
+ ## Stress Test Scenarios
220
+
221
+ The stress test suite validates multi-tenant scenarios and the build/sync pipeline:
222
+
223
+ | # | Scenario | What It Tests |
224
+ |---|----------|---------------|
225
+ | 1 | Brand Color Override Storm | Rapid consecutive saves, tenant-specific tokens |
226
+ | 2 | New Variant Hot-Add | Dynamic variant discovery without code changes |
227
+ | 3 | Size Matrix Explosion | Token lookup performance at scale (1000 lookups) |
228
+ | 4 | Cross-Component Cascade | Shared base components, typography inheritance |
229
+ | 5 | Concurrent Multi-Tenant Saves | Race conditions, tenant isolation (gap identified) |
230
+ | 6 | Primitive Token Drift | Invalid/renamed token detection |
231
+ | 7 | Breaking Change Detection | Variant removal warnings (gap identified) |
232
+ | 8 | Locked Token Enforcement | Token mutability rules (gap identified) |
233
+ | 9 | AI Tool Rules Generation | Rules generator performance for 350 projects |
234
+ | 10 | Hot Reload Chain Reaction | Rapid saves, final state consistency |
235
+
236
+ ### Known Gaps (Identified by Tests)
237
+
238
+ | Gap | Priority | Description |
239
+ |-----|----------|-------------|
240
+ | Multi-tenant isolation | P1 | Separate storage per tenant not yet implemented |
241
+ | Breaking change detection | P2 | No diff comparison when variants are removed |
242
+ | Locked token enforcement | P2 | No API validation for immutable tokens |
243
+
244
+ ## Architecture
245
+
246
+ ```
247
+ packages/atomix-mcp/
248
+ ├── src/
249
+ │ ├── index.ts # MCP server entry point
250
+ │ ├── tokens.ts # Re-exports @atomix/tokens
251
+ │ ├── utils.ts # Token traversal utilities
252
+ │ ├── component-tokens.ts # Component → token mappings (auto-generated)
253
+ │ ├── ai-rules-generator.ts # AI tool rules & MCP config generator
254
+ │ └── tenant-store.ts # Multi-tenant storage
255
+ ├── scripts/
256
+ │ └── sync-component-tokens.cjs # Sync from Atomix Lab
257
+ ├── data/
258
+ │ ├── tenants/ # Per-tenant configurations
259
+ │ └── component-tokens-snapshot.json # Breaking change detection
260
+ ├── tests/
261
+ │ └── stress-test.cjs # Multi-tenant stress tests
262
+ ├── package.json
263
+ └── tsconfig.json
264
+ ```
265
+
266
+ ## How It Works
267
+
268
+ 1. AI tool spawns the MCP server as a subprocess (via stdio)
269
+ 2. When you ask about design tokens, the AI queries the MCP server
270
+ 3. The server reads from `@atomix/tokens` primitives and `token-map.json`
271
+ 4. Responses include token values, CSS variable names, tier info, and usage examples
272
+ 5. Rules files (`.cursorrules`, etc.) provide project-level guidance
273
+
274
+ ## Token Path Format
275
+
276
+ Tokens use dot notation:
277
+
278
+ | Path | Tier | Description |
279
+ |------|------|-------------|
280
+ | `colors.scales.green.500` | Primitive | Raw green color |
281
+ | `colors.modes.light.bgSurface` | Semantic | Light mode surface background |
282
+ | `spacing.scale.md` | Primitive | Medium spacing value |
283
+ | `typography.fontSize.sm` | Primitive | Small font size |
284
+ | `radius.semantic.button` | Semantic | Button border radius |
285
+
286
+ ## CSS Variable Mapping
287
+
288
+ Token paths map to CSS variables:
289
+
290
+ ```
291
+ colors.static.brand.primary → --atomix-colors-static-brand-primary
292
+ spacing.scale.md → --atomix-spacing-scale-md
293
+ ```
294
+
295
+ Semantic aliases are also available:
296
+
297
+ ```
298
+ --atomix-brand (alias for colors.static.brand.primary)
299
+ --atomix-bg-surface (alias for colors.modes.{mode}.bgSurface)
300
+ ```
301
+
302
+ ## Multi-Tenant Support (Future)
303
+
304
+ The MCP server is prepared for multi-tenant operation:
305
+
306
+ ```bash
307
+ # Use tenant-specific tokens
308
+ ATOMIX_TENANT_ID=my-company npm start
309
+
310
+ # Connect to Atomix Cloud (future)
311
+ ATOMIX_CLOUD_API=https://cloud.atomix.design npm start
312
+ ```
313
+
314
+ ## Changelog
315
+
316
+ ### v0.2.0
317
+ - Added multi-tool support (`getAIToolRules`, `listAITools`, `getAIToolSetupGuide`)
318
+ - Added token tier system (primitive vs semantic)
319
+ - Added `tier` and `mutable` metadata to token responses
320
+ - Prepared for multi-tenant support
321
+
322
+ ### v0.1.0
323
+ - Initial MCP server with token querying
324
+ - Component token mappings
325
+ - `.cursorrules` generation