@getflip/swirl-ai 0.475.0 → 0.476.0-beta-20260409140533
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 +2 -55
- package/package.json +3 -27
- package/dist/mcp/mcp.js +0 -206
package/README.md
CHANGED
|
@@ -1,61 +1,8 @@
|
|
|
1
1
|
# @getflip/swirl-ai
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
agents can discover and use Swirl components interactively, or consume the
|
|
5
|
-
**build-time artifacts** directly.
|
|
3
|
+
Build-time artifacts for AI agents integrating with the Swirl Design System.
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
The package ships a Model Context Protocol server with 6 tools:
|
|
10
|
-
|
|
11
|
-
| Tool | Description |
|
|
12
|
-
| ------------------------- | ------------------------------------------------------------- |
|
|
13
|
-
| `get_started` | Installation and setup guide (Web Components, Angular, React) |
|
|
14
|
-
| `list_components` | List all UI components (buttons, modals, forms, etc.) |
|
|
15
|
-
| `list_icons` | List all icon components (`swirl-icon-*`) |
|
|
16
|
-
| `list_symbols` | List all symbol components (`swirl-symbol-*`) |
|
|
17
|
-
| `list_emojis` | List all emoji components (`swirl-emoji-*`) |
|
|
18
|
-
| `get_component_details` | Full docs for a component (props, events, slots, examples) |
|
|
19
|
-
|
|
20
|
-
### Usage
|
|
21
|
-
|
|
22
|
-
```jsonc
|
|
23
|
-
{
|
|
24
|
-
"mcpServers": {
|
|
25
|
-
"swirl-ai": {
|
|
26
|
-
"command": "npx",
|
|
27
|
-
"args": ["-y", "@getflip/swirl-ai"]
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
For local development, point to the built file directly:
|
|
34
|
-
|
|
35
|
-
```jsonc
|
|
36
|
-
{
|
|
37
|
-
"mcpServers": {
|
|
38
|
-
"swirl-ai": {
|
|
39
|
-
"command": "node",
|
|
40
|
-
"args": ["<path-to-repo>/packages/swirl-ai/dist/mcp/mcp.js"]
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
### Local testing
|
|
47
|
-
|
|
48
|
-
Use the MCP inspector to call tools interactively in a web UI:
|
|
49
|
-
|
|
50
|
-
```sh
|
|
51
|
-
npx @modelcontextprotocol/inspector node dist/mcp/mcp.js
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
Or during development (no rebuild needed after changes):
|
|
55
|
-
|
|
56
|
-
```sh
|
|
57
|
-
npx @modelcontextprotocol/inspector tsx scripts/mcp.ts
|
|
58
|
-
```
|
|
5
|
+
> **Looking for the MCP server?** See [`@getflip/swirl-mcp`](../swirl-mcp/).
|
|
59
6
|
|
|
60
7
|
## Artifacts
|
|
61
8
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getflip/swirl-ai",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.476.0-beta-20260409140533",
|
|
4
4
|
"description": "Swirl Design System AI package with artifacts for AI agents",
|
|
5
5
|
"author": "Flip GmbH",
|
|
6
6
|
"repository": {
|
|
@@ -12,9 +12,6 @@
|
|
|
12
12
|
"url": "https://github.com/getflip/swirl/issues"
|
|
13
13
|
},
|
|
14
14
|
"type": "module",
|
|
15
|
-
"bin": {
|
|
16
|
-
"swirl-ai": "./dist/mcp/mcp.js"
|
|
17
|
-
},
|
|
18
15
|
"files": [
|
|
19
16
|
"dist",
|
|
20
17
|
"README.md"
|
|
@@ -24,34 +21,13 @@
|
|
|
24
21
|
"./agent-index": "./dist/agent/components-index.json"
|
|
25
22
|
},
|
|
26
23
|
"scripts": {
|
|
27
|
-
"build": "tsx scripts/build.ts
|
|
24
|
+
"build": "tsx scripts/build.ts",
|
|
28
25
|
"build:artifacts": "tsx scripts/build.ts",
|
|
29
|
-
"build:mcp": "tsup",
|
|
30
|
-
"dev": "tsx scripts/mcp.ts",
|
|
31
26
|
"lint": "tsc --noEmit"
|
|
32
27
|
},
|
|
33
|
-
"tsup": {
|
|
34
|
-
"entry": [
|
|
35
|
-
"scripts/mcp.ts"
|
|
36
|
-
],
|
|
37
|
-
"format": [
|
|
38
|
-
"esm"
|
|
39
|
-
],
|
|
40
|
-
"target": "node18",
|
|
41
|
-
"outDir": "dist/mcp",
|
|
42
|
-
"clean": false,
|
|
43
|
-
"banner": {
|
|
44
|
-
"js": "#!/usr/bin/env node"
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
"dependencies": {
|
|
48
|
-
"@modelcontextprotocol/sdk": "1.27.1",
|
|
49
|
-
"zod": "3.24.0"
|
|
50
|
-
},
|
|
51
28
|
"devDependencies": {
|
|
52
|
-
"@getflip/swirl-components": "0.
|
|
29
|
+
"@getflip/swirl-components": "0.476.0-beta-20260409140533",
|
|
53
30
|
"@types/node": "25.3.0",
|
|
54
|
-
"tsup": "^8.0.0",
|
|
55
31
|
"tsx": "^4.7.0",
|
|
56
32
|
"typescript": "5.9.3"
|
|
57
33
|
}
|
package/dist/mcp/mcp.js
DELETED
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// scripts/mcp.ts
|
|
4
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
5
|
-
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
6
|
-
|
|
7
|
-
// lib/mcp/data-loader.ts
|
|
8
|
-
import { readFileSync } from "fs";
|
|
9
|
-
import { dirname, join } from "path";
|
|
10
|
-
import { fileURLToPath } from "url";
|
|
11
|
-
var ArtifactLibrary = class {
|
|
12
|
-
catalog;
|
|
13
|
-
tagIndex;
|
|
14
|
-
agentDir;
|
|
15
|
-
constructor(agentDir) {
|
|
16
|
-
this.agentDir = agentDir;
|
|
17
|
-
const catalogPath = join(agentDir, "components-index.json");
|
|
18
|
-
const raw = readFileSync(catalogPath, "utf-8");
|
|
19
|
-
const json = JSON.parse(raw);
|
|
20
|
-
this.catalog = json.components;
|
|
21
|
-
this.tagIndex = /* @__PURE__ */ new Map();
|
|
22
|
-
for (const entry of this.catalog) {
|
|
23
|
-
this.tagIndex.set(entry.tag, entry);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
getByCategory(category) {
|
|
27
|
-
return this.catalog.filter((c) => categorize(c.tag) === category);
|
|
28
|
-
}
|
|
29
|
-
getByTag(tag) {
|
|
30
|
-
return this.tagIndex.get(tag);
|
|
31
|
-
}
|
|
32
|
-
getComponentMarkdown(tag) {
|
|
33
|
-
const mdPath = join(this.agentDir, "components", `${tag}.md`);
|
|
34
|
-
try {
|
|
35
|
-
return readFileSync(mdPath, "utf-8");
|
|
36
|
-
} catch {
|
|
37
|
-
return void 0;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
getGuide(name) {
|
|
41
|
-
const mdPath = join(this.agentDir, `${name}.md`);
|
|
42
|
-
try {
|
|
43
|
-
return readFileSync(mdPath, "utf-8");
|
|
44
|
-
} catch {
|
|
45
|
-
return void 0;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
get totalCount() {
|
|
49
|
-
return this.catalog.length;
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
function resolveAgentDir() {
|
|
53
|
-
const thisFile = fileURLToPath(import.meta.url);
|
|
54
|
-
const mcpDir = dirname(thisFile);
|
|
55
|
-
return join(mcpDir, "..", "..", "dist", "agent");
|
|
56
|
-
}
|
|
57
|
-
function categorize(tag) {
|
|
58
|
-
if (tag.startsWith("swirl-icon-")) {
|
|
59
|
-
return "icon";
|
|
60
|
-
}
|
|
61
|
-
if (tag.startsWith("swirl-symbol-")) {
|
|
62
|
-
return "symbol";
|
|
63
|
-
}
|
|
64
|
-
if (tag.startsWith("swirl-emoji-")) {
|
|
65
|
-
return "emoji";
|
|
66
|
-
}
|
|
67
|
-
return "core";
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// lib/mcp/tools/list-components.ts
|
|
71
|
-
function registerListComponents(server, lib) {
|
|
72
|
-
registerListTool(
|
|
73
|
-
server,
|
|
74
|
-
lib,
|
|
75
|
-
"list_components",
|
|
76
|
-
"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.",
|
|
77
|
-
"core"
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
function registerListIcons(server, lib) {
|
|
81
|
-
registerListTool(
|
|
82
|
-
server,
|
|
83
|
-
lib,
|
|
84
|
-
"list_icons",
|
|
85
|
-
"List all Swirl icon components (swirl-icon-*). Use get_component_details for full details on a specific icon.",
|
|
86
|
-
"icon"
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
function registerListSymbols(server, lib) {
|
|
90
|
-
registerListTool(
|
|
91
|
-
server,
|
|
92
|
-
lib,
|
|
93
|
-
"list_symbols",
|
|
94
|
-
"List all Swirl symbol components (swirl-symbol-*). Use get_component_details for full details on a specific symbol.",
|
|
95
|
-
"symbol"
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
function registerListEmojis(server, lib) {
|
|
99
|
-
registerListTool(
|
|
100
|
-
server,
|
|
101
|
-
lib,
|
|
102
|
-
"list_emojis",
|
|
103
|
-
"List all Swirl emoji components (swirl-emoji-*). Use get_component_details for full details on a specific emoji.",
|
|
104
|
-
"emoji"
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
function registerListTool(server, lib, name, description, category) {
|
|
108
|
-
server.registerTool(name, { description }, async () => {
|
|
109
|
-
const components = lib.getByCategory(category);
|
|
110
|
-
return {
|
|
111
|
-
content: [{ type: "text", text: JSON.stringify(components) }]
|
|
112
|
-
};
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// lib/mcp/tools/get-component-details.ts
|
|
117
|
-
import { z } from "zod";
|
|
118
|
-
function registerGetComponentDetails(server, lib) {
|
|
119
|
-
server.registerTool(
|
|
120
|
-
"get_component_details",
|
|
121
|
-
{
|
|
122
|
-
description: "Get full details for a Swirl component including all props with types and defaults, events, methods, slots, accessibility info, and usage examples.",
|
|
123
|
-
inputSchema: {
|
|
124
|
-
tag: z.string().describe('The component tag name, e.g. "swirl-button"')
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
// @ts-expect-error - MCP SDK + zod 3.x causes excessively deep type instantiation
|
|
128
|
-
async ({ tag }) => {
|
|
129
|
-
const entry = lib.getByTag(tag);
|
|
130
|
-
if (!entry) {
|
|
131
|
-
return {
|
|
132
|
-
content: [
|
|
133
|
-
{
|
|
134
|
-
type: "text",
|
|
135
|
-
text: `Component "${tag}" not found. Use list_components to see available components.`
|
|
136
|
-
}
|
|
137
|
-
]
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
const markdown = lib.getComponentMarkdown(tag);
|
|
141
|
-
if (!markdown) {
|
|
142
|
-
return {
|
|
143
|
-
content: [
|
|
144
|
-
{
|
|
145
|
-
type: "text",
|
|
146
|
-
text: `Component "${tag}" exists but no detailed documentation was found.`
|
|
147
|
-
}
|
|
148
|
-
]
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
return {
|
|
152
|
-
content: [{ type: "text", text: markdown }]
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// lib/mcp/tools/get-started.ts
|
|
159
|
-
function registerGetStarted(server, lib) {
|
|
160
|
-
server.registerTool(
|
|
161
|
-
"get_started",
|
|
162
|
-
{
|
|
163
|
-
description: "Get installation and setup instructions for Swirl components. Covers Web Components, Angular, and React wrapper libraries."
|
|
164
|
-
},
|
|
165
|
-
async () => {
|
|
166
|
-
const markdown = lib.getGuide("get-started");
|
|
167
|
-
if (!markdown) {
|
|
168
|
-
return {
|
|
169
|
-
content: [
|
|
170
|
-
{
|
|
171
|
-
type: "text",
|
|
172
|
-
text: "Getting started guide not found."
|
|
173
|
-
}
|
|
174
|
-
]
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
return {
|
|
178
|
-
content: [{ type: "text", text: markdown }]
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
// scripts/mcp.ts
|
|
185
|
-
async function main() {
|
|
186
|
-
const agentDir = resolveAgentDir();
|
|
187
|
-
console.error(`Loading artifacts from: ${agentDir}`);
|
|
188
|
-
const lib = new ArtifactLibrary(agentDir);
|
|
189
|
-
console.error(`Loaded ${lib.totalCount} components`);
|
|
190
|
-
const server = new McpServer({
|
|
191
|
-
name: "swirl-ai",
|
|
192
|
-
version: "0.1.0"
|
|
193
|
-
});
|
|
194
|
-
registerListComponents(server, lib);
|
|
195
|
-
registerListIcons(server, lib);
|
|
196
|
-
registerListSymbols(server, lib);
|
|
197
|
-
registerListEmojis(server, lib);
|
|
198
|
-
registerGetComponentDetails(server, lib);
|
|
199
|
-
registerGetStarted(server, lib);
|
|
200
|
-
await server.connect(new StdioServerTransport());
|
|
201
|
-
console.error("Swirl AI MCP Server running on stdio");
|
|
202
|
-
}
|
|
203
|
-
main().catch((error) => {
|
|
204
|
-
console.error("Fatal error:", error);
|
|
205
|
-
process.exit(1);
|
|
206
|
-
});
|