@atomixstudio/mcp 0.1.0 → 1.0.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 CHANGED
@@ -1,325 +1,109 @@
1
1
  # @atomixstudio/mcp
2
2
 
3
- MCP (Model Context Protocol) server for the Atomix Design System.
3
+ MCP (Model Context Protocol) server for Atomix Design System. Query your design tokens directly from AI coding tools like Cursor, Claude Desktop, Windsurf, and more.
4
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
5
+ ## Installation
24
6
 
25
7
  ```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
-
8
+ npm install -g @atomixstudio/mcp
9
+ # or use directly with npx
10
+ npx @atomixstudio/mcp --ds-id <your-ds-id> --api-key <your-api-key>
47
11
  ```
48
- # Generate rules for a specific tool
49
- getAIToolRules({ tool: "copilot", projectName: "My App", strict: true })
50
12
 
51
- # Generate rules for ALL tools at once
52
- getAIToolRules({ tool: "all", projectName: "My App" })
13
+ ## Getting Your Credentials
53
14
 
54
- # Get a setup guide
55
- getAIToolSetupGuide({ projectName: "My App" })
56
- ```
15
+ 1. Go to [Atomix Studio](https://atomixstudio.eu)
16
+ 2. Sign in and access your design system
17
+ 3. Click **Export** → Generate API Key
18
+ 4. Your `ds-id` is in the URL: `atomixstudio.eu/ds/[ds-id]`
57
19
 
58
- ## Available Tools
20
+ ## Quick Setup
59
21
 
60
- ### `getToken`
22
+ ### Cursor IDE
61
23
 
62
- Get a specific token by its path.
24
+ Create `.cursor/mcp.json` in your project root:
63
25
 
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
26
+ ```json
27
+ {
28
+ "mcpServers": {
29
+ "my-design-system": {
30
+ "command": "npx",
31
+ "args": ["@atomixstudio/mcp@latest", "--ds-id", "<your-ds-id>", "--api-key", "<your-api-key>"]
32
+ }
74
33
  }
34
+ }
75
35
  ```
76
36
 
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
- ```
37
+ ### Claude Desktop
95
38
 
96
- ### `validateUsage`
39
+ Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
97
40
 
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
41
+ ```json
42
+ {
43
+ "mcpServers": {
44
+ "my-design-system": {
45
+ "command": "npx",
46
+ "args": ["@atomixstudio/mcp@latest", "--ds-id", "<your-ds-id>", "--api-key", "<your-api-key>"]
47
+ }
48
+ }
49
+ }
217
50
  ```
218
51
 
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)
52
+ ### Windsurf
237
53
 
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 |
54
+ Create `.windsurf/mcp.json` in your project root (same format as Cursor).
243
55
 
