@fragments-sdk/mcp 0.2.3 → 0.3.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,12 +1,10 @@
1
1
  # @fragments-sdk/mcp
2
2
 
3
- MCP (Model Context Protocol) server that gives AI agents access to your design system. Agents can list components, get usage guidelines, view code examples, suggest components for use cases, and more.
3
+ Standalone MCP server for the Fragments design system. Gives AI coding assistants (Claude Code, Cursor, etc.) semantic search over components, blocks, and tokens no Playwright or build tools required.
4
4
 
5
- ## Quick Start
5
+ ## Setup
6
6
 
7
- ### With Claude Code
8
-
9
- Add to your Claude Code MCP settings (`~/.claude/settings.json`):
7
+ Add to your editor's MCP config:
10
8
 
11
9
  ```json
12
10
  {
@@ -19,73 +17,37 @@ Add to your Claude Code MCP settings (`~/.claude/settings.json`):
19
17
  }
20
18
  ```
21
19
 
22
- The server automatically discovers `fragments.json` from any installed package that declares a `"fragments"` field in its `package.json` (e.g., `@fragments-sdk/ui`).
23
-
24
- ### With other MCP clients
25
-
26
- Run the server directly:
27
-
28
- ```bash
29
- npx @fragments-sdk/mcp
30
- ```
31
-
32
- Options:
33
-
34
- ```
35
- -p, --project-root <path> Project root directory (default: cwd)
36
- -u, --viewer-url <url> Viewer URL (default: http://localhost:6006)
37
- -h, --help Show this help message
38
- ```
39
-
40
- ## How It Works
41
-
42
- 1. Install a component library that ships `fragments.json` (e.g., `npm install @fragments-sdk/ui`)
43
- 2. Add this MCP server to your AI tool
44
- 3. The server reads `fragments.json` from the installed package and exposes component data to the AI agent
45
-
46
- The server searches for `fragments.json` in two places:
47
- - **Your project directory** (walks upward from cwd) — for library authors running `fragments build`
48
- - **Your package.json dependencies** — for consumers who installed a fragments-enabled package
20
+ The server auto-discovers `fragments.json` by walking up from cwd and scanning `node_modules`.
49
21
 
50
- ## Available Tools
22
+ ## Tools
51
23
 
52
24
  | Tool | Description |
53
25
  |------|-------------|
54
- | `fragments_context` | Get full design system context in one call. Use this first. |
55
- | `fragments_list` | List all components with names, categories, and variant counts |
56
- | `fragments_get` | Get detailed component info: props, usage, variants |
57
- | `fragments_suggest` | Suggest components for a use case (e.g., "form for email input") |
58
- | `fragments_guidelines` | Get when/when-not-to-use guidelines and accessibility rules |
59
- | `fragments_alternatives` | Find alternative or related components |
60
- | `fragments_example` | Get ready-to-use code examples for component variants |
61
- | `fragments_recipe` | Search composition recipes (e.g., "Login Form", "Settings Page") |
62
- | `fragments_render` | Render a component with specific props and return a screenshot |
63
- | `fragments_verify` | Verify a component render against the baseline screenshot |
64
- | `fragments_compare` | Compare a rendered component against its Figma design |
65
- | `fragments_fix` | Generate patches to fix token compliance issues |
26
+ | `fragments_discover` | List, search, or get AI-powered component suggestions |
27
+ | `fragments_inspect` | Full component details props, examples, guidelines |
28
+ | `fragments_blocks` | Composition patterns (e.g. "Login Form", "Settings Page") |
29
+ | `fragments_tokens` | CSS custom properties by category |
30
+ | `fragments_implement` | One-shot: components + blocks + tokens for a use case |
31
+ | `fragments_render` | Render a component screenshot (requires dev server) |
32
+ | `fragments_fix` | Generate token-compliance patches (requires dev server) |
66
33
 
67
- ### Visual tools
34
+ ## How search works
68
35
 
69
- The `render`, `verify`, `compare`, and `fix` tools require [Playwright](https://playwright.dev/). Install it separately if you need visual tools:
70
-
71
- ```bash
72
- npm install playwright
73
- ```
36
+ Queries run through **hybrid search** Convex-hosted vector search (Voyage-Code-3 embeddings) fused with local keyword scoring via Reciprocal Rank Fusion. If Convex is unreachable, falls back silently to keyword-only.
74
37
 
75
- These tools are optional. All other tools work without Playwright.
38
+ ## Options
76
39
 
77
- ## Programmatic Usage
78
-
79
- ```typescript
80
- import { createMcpServer, startMcpServer } from '@fragments-sdk/mcp';
40
+ ```
41
+ -p, --project-root <path> Project root (default: cwd)
42
+ -u, --viewer-url <url> Dev server URL for render/fix tools
43
+ ```
81
44
 
82
- // Start with stdio transport (default)
83
- await startMcpServer({ projectRoot: process.cwd() });
45
+ ## Convex backend
84
46
 
85
- // Or create the server instance for custom transports
86
- const server = createMcpServer({ projectRoot: process.cwd() });
87
- ```
47
+ The `convex/` directory contains the hosted search backend:
88
48
 
89
- ## License
49
+ - **schema.ts** — `entries` table with vector index (components, blocks, tokens)
50
+ - **search.ts** — HTTP action that embeds queries with Voyage-Code-3 and runs vector search
51
+ - **ingest.ts** — Mutation to upsert entries at publish time
90
52
 
91
- MIT
53
+ Index entries: `pnpm --filter @fragments-sdk/mcp index` (requires `VOYAGE_API_KEY` and `CONVEX_URL`).
package/package.json CHANGED
@@ -1,19 +1,20 @@
1
1
  {
2
2
  "name": "@fragments-sdk/mcp",
3
- "version": "0.2.3",
4
- "description": "MCP server for AI agent integration with Fragments",
3
+ "version": "0.3.0",
4
+ "description": "Standalone MCP server for Fragments design system — zero-config component discovery with semantic search",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "fragments-mcp": "./dist/bin.js"
8
8
  },
9
+ "main": "./dist/server.js",
10
+ "module": "./dist/server.js",
11
+ "types": "./dist/server.d.ts",
9
12
  "exports": {
10
13
  ".": {
11
- "import": "./dist/index.js",
12
- "types": "./dist/index.d.ts"
14
+ "types": "./dist/server.d.ts",
15
+ "import": "./dist/server.js"
13
16
  }
14
17
  },
15
- "main": "./dist/index.js",
16
- "types": "./dist/index.d.ts",
17
18
  "publishConfig": {
18
19
  "access": "public"
19
20
  },
@@ -24,27 +25,17 @@
24
25
  "@modelcontextprotocol/sdk": "^1.0.0"
25
26
  },
