@getflip/swirl-mcp 0.1.1 → 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 +12 -5
- package/dist/{chunk-656TS2QU.js → chunk-HWC76PLD.js} +147 -60
- package/dist/transports/http.js +1 -1
- package/dist/transports/stdio.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# @getflip/swirl-mcp
|
|
2
2
|
|
|
3
|
-
MCP server that lets AI agents discover and use
|
|
3
|
+
MCP server that lets AI agents discover and use
|
|
4
|
+
[Swirl Design System](https://getflip.dev) components.
|
|
4
5
|
|
|
5
6
|
## Setup
|
|
6
7
|
|
|
@@ -41,7 +42,8 @@ npx @modelcontextprotocol/inspector node dist/transports/stdio.js
|
|
|
41
42
|
|
|
42
43
|
### HTTP
|
|
43
44
|
|
|
44
|
-
Start the server, then open the Inspector and connect with transport type
|
|
45
|
+
Start the server, then open the Inspector and connect with transport type
|
|
46
|
+
"Streamable HTTP" and URL `http://localhost:3000/mcp`:
|
|
45
47
|
|
|
46
48
|
```sh
|
|
47
49
|
npx tsx src/transports/http.ts
|
|
@@ -55,12 +57,17 @@ npx @modelcontextprotocol/inspector
|
|
|
55
57
|
| **list_components** | Lists all Swirl UI components with brief summaries and related components. |
|
|
56
58
|
| **list_icons** | Lists all Swirl icon components. |
|
|
57
59
|
| **list_symbols** | Lists all Swirl symbol components. |
|
|
58
|
-
| **list_emojis** | Lists all Swirl emoji components. |
|
|
59
60
|
| **get_component_details** | Full component docs: props, events, slots, examples, and accessibility info. |
|
|
61
|
+
| **get_component_source** | Versioned original TSX and CSS source for a specific component. |
|
|
60
62
|
| **get_started** | Installation and setup guide for Web Components, Angular, and React. |
|
|
61
63
|
|
|
62
|
-
All tools accept a `version` parameter matching the installed
|
|
64
|
+
All tools accept a `version` parameter matching the installed
|
|
65
|
+
`@getflip/swirl-components` version.
|
|
63
66
|
|
|
64
67
|
## How it works
|
|
65
68
|
|
|
66
|
-
Component metadata and documentation are fetched at runtime from
|
|
69
|
+
Component metadata and documentation are fetched at runtime from
|
|
70
|
+
`@getflip/swirl-ai` artifacts on the unpkg CDN. Versioned component source is
|
|
71
|
+
fetched from matching `@getflip/swirl-components@<version>` tags in the Swirl
|
|
72
|
+
GitHub repository. Loaded libraries are cached in-memory to avoid redundant
|
|
73
|
+
fetches.
|
|
@@ -20,6 +20,17 @@ var DataSource = class {
|
|
|
20
20
|
}
|
|
21
21
|
async readText(relativePath) {
|
|
22
22
|
const url = `${this.baseUrl}/${relativePath}`;
|
|
23
|
+
return this.readTextUrl(url);
|
|
24
|
+
}
|
|
25
|
+
async readComponentSource(tag) {
|
|
26
|
+
const componentPath = `packages/swirl-components/src/components/${tag}/${tag}`;
|
|
27
|
+
const [tsx, css] = await Promise.all([
|
|
28
|
+
this.readTextUrl(`${this.sourceBaseUrl}/${componentPath}.tsx`),
|
|
29
|
+
this.readTextUrl(`${this.sourceBaseUrl}/${componentPath}.css`)
|
|
30
|
+
]);
|
|
31
|
+
return { tsx, css };
|
|
32
|
+
}
|
|
33
|
+
async readTextUrl(url) {
|
|
23
34
|
try {
|
|
24
35
|
const res = await fetch(url);
|
|
25
36
|
if (!res.ok) {
|
|
@@ -33,6 +44,9 @@ var DataSource = class {
|
|
|
33
44
|
get baseUrl() {
|
|
34
45
|
return `https://unpkg.com/@getflip/swirl-ai@${this.version}/dist/agent`;
|
|
35
46
|
}
|
|
47
|
+
get sourceBaseUrl() {
|
|
48
|
+
return `https://raw.githubusercontent.com/getflip/swirl/@getflip/swirl-components@${this.version}`;
|
|
49
|
+
}
|
|
36
50
|
};
|
|
37
51
|
|
|
38
52
|
// src/artifact-library.ts
|
|
@@ -67,6 +81,9 @@ var ArtifactLibrary = class _ArtifactLibrary {
|
|
|
67
81
|
async getComponentMarkdown(tag) {
|
|
68
82
|
return this.dataSource.readText(`components/${tag}.md`);
|
|
69
83
|
}
|
|
84
|
+
async getComponentSource(tag) {
|
|
85
|
+
return this.dataSource.readComponentSource(tag);
|
|
86
|
+
}
|
|
70
87
|
async getGuide(name) {
|
|
71
88
|
return this.dataSource.readText(`${name}.md`);
|
|
72
89
|
}
|
|
@@ -78,9 +95,6 @@ function categorize(tag) {
|
|
|
78
95
|
if (tag.startsWith("swirl-symbol-")) {
|
|
79
96
|
return "symbol";
|
|
80
97
|
}
|
|
81
|
-
if (tag.startsWith("swirl-emoji-")) {
|
|
82
|
-
return "emoji";
|
|
83
|
-
}
|
|
84
98
|
return "core";
|
|
85
99
|
}
|
|
86
100
|
|
|
@@ -110,73 +124,59 @@ var LibraryCache = class {
|
|
|
110
124
|
}
|
|
111
125
|
};
|
|
112
126
|
|
|
113
|
-
// src/tools/
|
|
127
|
+
// src/tools/get-component-details.ts
|
|
114
128
|
import { z } from "zod";
|
|
115
129
|
var VERSION_DESCRIPTION = "The @getflip/swirl-components version installed in the project. Read the user's package.json or node_modules/@getflip/swirl-components/package.json to find this.";
|
|
116
|
-
function
|
|
117
|
-
registerListTool(
|
|
118
|
-
server,
|
|
119
|
-
loadLibrary2,
|
|
120
|
-
"list_components",
|
|
121
|
-
"List all Swirl design system UI components (buttons, modals, forms, etc.) with brief summaries and related components. Does NOT include icons, symbols, or emojis \u2014 use list_icons, list_symbols, or list_emojis for those. Use get_component_details for full props, events, slots, and examples. IMPORTANT: First read the user's package.json to determine their installed @getflip/swirl-components version, then pass it as the 'version' parameter.",
|
|
122
|
-
"core"
|
|
123
|
-
);
|
|
124
|
-
}
|
|
125
|
-
function registerListIcons(server, loadLibrary2) {
|
|
126
|
-
registerListTool(
|
|
127
|
-
server,
|
|
128
|
-
loadLibrary2,
|
|
129
|
-
"list_icons",
|
|
130
|
-
"List all Swirl icon components (swirl-icon-*). Use get_component_details for full details on a specific icon. IMPORTANT: First read the user's package.json to determine their installed @getflip/swirl-components version, then pass it as the 'version' parameter.",
|
|
131
|
-
"icon"
|
|
132
|
-
);
|
|
133
|
-
}
|
|
134
|
-
function registerListSymbols(server, loadLibrary2) {
|
|
135
|
-
registerListTool(
|
|
136
|
-
server,
|
|
137
|
-
loadLibrary2,
|
|
138
|
-
"list_symbols",
|
|
139
|
-
"List all Swirl symbol components (swirl-symbol-*). Use get_component_details for full details on a specific symbol. IMPORTANT: First read the user's package.json to determine their installed @getflip/swirl-components version, then pass it as the 'version' parameter.",
|
|
140
|
-
"symbol"
|
|
141
|
-
);
|
|
142
|
-
}
|
|
143
|
-
function registerListEmojis(server, loadLibrary2) {
|
|
144
|
-
registerListTool(
|
|
145
|
-
server,
|
|
146
|
-
loadLibrary2,
|
|
147
|
-
"list_emojis",
|
|
148
|
-
"List all Swirl emoji components (swirl-emoji-*). Use get_component_details for full details on a specific emoji. IMPORTANT: First read the user's package.json to determine their installed @getflip/swirl-components version, then pass it as the 'version' parameter.",
|
|
149
|
-
"emoji"
|
|
150
|
-
);
|
|
151
|
-
}
|
|
152
|
-
function registerListTool(server, loadLibrary2, name, description, category) {
|
|
130
|
+
function registerGetComponentDetails(server, loadLibrary2) {
|
|
153
131
|
server.registerTool(
|
|
154
|
-
|
|
132
|
+
"get_component_details",
|
|
155
133
|
{
|
|
156
|
-
description,
|
|
134
|
+
description: "Get full details for a Swirl component including all props with types and defaults, events, methods, slots, accessibility info, and usage examples.",
|
|
157
135
|
inputSchema: {
|
|
136
|
+
tag: z.string().describe('The component tag name, e.g. "swirl-button"'),
|
|
158
137
|
version: z.string().describe(VERSION_DESCRIPTION)
|
|
159
138
|
}
|
|
160
139
|
},
|
|
161
140
|
// @ts-ignore - MCP SDK + zod 3.x causes excessively deep type instantiation
|
|
162
|
-
async ({ version }) => {
|
|
141
|
+
async ({ tag, version }) => {
|
|
163
142
|
const lib = await loadLibrary2(version);
|
|
164
|
-
const
|
|
143
|
+
const entry = lib.getByTag(tag);
|
|
144
|
+
if (!entry) {
|
|
145
|
+
return {
|
|
146
|
+
content: [
|
|
147
|
+
{
|
|
148
|
+
type: "text",
|
|
149
|
+
text: `Component "${tag}" not found. Use list_components to see available components.`
|
|
150
|
+
}
|
|
151
|
+
]
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
const markdown = await lib.getComponentMarkdown(tag);
|
|
155
|
+
if (!markdown) {
|
|
156
|
+
return {
|
|
157
|
+
content: [
|
|
158
|
+
{
|
|
159
|
+
type: "text",
|
|
160
|
+
text: `Component "${tag}" exists but no detailed documentation was found.`
|
|
161
|
+
}
|
|
162
|
+
]
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
165
|
return {
|
|
166
|
-
content: [{ type: "text", text:
|
|
166
|
+
content: [{ type: "text", text: markdown }]
|
|
167
167
|
};
|
|
168
168
|
}
|
|
169
169
|
);
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
// src/tools/get-component-
|
|
172
|
+
// src/tools/get-component-source.ts
|
|
173
173
|
import { z as z2 } from "zod";
|
|
174
174
|
var VERSION_DESCRIPTION2 = "The @getflip/swirl-components version installed in the project. Read the user's package.json or node_modules/@getflip/swirl-components/package.json to find this.";
|
|
175
|
-
function
|
|
175
|
+
function registerGetComponentSource(server, loadLibrary2) {
|
|
176
176
|
server.registerTool(
|
|
177
|
-
"
|
|
177
|
+
"get_component_source",
|
|
178
178
|
{
|
|
179
|
-
description: "Get
|
|
179
|
+
description: "Get the versioned original TSX and CSS source files for a Swirl component. Use this when behavior, styling, layout, rendering details, debugging, or uncertainty requires the full implementation.",
|
|
180
180
|
inputSchema: {
|
|
181
181
|
tag: z2.string().describe('The component tag name, e.g. "swirl-button"'),
|
|
182
182
|
version: z2.string().describe(VERSION_DESCRIPTION2)
|
|
@@ -196,23 +196,34 @@ function registerGetComponentDetails(server, loadLibrary2) {
|
|
|
196
196
|
]
|
|
197
197
|
};
|
|
198
198
|
}
|
|
199
|
-
const
|
|
200
|
-
|
|
199
|
+
const source = await lib.getComponentSource(tag);
|
|
200
|
+
const sections = [
|
|
201
|
+
formatSourceSection(tag, "tsx", source.tsx),
|
|
202
|
+
formatSourceSection(tag, "css", source.css)
|
|
203
|
+
].filter(Boolean);
|
|
204
|
+
if (sections.length === 0) {
|
|
201
205
|
return {
|
|
202
206
|
content: [
|
|
203
207
|
{
|
|
204
208
|
type: "text",
|
|
205
|
-
text: `Component "${tag}" exists but no
|
|
209
|
+
text: `Component "${tag}" exists but no original source files were found for version "${version}". Make sure the version matches an @getflip/swirl-components release tag.`
|
|
206
210
|
}
|
|
207
211
|
]
|
|
208
212
|
};
|
|
209
213
|
}
|
|
210
214
|
return {
|
|
211
|
-
content: [{ type: "text", text:
|
|
215
|
+
content: [{ type: "text", text: sections.join("\n\n") }]
|
|
212
216
|
};
|
|
213
217
|
}
|
|
214
218
|
);
|
|
215
219
|
}
|
|
220
|
+
function formatSourceSection(tag, extension, content) {
|
|
221
|
+
if (!content) {
|
|
222
|
+
return void 0;
|
|
223
|
+
}
|
|
224
|
+
const path = `packages/swirl-components/src/components/${tag}/${tag}.${extension}`;
|
|
225
|
+
return [`## ${path}`, "", `\`\`\`\`${extension}`, content, "````"].join("\n");
|
|
226
|
+
}
|
|
216
227
|
|
|
217
228
|
// src/tools/get-started.ts
|
|
218
229
|
import { z as z3 } from "zod";
|
|
@@ -221,7 +232,7 @@ function registerGetStarted(server, loadLibrary2) {
|
|
|
221
232
|
server.registerTool(
|
|
222
233
|
"get_started",
|
|
223
234
|
{
|
|
224
|
-
description: "Get installation and setup instructions for Swirl components. Covers Web Components, Angular, and React wrapper libraries.
|
|
235
|
+
description: "Get installation and setup instructions for Swirl components. Covers Web Components, Angular, and React wrapper libraries.",
|
|
225
236
|
inputSchema: {
|
|
226
237
|
version: z3.string().describe(VERSION_DESCRIPTION3)
|
|
227
238
|
}
|
|
@@ -246,6 +257,56 @@ function registerGetStarted(server, loadLibrary2) {
|
|
|
246
257
|
);
|
|
247
258
|
}
|
|
248
259
|
|
|
260
|
+
// src/tools/list-components.ts
|
|
261
|
+
import { z as z4 } from "zod";
|
|
262
|
+
var VERSION_DESCRIPTION4 = "The @getflip/swirl-components version installed in the project. Read the user's package.json or node_modules/@getflip/swirl-components/package.json to find this.";
|
|
263
|
+
function registerListComponents(server, loadLibrary2) {
|
|
264
|
+
registerListTool(
|
|
265
|
+
server,
|
|
266
|
+
loadLibrary2,
|
|
267
|
+
"list_components",
|
|
268
|
+
"List all Swirl design system UI components (buttons, modals, forms, etc.) with brief summaries and related components. Does NOT include icons or symbols \u2014 use list_icons or list_symbols for those. Use get_component_details for full props, events, slots, and examples.",
|
|
269
|
+
"core"
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
function registerListIcons(server, loadLibrary2) {
|
|
273
|
+
registerListTool(
|
|
274
|
+
server,
|
|
275
|
+
loadLibrary2,
|
|
276
|
+
"list_icons",
|
|
277
|
+
"List all Swirl icon components (swirl-icon-*). Use get_component_details for full details on a specific icon.",
|
|
278
|
+
"icon"
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
function registerListSymbols(server, loadLibrary2) {
|
|
282
|
+
registerListTool(
|
|
283
|
+
server,
|
|
284
|
+
loadLibrary2,
|
|
285
|
+
"list_symbols",
|
|
286
|
+
"List all Swirl symbol components (swirl-symbol-*). Use get_component_details for full details on a specific symbol.",
|
|
287
|
+
"symbol"
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
function registerListTool(server, loadLibrary2, name, description, category) {
|
|
291
|
+
server.registerTool(
|
|
292
|
+
name,
|
|
293
|
+
{
|
|
294
|
+
description,
|
|
295
|
+
inputSchema: {
|
|
296
|
+
version: z4.string().describe(VERSION_DESCRIPTION4)
|
|
297
|
+
}
|
|
298
|
+
},
|
|
299
|
+
// @ts-ignore - MCP SDK + zod 3.x causes excessively deep type instantiation
|
|
300
|
+
async ({ version }) => {
|
|
301
|
+
const lib = await loadLibrary2(version);
|
|
302
|
+
const components = lib.getByCategory(category);
|
|
303
|
+
return {
|
|
304
|
+
content: [{ type: "text", text: JSON.stringify(components) }]
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
|
|
249
310
|
// src/create-server.ts
|
|
250
311
|
var cache = new LibraryCache();
|
|
251
312
|
async function loadLibrary(version) {
|
|
@@ -264,16 +325,42 @@ async function loadLibrary(version) {
|
|
|
264
325
|
);
|
|
265
326
|
}
|
|
266
327
|
}
|
|
328
|
+
var INSTRUCTIONS = `Use this server as the authoritative, version-aware source for the Swirl design system (@getflip/swirl-components).
|
|
329
|
+
|
|
330
|
+
If a project has @getflip/swirl-components installed, use Swirl as the default
|
|
331
|
+
UI system for all UI work. Prefer Swirl components, icons, symbols, tokens, and
|
|
332
|
+
documented patterns over custom UI. Only build custom UI when no suitable Swirl
|
|
333
|
+
component or pattern exists.
|
|
334
|
+
|
|
335
|
+
For any UI task in a project that uses Swirl, call the appropriate Swirl MCP
|
|
336
|
+
tool before choosing or implementing UI. Do not infer component APIs, prop names,
|
|
337
|
+
token values, icon names, or usage patterns from memory.
|
|
338
|
+
|
|
339
|
+
Use get_component_details for documented component APIs, accessibility guidance,
|
|
340
|
+
slots, events, examples, and related components. When behavior, styling, layout,
|
|
341
|
+
rendering details, debugging, or uncertainty requires the full picture, use
|
|
342
|
+
get_component_source to read the versioned original source and styles for the
|
|
343
|
+
specific component as well.
|
|
344
|
+
|
|
345
|
+
Every tool requires a 'version' parameter matching the project's
|
|
346
|
+
installed @getflip/swirl-components version. Read it from the user's
|
|
347
|
+
package.json (or node_modules/@getflip/swirl-components/package.json)
|
|
348
|
+
before the first tool call and reuse it for subsequent calls.`;
|
|
267
349
|
function createMcpServer() {
|
|
268
|
-
const server = new McpServer(
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
350
|
+
const server = new McpServer(
|
|
351
|
+
{
|
|
352
|
+
name: "swirl-mcp",
|
|
353
|
+
version: "0.1.0"
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
instructions: INSTRUCTIONS
|
|
357
|
+
}
|
|
358
|
+
);
|
|
272
359
|
registerListComponents(server, loadLibrary);
|
|
273
360
|
registerListIcons(server, loadLibrary);
|
|
274
361
|
registerListSymbols(server, loadLibrary);
|
|
275
|
-
registerListEmojis(server, loadLibrary);
|
|
276
362
|
registerGetComponentDetails(server, loadLibrary);
|
|
363
|
+
registerGetComponentSource(server, loadLibrary);
|
|
277
364
|
registerGetStarted(server, loadLibrary);
|
|
278
365
|
return server;
|
|
279
366
|
}
|
package/dist/transports/http.js
CHANGED
package/dist/transports/stdio.js
CHANGED