@getflip/swirl-mcp 0.2.0 → 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 -4
- package/dist/{chunk-4X45IM6A.js → chunk-HWC76PLD.js} +146 -58
- 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
|
|
@@ -56,10 +58,16 @@ npx @modelcontextprotocol/inspector
|
|
|
56
58
|
| **list_icons** | Lists all Swirl icon components. |
|
|
57
59
|
| **list_symbols** | Lists all Swirl symbol components. |
|
|
58
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. |
|
|
59
62
|
| **get_started** | Installation and setup guide for Web Components, Angular, and React. |
|
|
60
63
|
|
|
61
|
-
All tools accept a `version` parameter matching the installed
|
|
64
|
+
All tools accept a `version` parameter matching the installed
|
|
65
|
+
`@getflip/swirl-components` version.
|
|
62
66
|
|
|
63
67
|
## How it works
|
|
64
68
|
|
|
65
|
-
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
|
}
|
|
@@ -107,64 +124,59 @@ var LibraryCache = class {
|
|
|
107
124
|
}
|
|
108
125
|
};
|
|
109
126
|
|
|
110
|
-
// src/tools/
|
|
127
|
+
// src/tools/get-component-details.ts
|
|
111
128
|
import { z } from "zod";
|
|
112
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.";
|
|
113
|
-
function
|
|
114
|
-
registerListTool(
|
|
115
|
-
server,
|
|
116
|
-
loadLibrary2,
|
|
117
|
-
"list_components",
|
|
118
|
-
"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. IMPORTANT: First read the user's package.json to determine their installed @getflip/swirl-components version, then pass it as the 'version' parameter.",
|
|
119
|
-
"core"
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
|
-
function registerListIcons(server, loadLibrary2) {
|
|
123
|
-
registerListTool(
|
|
124
|
-
server,
|
|
125
|
-
loadLibrary2,
|
|
126
|
-
"list_icons",
|
|
127
|
-
"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.",
|
|
128
|
-
"icon"
|
|
129
|
-
);
|
|
130
|
-
}
|
|
131
|
-
function registerListSymbols(server, loadLibrary2) {
|
|
132
|
-
registerListTool(
|
|
133
|
-
server,
|
|
134
|
-
loadLibrary2,
|
|
135
|
-
"list_symbols",
|
|
136
|
-
"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.",
|
|
137
|
-
"symbol"
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
function registerListTool(server, loadLibrary2, name, description, category) {
|
|
130
|
+
function registerGetComponentDetails(server, loadLibrary2) {
|
|
141
131
|
server.registerTool(
|
|
142
|
-
|
|
132
|
+
"get_component_details",
|
|
143
133
|
{
|
|
144
|
-
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.",
|
|
145
135
|
inputSchema: {
|
|
136
|
+
tag: z.string().describe('The component tag name, e.g. "swirl-button"'),
|
|
146
137
|
version: z.string().describe(VERSION_DESCRIPTION)
|
|
147
138
|
}
|
|
148
139
|
},
|
|
149
140
|
// @ts-ignore - MCP SDK + zod 3.x causes excessively deep type instantiation
|
|
150
|
-
async ({ version }) => {
|
|
141
|
+
async ({ tag, version }) => {
|
|
151
142
|
const lib = await loadLibrary2(version);
|
|
152
|
-
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
|
+
}
|
|
153
165
|
return {
|
|
154
|
-
content: [{ type: "text", text:
|
|
166
|
+
content: [{ type: "text", text: markdown }]
|
|
155
167
|
};
|
|
156
168
|
}
|
|
157
169
|
);
|
|
158
170
|
}
|
|
159
171
|
|
|
160
|
-
// src/tools/get-component-
|
|
172
|
+
// src/tools/get-component-source.ts
|
|
161
173
|
import { z as z2 } from "zod";
|
|
162
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.";
|
|
163
|
-
function
|
|
175
|
+
function registerGetComponentSource(server, loadLibrary2) {
|
|
164
176
|
server.registerTool(
|
|
165
|
-
"
|
|
177
|
+
"get_component_source",
|
|
166
178
|
{
|
|
167
|
-
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.",
|
|
168
180
|
inputSchema: {
|
|
169
181
|
tag: z2.string().describe('The component tag name, e.g. "swirl-button"'),
|
|
170
182
|
version: z2.string().describe(VERSION_DESCRIPTION2)
|
|
@@ -184,23 +196,34 @@ function registerGetComponentDetails(server, loadLibrary2) {
|
|
|
184
196
|
]
|
|
185
197
|
};
|
|
186
198
|
}
|
|
187
|
-
const
|
|
188
|
-
|
|
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) {
|
|
189
205
|
return {
|
|
190
206
|
content: [
|
|
191
207
|
{
|
|
192
208
|
type: "text",
|
|
193
|
-
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.`
|
|
194
210
|
}
|
|
195
211
|
]
|
|
196
212
|
};
|
|
197
213
|
}
|
|
198
214
|
return {
|
|
199
|
-
content: [{ type: "text", text:
|
|
215
|
+
content: [{ type: "text", text: sections.join("\n\n") }]
|
|
200
216
|
};
|
|
201
217
|
}
|
|
202
218
|
);
|
|
203
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
|
+
}
|
|
204
227
|
|
|
205
228
|
// src/tools/get-started.ts
|
|
206
229
|
import { z as z3 } from "zod";
|
|
@@ -209,7 +232,7 @@ function registerGetStarted(server, loadLibrary2) {
|
|
|
209
232
|
server.registerTool(
|
|
210
233
|
"get_started",
|
|
211
234
|
{
|
|
212
|
-
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.",
|
|
213
236
|
inputSchema: {
|
|
214
237
|
version: z3.string().describe(VERSION_DESCRIPTION3)
|
|
215
238
|
}
|
|
@@ -234,6 +257,56 @@ function registerGetStarted(server, loadLibrary2) {
|
|
|
234
257
|
);
|
|
235
258
|
}
|
|
236
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
|
+
|
|
237
310
|
// src/create-server.ts
|
|
238
311
|
var cache = new LibraryCache();
|
|
239
312
|
async function loadLibrary(version) {
|
|
@@ -252,27 +325,42 @@ async function loadLibrary(version) {
|
|
|
252
325
|
);
|
|
253
326
|
}
|
|
254
327
|
}
|
|
255
|
-
var INSTRUCTIONS = `
|
|
256
|
-
|
|
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.
|
|
257
334
|
|
|
258
|
-
For any task
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
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.`;
|
|
265
349
|
function createMcpServer() {
|
|
266
|
-
const server = new McpServer(
|
|
267
|
-
|
|
268
|
-
|
|
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
362
|
registerGetComponentDetails(server, loadLibrary);
|
|
363
|
+
registerGetComponentSource(server, loadLibrary);
|
|
276
364
|
registerGetStarted(server, loadLibrary);
|
|
277
365
|
return server;
|
|
278
366
|
}
|
package/dist/transports/http.js
CHANGED
package/dist/transports/stdio.js
CHANGED