26
27
  "devDependencies": {
27
- "@types/node": "^20.10.0",
28
- "tsup": "^8.0.1",
29
- "typescript": "^5.7.2",
30
- "vitest": "^2.1.9",
31
- "@fragments/core": "0.2.0",
32
- "@fragments/service": "0.1.1"
33
- },
34
- "peerDependencies": {
35
- "typescript": "^5.0.0",
36
- "playwright": "^1.40.0"
37
- },
38
- "peerDependenciesMeta": {
39
- "playwright": {
40
- "optional": true
41
- }
28
+ "@types/node": "^22.0.0",
29
+ "convex": "^1.17.0",
30
+ "tsup": "^8.3.5",
31
+ "tsx": "^4.19.0",
32
+ "typescript": "^5.7.2"
42
33
  },
43
34
  "scripts": {
44
35
  "build": "tsup",
45
36
  "dev": "tsup --watch",
46
- "test": "vitest run",
47
37
  "typecheck": "tsc --noEmit",
48
- "clean": "rm -rf dist"
38
+ "clean": "rm -rf dist",
39
+ "index": "tsx scripts/index-components.ts"
49
40
  }
50
41
  }
package/dist/bin.d.ts DELETED
@@ -1 +0,0 @@
1
- #!/usr/bin/env node
package/dist/bin.js DELETED
@@ -1,37 +0,0 @@
1
- #!/usr/bin/env node
2
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
3
- import {
4
- startMcpServer
5
- } from "./chunk-OQOBENAX.js";
6
- import "./chunk-7OMNY6JX.js";
7
-
8
- // src/bin.ts
9
- var args = process.argv.slice(2);
10
- var projectRoot = process.cwd();
11
- var viewerUrl;
12
- for (let i = 0; i < args.length; i++) {
13
- const arg = args[i];
14
- if (arg === "--project-root" || arg === "-p") {
15
- projectRoot = args[++i] ?? projectRoot;
16
- } else if (arg === "--viewer-url" || arg === "-u") {
17
- viewerUrl = args[++i];
18
- } else if (arg === "--help" || arg === "-h") {
19
- console.log(`
20
- Usage: fragments-mcp [options]
21
-
22
- Options:
23
- -p, --project-root <path> Project root directory (default: cwd)
24
- -u, --viewer-url <url> Viewer URL (default: http://localhost:6006)
25
- -h, --help Show this help message
26
- `);
27
- process.exit(0);
28
- }
29
- }
30
- startMcpServer({
31
- projectRoot,
32
- viewerUrl
33
- }).catch((error) => {
34
- console.error("Failed to start MCP server:", error);
35
- process.exit(1);
36
- });
37
- //# sourceMappingURL=bin.js.map
package/dist/bin.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/bin.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { startMcpServer } from './server.js';\n\n// Parse command line arguments\nconst args = process.argv.slice(2);\nlet projectRoot = process.cwd();\nlet viewerUrl: string | undefined;\n\nfor (let i = 0; i < args.length; i++) {\n const arg = args[i];\n\n if (arg === '--project-root' || arg === '-p') {\n projectRoot = args[++i] ?? projectRoot;\n } else if (arg === '--viewer-url' || arg === '-u') {\n viewerUrl = args[++i];\n } else if (arg === '--help' || arg === '-h') {\n console.log(`\nUsage: fragments-mcp [options]\n\nOptions:\n -p, --project-root <path> Project root directory (default: cwd)\n -u, --viewer-url <url> Viewer URL (default: http://localhost:6006)\n -h, --help Show this help message\n`);\n process.exit(0);\n }\n}\n\n// Start server\nstartMcpServer({\n projectRoot,\n viewerUrl,\n}).catch((error) => {\n console.error('Failed to start MCP server:', error);\n process.exit(1);\n});\n"],"mappings":";;;;;;;;AAIA,IAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AACjC,IAAI,cAAc,QAAQ,IAAI;AAC9B,IAAI;AAEJ,SAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,QAAM,MAAM,KAAK,CAAC;AAElB,MAAI,QAAQ,oBAAoB,QAAQ,MAAM;AAC5C,kBAAc,KAAK,EAAE,CAAC,KAAK;AAAA,EAC7B,WAAW,QAAQ,kBAAkB,QAAQ,MAAM;AACjD,gBAAY,KAAK,EAAE,CAAC;AAAA,EACtB,WAAW,QAAQ,YAAY,QAAQ,MAAM;AAC3C,YAAQ,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAOf;AACG,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;AAGA,eAAe;AAAA,EACb;AAAA,EACA;AACF,CAAC,EAAE,MAAM,CAAC,UAAU;AAClB,UAAQ,MAAM,+BAA+B,KAAK;AAClD,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":[]}