244
- ## Architecture
56
+ ## Available Tools
245
57
 
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
- ```
58
+ Once connected, AI tools can use these MCP tools:
265
59
 
266
- ## How It Works
60
+ | Tool | Description |
61
+ |------|-------------|
62
+ | `getToken(path)` | Get a specific token by path (e.g., `colors.brand.primary`) |
63
+ | `listTokens(category)` | List all tokens in a category |
64
+ | `searchTokens(query)` | Search tokens by name or value |
65
+ | `validateUsage(value)` | Check if a hardcoded value should use a token |
66
+ | `getAIToolRules(tool)` | Generate AI coding rules for your design system |
67
+ | `exportMCPConfig(tool)` | Get MCP configuration for different tools |
68
+ | `getSetupInstructions(tool)` | Get detailed setup guide |
267
69
 
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
70
+ ## Token Categories
273
71
 
274
- ## Token Path Format
72
+ - **colors** Brand, background, text, icon, border, action, feedback colors
73
+ - **typography** — Font families, sizes, weights, line heights
74
+ - **spacing** — Scale tokens (xs, sm, md, lg, xl, etc.)
75
+ - **sizing** — Component heights, icon sizes
76
+ - **shadows** — Elevation scale
77
+ - **radius** — Border radius scale
78
+ - **borders** — Border width tokens
79
+ - **motion** — Duration and easing tokens
80
+ - **zIndex** — Layer tokens
275
81
 
276
- Tokens use dot notation:
82
+ ## Example Usage
277
83
 
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 |
84
+ After setup, ask your AI tool:
285
85
 
286
- ## CSS Variable Mapping
86
+ > "What color tokens are available in my design system?"
287
87
 
288
- Token paths map to CSS variables:
88
+ > "Use the correct spacing token for 16px padding"
289
89
 
290
- ```
291
- colors.static.brand.primary → --atomix-colors-static-brand-primary
292
- spacing.scale.md → --atomix-spacing-scale-md
293
- ```
90
+ > "Validate this: style={{ backgroundColor: '#007061' }}"
294
91
 
295
- Semantic aliases are also available:
92
+ ## CLI Options
296
93
 
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)
94
+ | Option | Description |
95
+ |--------|-------------|
96
+ | `--ds-id` | Your design system ID (required) |
97
+ | `--api-key` | Your API key for authentication |
98
+ | `--api-base` | API base URL (default: https://atomixstudio.eu) |
303
99
 
304
- The MCP server is prepared for multi-tenant operation:
100
+ ## Links
305
101
 
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
- ```
102
+ - [Atomix Studio](https://atomixstudio.eu)
103
+ - [Documentation](https://atomixstudio.eu/docs)
104
+ - [MCP Protocol](https://modelcontextprotocol.io)
313
105
 
314
- ## Changelog
106
+ ## License
315
107
 
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
108
+ MIT
321
109
 
322
- ### v0.1.0
323
- - Initial MCP server with token querying
324
- - Component token mappings
325
- - `.cursorrules` generation
package/dist/index.d.ts CHANGED
@@ -1,202 +1,2 @@
1
- /**
2
- * User Tokens Fetcher
3
- * -------------------
4
- * Fetches user-specific design system tokens from Atomix API.
5
- *
6
- * Used when MCP server is run with --ds-id flag to serve a user's
7
- * custom design system instead of Atomix's internal tokens.
8
- */
9
- interface UserDesignSystem {
10
- id: string;
11
- name: string;
12
- tokens: Record<string, unknown>;
13
- governance?: {
14
- rules: string[];
15
- categories?: Record<string, string[]>;
16
- };
17
- }
18
- interface FetchUserDSOptions {
19
- /** User's design system ID */
20
- dsId: string;
21
- /** API key for authentication */
22
- apiKey?: string;
23
- /** Base URL for the Atomix API (default: https://atomix.design) */
24
- baseUrl?: string;
25
- }
26
- interface UserDSMeta {
27
- id: string;
28
- name: string;
29
- publishedAt?: number;
30
- updatedAt?: number;
31
- version?: number;
32
- }
33
- interface UserDSResponse {
34
- success: boolean;
35
- tokens?: Record<string, unknown>;
36
- governance?: UserDesignSystem['governance'];
37
- meta?: UserDSMeta;
38
- error?: string;
39
- }
40
- /**
41
- * Fetch user's design system tokens from Atomix API
42
- *
43
- * @param options - Fetch options including dsId and apiKey
44
- * @returns User's tokens and governance rules
45
- *
46
- * @example
47
- * ```ts
48
- * const { tokens, governance } = await fetchUserDesignSystem({
49
- * dsId: 'abc123',
50
- * apiKey: 'user-api-key'
51
- * });
52
- * ```
53
- */
54
- declare function fetchUserDesignSystem(options: FetchUserDSOptions): Promise<UserDSResponse>;
55
- interface CLIArgs {
56
- /** User's design system ID */
57
- dsId?: string;
58
- /** API key for authentication */
59
- apiKey?: string;
60
- /** Tenant ID (legacy, mapped to dsId) */
61
- tenant?: string;
62
- /** Base URL for the Atomix API */
63
- baseUrl?: string;
64
- }
65
- /**
66
- * Parse command line arguments for user DS mode
67
- *
68
- * Supported args:
69
- * - --ds-id <id>: User's design system ID
70
- * - --api-key <key>: API key for authentication
71
- * - --tenant <id>: Legacy tenant ID (mapped to dsId)
72
- * - --base-url <url>: Custom API base URL
73
- *
74
- * @param argv - Command line arguments (default: process.argv)
75
- * @returns Parsed CLI arguments
76
- */
77
- declare function parseCLIArgs(argv?: string[]): CLIArgs;
78
- /**
79
- * Check if CLI args indicate user DS mode
80
- */
81
- declare function isUserDSMode(args: CLIArgs): boolean;
82
- /**
83
- * Transform user DS tokens to match the structure expected by MCP server.
84
- *
85
- * User DS tokens come in the StoredDesignSystem format from InstantDB.
86
- * This transforms them to the flat primitives structure used by MCP tools.
87
- *
88
- * @param userTokens - User's tokens from InstantDB
89
- * @returns Tokens in MCP-compatible format
90
- */
91
- declare function transformUserTokens(userTokens: Record<string, unknown>): Record<string, unknown>;
92
1
 
93
- /**
94
- * AI Rules Generator
95
- *
96
- * Generates project-specific rules and MCP configurations for AI coding tools
97
- * using the Atomix design system.
98
- *
99
- * SUPPORTED MCP CLIENTS (from modelcontextprotocol.io/clients):
100
- *
101
- * IDE/Editors:
102
- * - Cursor (.cursorrules)
103
- * - VS Code + GitHub Copilot (.github/copilot-instructions.md)
104
- * - Windsurf (.windsurfrules)
105
- * - Zed (MCP native)
106
- * - Continue (.continuerules)
107
- * - Cline (.clinerules)
108
- * - CodeGPT (MCP native)
109
- * - Amazon Q IDE (MCP native)
110
- * - Augment Code (MCP native)
111
- * - VT Code (MCP native)
112
- *
113
- * Desktop Apps:
114
- * - Claude Desktop (MCP native)
115
- * - BoltAI (MCP native)
116
- * - Chatbox (MCP native)
117
- * - ChatGPT (MCP native)
118
- *
119
- * CLI/Terminal:
120
- * - Warp (.warp/workflows or MCP)
121
- * - Amazon Q CLI (MCP native)
122
- * - goose (MCP native)
123
- *
124
- * Frameworks/Libraries:
125
- * - Genkit (MCP native)
126
- * - LangChain (MCP native)
127
- * - fast-agent (MCP native)
128
- */
129
- type AIToolId = "cursor" | "copilot" | "windsurf" | "cline" | "continue" | "zed" | "claude-desktop" | "generic";
130
- interface AIToolConfig {
131
- id: AIToolId;
132
- name: string;
133
- rulesFilename: string;
134
- rulesPath: string;
135
- mcpConfigPath?: string;
136
- supportsMarkdown: boolean;
137
- supportsMCP: boolean;
138
- description: string;
139
- }
140
- /**
141
- * Registry of supported AI coding tools and their rules file conventions
142
- */
143
- declare const AI_TOOLS: Record<AIToolId, AIToolConfig>;
144
- type MCPConfigToolId = "cursor" | "claude-desktop" | "windsurf" | "continue" | "vscode";
145
- interface MCPConfigOptions {
146
- /** Path to the MCP server (default: npx @atomixstudio/mcp) */
147
- serverPath?: string;
148
- /** Use npx to run the server */
149
- useNpx?: boolean;
150
- /** Design system ID for per-user MCP mode */
151
- dsId?: string;
152
- /** API key for authentication (required for per-user mode) */
153
- apiKey?: string;
154
- /** @deprecated Use dsId instead. Tenant ID for backwards compatibility */
155
- tenantId?: string;
156
- /** Project name for identification */
157
- projectName?: string;
158
- }
159
- interface MCPConfig {
160
- tool: MCPConfigToolId;
161
- filename: string;
162
- path: string;
163
- content: string;
164
- instructions: string;
165
- }
166
- /**
167
- * Generate MCP configuration file for a specific AI tool
168
- */
169
- declare function generateMCPConfig(tool: MCPConfigToolId, options?: MCPConfigOptions): MCPConfig;
170
- /**
171
- * Generate MCP configs for all supported tools
172
- */
173
- declare function generateAllMCPConfigs(options?: MCPConfigOptions): MCPConfig[];
174
- /**
175
- * Get detailed setup instructions for a specific AI tool
176
- */
177
- declare function getSetupInstructions(toolId: AIToolId): string;
178
- declare function generateCursorRules(projectName: string, strict: boolean): string;
179
- interface GeneratedRulesFile {
180
- tool: AIToolConfig;
181
- filename: string;
182
- path: string;
183
- content: string;
184
- }
185
- /**
186
- * Generate rules for a specific AI tool
187
- */
188
- declare function generateRulesForTool(toolId: AIToolId, projectName: string, strict: boolean): GeneratedRulesFile;
189
- /**
190
- * Generate rules for ALL supported AI tools at once
191
- */
192
- declare function generateRulesForAllTools(projectName: string, strict: boolean): GeneratedRulesFile[];
193
- /**
194
- * Get list of all supported AI tools
195
- */
196
- declare function getSupportedAITools(): AIToolConfig[];
197
- /**
198
- * Generate a summary of which files to create for full AI tool support
199
- */
200
- declare function generateToolSetupGuide(projectName: string): string;
201
-
202
- export { type AIToolId, AI_TOOLS, type MCPConfigToolId, fetchUserDesignSystem, generateAllMCPConfigs, generateCursorRules, generateMCPConfig, generateRulesForAllTools, generateRulesForTool, generateToolSetupGuide, getSetupInstructions, getSupportedAITools, isUserDSMode, parseCLIArgs, transformUserTokens };
2
+ export { }