@wireweave/mcp-server 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Wireweave
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,167 @@
1
+ <p align="center">
2
+ <img src="logo.svg" width="128" height="128" alt="Wireweave MCP">
3
+ </p>
4
+
5
+ <h1 align="center">@wireweave/mcp-server</h1>
6
+
7
+ <p align="center">
8
+ <a href="https://www.npmjs.com/package/@wireweave/mcp-server"><img src="https://img.shields.io/npm/v/@wireweave/mcp-server.svg" alt="npm version"></a>
9
+ <a href="https://github.com/wireweave/wireframe-lang/blob/main/packages/mcp-server/LICENSE"><img src="https://img.shields.io/npm/l/@wireweave/mcp-server.svg" alt="license"></a>
10
+ </p>
11
+
12
+ <p align="center">Model Context Protocol server for Wireweave DSL - AI-powered wireframe generation</p>
13
+
14
+ ## Overview
15
+
16
+ This MCP server enables AI assistants like Claude to generate wireframes using the Wireweave DSL. It provides **32 tools** for parsing, rendering, validating, and managing wireframes.
17
+
18
+ ## Prerequisites
19
+
20
+ You need a Wireweave API key. Get one from the [Dashboard](https://dashboard.wireweave.org).
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ npm install -g @wireweave/mcp-server
26
+ ```
27
+
28
+ Or use directly with npx:
29
+
30
+ ```bash
31
+ npx @wireweave/mcp-server
32
+ ```
33
+
34
+ ## Configuration
35
+
36
+ ### Claude Desktop
37
+
38
+ Add to your Claude Desktop config (`~/Library/Application Support/Claude/claude_desktop_config.json`):
39
+
40
+ ```json
41
+ {
42
+ "mcpServers": {
43
+ "wireweave": {
44
+ "command": "npx",
45
+ "args": ["@wireweave/mcp-server"],
46
+ "env": {
47
+ "WIREWEAVE_API_KEY": "your-api-key"
48
+ }
49
+ }
50
+ }
51
+ }
52
+ ```
53
+
54
+ ### Environment Variables
55
+
56
+ | Variable | Required | Description |
57
+ |----------|----------|-------------|
58
+ | `WIREWEAVE_API_KEY` | Yes | Your API key from Dashboard |
59
+ | `WIREWEAVE_API_URL` | No | API server URL (default: https://api.wireweave.org) |
60
+
61
+ ## Available Tools (32)
62
+
63
+ ### Core Tools (14)
64
+
65
+ | Tool | Description |
66
+ |------|-------------|
67
+ | `wireweave_parse` | Parse DSL source code into an AST |
68
+ | `wireweave_validate` | Validate DSL syntax |
69
+ | `wireweave_grammar` | Get DSL grammar documentation |
70
+ | `wireweave_guide` | **Primary LLM resource** - comprehensive language guide |
71
+ | `wireweave_patterns` | Get common layout patterns |
72
+ | `wireweave_examples` | Get code examples by category |
73
+ | `wireweave_render_html` | Render DSL to HTML and CSS |
74
+ | `wireweave_render_svg` | Render DSL to SVG format |
75
+ | `wireweave_validate_ux` | Validate UX best practices |
76
+ | `wireweave_ux_rules` | Get UX rule categories |
77
+ | `wireweave_diff` | Compare two wireframe sources |
78
+ | `wireweave_export_json` | Export to JSON format |
79
+ | `wireweave_export_figma` | Export to Figma format |
80
+ | `wireweave_analyze` | Analyze wireframe statistics |
81
+
82
+ ### Cloud Storage Tools (14)
83
+
84
+ | Tool | Description |
85
+ |------|-------------|
86
+ | `wireweave_cloud_list_projects` | List your projects |
87
+ | `wireweave_cloud_create_project` | Create a new project |
88
+ | `wireweave_cloud_update_project` | Update project details |
89
+ | `wireweave_cloud_delete_project` | Delete a project |
90
+ | `wireweave_cloud_list_wireframes` | List saved wireframes |
91
+ | `wireweave_cloud_get_wireframe` | Get a specific wireframe |
92
+ | `wireweave_cloud_save_wireframe` | Save a new wireframe |
93
+ | `wireweave_cloud_update_wireframe` | Update an existing wireframe |
94
+ | `wireweave_cloud_delete_wireframe` | Delete a wireframe |
95
+ | `wireweave_cloud_get_versions` | Get version history |
96
+ | `wireweave_cloud_restore_version` | Restore to a previous version |
97
+ | `wireweave_cloud_create_share_link` | Create a shareable link |
98
+ | `wireweave_cloud_list_shares` | List share links |
99
+ | `wireweave_gallery` | Browse public wireframe gallery |
100
+
101
+ ### Account & Billing Tools (4)
102
+
103
+ | Tool | Description |
104
+ |------|-------------|
105
+ | `wireweave_account_balance` | Check credit balance |
106
+ | `wireweave_account_subscription` | Get subscription details |
107
+ | `wireweave_account_transactions` | View transaction history |
108
+ | `wireweave_pricing` | Get pricing information |
109
+
110
+ ## Usage Examples
111
+
112
+ Once configured, you can ask Claude:
113
+
114
+ **Generate a wireframe:**
115
+ > "Create a wireframe for a login page with email and password fields"
116
+
117
+ **Validate UX:**
118
+ > "Check the UX best practices for this wireframe code"
119
+
120
+ **Save to cloud:**
121
+ > "Save this wireframe as 'Dashboard v2' in my project"
122
+
123
+ **Export:**
124
+ > "Export this wireframe to Figma format"
125
+
126
+ ## Architecture
127
+
128
+ ```
129
+ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
130
+ │ Claude/LLM │────▶│ MCP Server │────▶│ API Server │
131
+ │ │ │ (this package) │ │ │
132
+ └─────────────────┘ └─────────────────┘ └─────────────────┘
133
+ │ │
134
+ Tool definitions Execution
135
+ Request forwarding Auth & Rate Limit
136
+ Credit management
137
+ ```
138
+
139
+ The MCP server is a thin client that:
140
+ - Defines and exposes 32 tools to AI assistants
141
+ - Forwards tool calls to the Wireweave API Server
142
+ - Returns results back to the AI
143
+
144
+ All authentication, rate limiting, and business logic runs on the API Server.
145
+
146
+ ## Credit Costs
147
+
148
+ | Feature | Credits |
149
+ |---------|---------|
150
+ | Parse, Validate, Grammar, Guide, Patterns | 1 |
151
+ | Render HTML/SVG | 2 |
152
+ | UX Validation | 3 |
153
+ | Diff, Analyze | 2 |
154
+ | Export JSON/Figma | 3 |
155
+ | Cloud Save/Update | 1 |
156
+ | Create Share Link | 5 |
157
+
158
+ ## Links
159
+
160
+ - [Documentation](https://docs.wireweave.org)
161
+ - [Dashboard](https://dashboard.wireweave.org)
162
+ - [Playground](https://playground.wireweave.org)
163
+ - [GitHub](https://github.com/wireweave/wireframe-lang)
164
+
165
+ ## License
166
+
167
+ MIT
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
package/dist/index.js ADDED
@@ -0,0 +1,852 @@
1
+ #!/usr/bin/env node
2
+ #!/usr/bin/env node
3
+
4
+ // src/index.ts
5
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
6
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
7
+ import {
8
+ CallToolRequestSchema,
9
+ ListToolsRequestSchema
10
+ } from "@modelcontextprotocol/sdk/types.js";
11
+
12
+ // src/tools.ts
13
+ var tools = [
14
+ {
15
+ name: "wireweave_parse",
16
+ description: "Parse Wireweave DSL source code into an AST (Abstract Syntax Tree)",
17
+ inputSchema: {
18
+ type: "object",
19
+ properties: {
20
+ source: {
21
+ type: "string",
22
+ description: "The Wireweave DSL source code to parse"
23
+ }
24
+ },
25
+ required: ["source"]
26
+ }
27
+ },
28
+ {
29
+ name: "wireweave_validate",
30
+ description: "Validate Wireweave DSL syntax without generating output",
31
+ inputSchema: {
32
+ type: "object",
33
+ properties: {
34
+ source: {
35
+ type: "string",
36
+ description: "The Wireweave DSL source code to validate"
37
+ }
38
+ },
39
+ required: ["source"]
40
+ }
41
+ },
42
+ {
43
+ name: "wireweave_grammar",
44
+ description: "Get the Wireweave DSL grammar documentation and syntax reference",
45
+ inputSchema: {
46
+ type: "object",
47
+ properties: {},
48
+ required: []
49
+ }
50
+ },
51
+ {
52
+ name: "wireweave_guide",
53
+ description: "Get the comprehensive LLM guide for Wireweave DSL. This is the PRIMARY resource for learning the language - includes syntax, components, patterns, and best practices. Call this FIRST before generating wireframes.",
54
+ inputSchema: {
55
+ type: "object",
56
+ properties: {},
57
+ required: []
58
+ }
59
+ },
60
+ {
61
+ name: "wireweave_patterns",
62
+ description: "Get common layout patterns for wireframes including headers, sidebars, forms, cards, and more. Use these as building blocks.",
63
+ inputSchema: {
64
+ type: "object",
65
+ properties: {},
66
+ required: []
67
+ }
68
+ },
69
+ {
70
+ name: "wireweave_examples",
71
+ description: "Get Wireweave code examples. Use this to learn patterns and best practices for different UI types.",
72
+ inputSchema: {
73
+ type: "object",
74
+ properties: {
75
+ category: {
76
+ type: "string",
77
+ enum: ["all", "form", "dashboard", "mobile", "social", "commerce", "media"],
78
+ description: 'Filter examples by category. Use "all" to get all examples.',
79
+ default: "all"
80
+ },
81
+ limit: {
82
+ type: "number",
83
+ description: "Maximum number of examples to return",
84
+ default: 5
85
+ }
86
+ },
87
+ required: []
88
+ }
89
+ },
90
+ {
91
+ name: "wireweave_render_html",
92
+ description: "Render Wireweave DSL to HTML and CSS",
93
+ inputSchema: {
94
+ type: "object",
95
+ properties: {
96
+ source: {
97
+ type: "string",
98
+ description: "The Wireweave DSL source code to render"
99
+ },
100
+ theme: {
101
+ type: "string",
102
+ enum: ["light", "dark"],
103
+ description: "Color theme for rendering",
104
+ default: "light"
105
+ },
106
+ fullDocument: {
107
+ type: "boolean",
108
+ description: "Return a complete HTML document instead of fragment",
109
+ default: false
110
+ }
111
+ },
112
+ required: ["source"]
113
+ }
114
+ },
115
+ {
116
+ name: "wireweave_render_svg",
117
+ description: "Render Wireweave DSL to SVG format",
118
+ inputSchema: {
119
+ type: "object",
120
+ properties: {
121
+ source: {
122
+ type: "string",
123
+ description: "The Wireweave DSL source code to render"
124
+ },
125
+ width: {
126
+ type: "number",
127
+ description: "SVG width in pixels",
128
+ default: 1200
129
+ },
130
+ padding: {
131
+ type: "number",
132
+ description: "Padding around content",
133
+ default: 24
134
+ },
135
+ theme: {
136
+ type: "string",
137
+ enum: ["light", "dark"],
138
+ description: "Color theme for rendering",
139
+ default: "light"
140
+ }
141
+ },
142
+ required: ["source"]
143
+ }
144
+ },
145
+ {
146
+ name: "wireweave_validate_ux",
147
+ description: "Validate Wireweave DSL for UX best practices. Returns issues with severity levels and actionable recommendations.",
148
+ inputSchema: {
149
+ type: "object",
150
+ properties: {
151
+ source: {
152
+ type: "string",
153
+ description: "The Wireweave DSL source code to validate"
154
+ },
155
+ categories: {
156
+ type: "array",
157
+ items: {
158
+ type: "string",
159
+ enum: ["accessibility", "usability", "form", "touch-target", "consistency", "navigation"]
160
+ },
161
+ description: "UX rule categories to check. If not specified, all categories are checked."
162
+ },
163
+ minSeverity: {
164
+ type: "string",
165
+ enum: ["error", "warning", "info"],
166
+ description: "Minimum severity level to report",
167
+ default: "info"
168
+ },
169
+ maxIssues: {
170
+ type: "number",
171
+ description: "Maximum number of issues to return"
172
+ }
173
+ },
174
+ required: ["source"]
175
+ }
176
+ },
177
+ {
178
+ name: "wireweave_ux_rules",
179
+ description: "Get available UX rule categories and their descriptions",
180
+ inputSchema: {
181
+ type: "object",
182
+ properties: {},
183
+ required: []
184
+ }
185
+ },
186
+ {
187
+ name: "wireweave_diff",
188
+ description: "Compare two Wireweave DSL sources and return the differences between them",
189
+ inputSchema: {
190
+ type: "object",
191
+ properties: {
192
+ oldSource: {
193
+ type: "string",
194
+ description: "The original Wireweave DSL source code"
195
+ },
196
+ newSource: {
197
+ type: "string",
198
+ description: "The modified Wireweave DSL source code"
199
+ },
200
+ ignoreAttributes: {
201
+ type: "boolean",
202
+ description: "Ignore attribute changes, only compare structure",
203
+ default: false
204
+ },
205
+ ignoreOrder: {
206
+ type: "boolean",
207
+ description: "Ignore the order of children when comparing",
208
+ default: false
209
+ }
210
+ },
211
+ required: ["oldSource", "newSource"]
212
+ }
213
+ },
214
+ {
215
+ name: "wireweave_export_json",
216
+ description: "Export Wireweave DSL to JSON format for integration with other tools",
217
+ inputSchema: {
218
+ type: "object",
219
+ properties: {
220
+ source: {
221
+ type: "string",
222
+ description: "The Wireweave DSL source code to export"
223
+ },
224
+ includeLocations: {
225
+ type: "boolean",
226
+ description: "Include source location information in output",
227
+ default: false
228
+ },
229
+ prettyPrint: {
230
+ type: "boolean",
231
+ description: "Format JSON with indentation",
232
+ default: true
233
+ }
234
+ },
235
+ required: ["source"]
236
+ }
237
+ },
238
+ {
239
+ name: "wireweave_export_figma",
240
+ description: "Export Wireweave DSL to Figma-compatible format",
241
+ inputSchema: {
242
+ type: "object",
243
+ properties: {
244
+ source: {
245
+ type: "string",
246
+ description: "The Wireweave DSL source code to export"
247
+ }
248
+ },
249
+ required: ["source"]
250
+ }
251
+ },
252
+ {
253
+ name: "wireweave_analyze",
254
+ description: "Analyze Wireweave DSL for statistics and metrics including component usage, tree structure, accessibility score, and complexity",
255
+ inputSchema: {
256
+ type: "object",
257
+ properties: {
258
+ source: {
259
+ type: "string",
260
+ description: "The Wireweave DSL source code to analyze"
261
+ },
262
+ includeComponentBreakdown: {
263
+ type: "boolean",
264
+ description: "Include detailed component usage breakdown",
265
+ default: true
266
+ },
267
+ includeAccessibility: {
268
+ type: "boolean",
269
+ description: "Include accessibility analysis",
270
+ default: true
271
+ },
272
+ includeComplexity: {
273
+ type: "boolean",
274
+ description: "Include complexity metrics",
275
+ default: true
276
+ },
277
+ includeLayout: {
278
+ type: "boolean",
279
+ description: "Include layout pattern analysis",
280
+ default: true
281
+ },
282
+ includeContent: {
283
+ type: "boolean",
284
+ description: "Include content analysis",
285
+ default: true
286
+ }
287
+ },
288
+ required: ["source"]
289
+ }
290
+ },
291
+ // ============================================
292
+ // Cloud Storage Tools
293
+ // ============================================
294
+ {
295
+ name: "wireweave_cloud_list_projects",
296
+ description: "List all your Wireweave projects. Projects help organize your wireframes.",
297
+ inputSchema: {
298
+ type: "object",
299
+ properties: {
300
+ includeArchived: {
301
+ type: "boolean",
302
+ description: "Include archived projects",
303
+ default: false
304
+ }
305
+ },
306
+ required: []
307
+ }
308
+ },
309
+ {
310
+ name: "wireweave_cloud_create_project",
311
+ description: "Create a new project to organize wireframes",
312
+ inputSchema: {
313
+ type: "object",
314
+ properties: {
315
+ name: {
316
+ type: "string",
317
+ description: "Project name"
318
+ },
319
+ description: {
320
+ type: "string",
321
+ description: "Project description"
322
+ },
323
+ color: {
324
+ type: "string",
325
+ description: "Project color (hex code, e.g., #6366f1)"
326
+ }
327
+ },
328
+ required: ["name"]
329
+ }
330
+ },
331
+ {
332
+ name: "wireweave_cloud_update_project",
333
+ description: "Update an existing project",
334
+ inputSchema: {
335
+ type: "object",
336
+ properties: {
337
+ id: {
338
+ type: "string",
339
+ description: "Project ID to update"
340
+ },
341
+ name: {
342
+ type: "string",
343
+ description: "New project name"
344
+ },
345
+ description: {
346
+ type: "string",
347
+ description: "New project description"
348
+ },
349
+ color: {
350
+ type: "string",
351
+ description: "New project color (hex code)"
352
+ },
353
+ isArchived: {
354
+ type: "boolean",
355
+ description: "Archive or unarchive the project"
356
+ }
357
+ },
358
+ required: ["id"]
359
+ }
360
+ },
361
+ {
362
+ name: "wireweave_cloud_delete_project",
363
+ description: "Delete a project permanently. All wireframes in the project will be moved to the default project.",
364
+ inputSchema: {
365
+ type: "object",
366
+ properties: {
367
+ id: {
368
+ type: "string",
369
+ description: "Project ID to delete"
370
+ }
371
+ },
372
+ required: ["id"]
373
+ }
374
+ },
375
+ {
376
+ name: "wireweave_cloud_list_wireframes",
377
+ description: "List your saved wireframes. Optionally filter by project or tags.",
378
+ inputSchema: {
379
+ type: "object",
380
+ properties: {
381
+ projectId: {
382
+ type: "string",
383
+ description: "Filter by project ID"
384
+ },
385
+ tags: {
386
+ type: "array",
387
+ items: { type: "string" },
388
+ description: "Filter by tags"
389
+ },
390
+ limit: {
391
+ type: "number",
392
+ description: "Maximum number of wireframes to return",
393
+ default: 20
394
+ },
395
+ offset: {
396
+ type: "number",
397
+ description: "Offset for pagination",
398
+ default: 0
399
+ }
400
+ },
401
+ required: []
402
+ }
403
+ },
404
+ {
405
+ name: "wireweave_cloud_get_wireframe",
406
+ description: "Get a specific wireframe by ID, including its code and metadata",
407
+ inputSchema: {
408
+ type: "object",
409
+ properties: {
410
+ id: {
411
+ type: "string",
412
+ description: "Wireframe ID"
413
+ }
414
+ },
415
+ required: ["id"]
416
+ }
417
+ },
418
+ {
419
+ name: "wireweave_cloud_save_wireframe",
420
+ description: "Save a new wireframe to the cloud. Costs 1 credit.",
421
+ inputSchema: {
422
+ type: "object",
423
+ properties: {
424
+ name: {
425
+ type: "string",
426
+ description: "Wireframe name"
427
+ },
428
+ code: {
429
+ type: "string",
430
+ description: "Wireweave DSL code"
431
+ },
432
+ description: {
433
+ type: "string",
434
+ description: "Wireframe description"
435
+ },
436
+ projectId: {
437
+ type: "string",
438
+ description: "Project ID to save to (uses default project if not specified)"
439
+ },
440
+ tags: {
441
+ type: "array",
442
+ items: { type: "string" },
443
+ description: "Tags for categorization"
444
+ },
445
+ isPublic: {
446
+ type: "boolean",
447
+ description: "Make wireframe publicly visible",
448
+ default: false
449
+ }
450
+ },
451
+ required: ["name", "code"]
452
+ }
453
+ },
454
+ {
455
+ name: "wireweave_cloud_update_wireframe",
456
+ description: "Update an existing wireframe. Creates a new version automatically. Costs 1 credit.",
457
+ inputSchema: {
458
+ type: "object",
459
+ properties: {
460
+ id: {
461
+ type: "string",
462
+ description: "Wireframe ID to update"
463
+ },
464
+ name: {
465
+ type: "string",
466
+ description: "New name (optional)"
467
+ },
468
+ code: {
469
+ type: "string",
470
+ description: "New Wireweave DSL code (optional)"
471
+ },
472
+ description: {
473
+ type: "string",
474
+ description: "New description (optional)"
475
+ },
476
+ tags: {
477
+ type: "array",
478
+ items: { type: "string" },
479
+ description: "New tags (optional)"
480
+ },
481
+ isPublic: {
482
+ type: "boolean",
483
+ description: "Update public visibility (optional)"
484
+ }
485
+ },
486
+ required: ["id"]
487
+ }
488
+ },
489
+ {
490
+ name: "wireweave_cloud_delete_wireframe",
491
+ description: "Delete a wireframe permanently",
492
+ inputSchema: {
493
+ type: "object",
494
+ properties: {
495
+ id: {
496
+ type: "string",
497
+ description: "Wireframe ID to delete"
498
+ }
499
+ },
500
+ required: ["id"]
501
+ }
502
+ },
503
+ {
504
+ name: "wireweave_cloud_get_versions",
505
+ description: "Get version history of a wireframe",
506
+ inputSchema: {
507
+ type: "object",
508
+ properties: {
509
+ wireframeId: {
510
+ type: "string",
511
+ description: "Wireframe ID"
512
+ }
513
+ },
514
+ required: ["wireframeId"]
515
+ }
516
+ },
517
+ {
518
+ name: "wireweave_cloud_restore_version",
519
+ description: "Restore a wireframe to a previous version. Costs 1 credit.",
520
+ inputSchema: {
521
+ type: "object",
522
+ properties: {
523
+ wireframeId: {
524
+ type: "string",
525
+ description: "Wireframe ID"
526
+ },
527
+ version: {
528
+ type: "number",
529
+ description: "Version number to restore"
530
+ }
531
+ },
532
+ required: ["wireframeId", "version"]
533
+ }
534
+ },
535
+ {
536
+ name: "wireweave_cloud_create_share_link",
537
+ description: "Create a shareable link for a wireframe. Costs 5 credits.",
538
+ inputSchema: {
539
+ type: "object",
540
+ properties: {
541
+ wireframeId: {
542
+ type: "string",
543
+ description: "Wireframe ID to share"
544
+ },
545
+ title: {
546
+ type: "string",
547
+ description: "Custom title for the shared view"
548
+ },
549
+ allowCopy: {
550
+ type: "boolean",
551
+ description: "Allow viewers to copy the code",
552
+ default: false
553
+ },
554
+ password: {
555
+ type: "string",
556
+ description: "Password protection (optional)"
557
+ },
558
+ expiresInDays: {
559
+ type: "number",
560
+ description: "Link expiration in days (optional, null = never)"
561
+ }
562
+ },
563
+ required: ["wireframeId"]
564
+ }
565
+ },
566
+ {
567
+ name: "wireweave_cloud_list_shares",
568
+ description: "List share links for a wireframe",
569
+ inputSchema: {
570
+ type: "object",
571
+ properties: {
572
+ wireframeId: {
573
+ type: "string",
574
+ description: "Wireframe ID"
575
+ }
576
+ },
577
+ required: ["wireframeId"]
578
+ }
579
+ },
580
+ // ============================================
581
+ // Account & Billing Tools
582
+ // ============================================
583
+ {
584
+ name: "wireweave_account_balance",
585
+ description: "Check your current credit balance and subscription status",
586
+ inputSchema: {
587
+ type: "object",
588
+ properties: {},
589
+ required: []
590
+ }
591
+ },
592
+ {
593
+ name: "wireweave_account_subscription",
594
+ description: "Get detailed subscription information including plan features",
595
+ inputSchema: {
596
+ type: "object",
597
+ properties: {},
598
+ required: []
599
+ }
600
+ },
601
+ {
602
+ name: "wireweave_account_transactions",
603
+ description: "View your credit transaction history",
604
+ inputSchema: {
605
+ type: "object",
606
+ properties: {
607
+ limit: {
608
+ type: "number",
609
+ description: "Number of transactions to return",
610
+ default: 20
611
+ },
612
+ type: {
613
+ type: "string",
614
+ enum: ["purchase", "subscription", "usage", "refund", "bonus", "admin"],
615
+ description: "Filter by transaction type"
616
+ }
617
+ },
618
+ required: []
619
+ }
620
+ },
621
+ {
622
+ name: "wireweave_pricing",
623
+ description: "Get current pricing information for plans, credit packs, and feature costs",
624
+ inputSchema: {
625
+ type: "object",
626
+ properties: {},
627
+ required: []
628
+ }
629
+ },
630
+ // ============================================
631
+ // Public Gallery
632
+ // ============================================
633
+ {
634
+ name: "wireweave_gallery",
635
+ description: "Browse public wireframe gallery for inspiration",
636
+ inputSchema: {
637
+ type: "object",
638
+ properties: {
639
+ tags: {
640
+ type: "array",
641
+ items: { type: "string" },
642
+ description: "Filter by tags"
643
+ },
644
+ limit: {
645
+ type: "number",
646
+ description: "Number of wireframes to return",
647
+ default: 20
648
+ }
649
+ },
650
+ required: []
651
+ }
652
+ }
653
+ ];
654
+ var toolEndpoints = {
655
+ // Core tools
656
+ wireweave_parse: { method: "POST", path: "/tools/parse" },
657
+ wireweave_validate: { method: "POST", path: "/tools/validate" },
658
+ wireweave_grammar: { method: "GET", path: "/tools/grammar" },
659
+ wireweave_guide: { method: "GET", path: "/tools/guide" },
660
+ wireweave_patterns: { method: "GET", path: "/tools/patterns" },
661
+ wireweave_examples: { method: "GET", path: "/tools/examples" },
662
+ wireweave_render_html: { method: "POST", path: "/tools/render/html" },
663
+ wireweave_render_svg: { method: "POST", path: "/tools/render/svg" },
664
+ wireweave_validate_ux: { method: "POST", path: "/tools/validate/ux" },
665
+ wireweave_ux_rules: { method: "GET", path: "/tools/ux-rules" },
666
+ wireweave_diff: { method: "POST", path: "/tools/diff" },
667
+ wireweave_export_json: { method: "POST", path: "/tools/export/json" },
668
+ wireweave_export_figma: { method: "POST", path: "/tools/export/figma" },
669
+ wireweave_analyze: { method: "POST", path: "/tools/analyze" },
670
+ // Cloud storage tools
671
+ wireweave_cloud_list_projects: { method: "GET", path: "/cloud/projects" },
672
+ wireweave_cloud_create_project: { method: "POST", path: "/cloud/projects" },
673
+ wireweave_cloud_update_project: { method: "PATCH", path: "/cloud/projects/:id", pathParams: ["id"] },
674
+ wireweave_cloud_delete_project: { method: "DELETE", path: "/cloud/projects/:id", pathParams: ["id"] },
675
+ wireweave_cloud_list_wireframes: { method: "GET", path: "/cloud/wireframes" },
676
+ wireweave_cloud_get_wireframe: { method: "GET", path: "/cloud/wireframes/:id", pathParams: ["id"] },
677
+ wireweave_cloud_save_wireframe: { method: "POST", path: "/cloud/wireframes" },
678
+ wireweave_cloud_update_wireframe: { method: "PATCH", path: "/cloud/wireframes/:id", pathParams: ["id"] },
679
+ wireweave_cloud_delete_wireframe: { method: "DELETE", path: "/cloud/wireframes/:id", pathParams: ["id"] },
680
+ wireweave_cloud_get_versions: { method: "GET", path: "/cloud/wireframes/:wireframeId/versions", pathParams: ["wireframeId"] },
681
+ wireweave_cloud_restore_version: { method: "POST", path: "/cloud/wireframes/:wireframeId/versions/:version/restore", pathParams: ["wireframeId", "version"] },
682
+ wireweave_cloud_create_share_link: { method: "POST", path: "/cloud/wireframes/:wireframeId/shares", pathParams: ["wireframeId"] },
683
+ wireweave_cloud_list_shares: { method: "GET", path: "/cloud/wireframes/:wireframeId/shares", pathParams: ["wireframeId"] },
684
+ // Account & billing tools
685
+ wireweave_account_balance: { method: "GET", path: "/billing/balance" },
686
+ wireweave_account_subscription: { method: "GET", path: "/billing/subscription" },
687
+ wireweave_account_transactions: { method: "GET", path: "/billing/transactions" },
688
+ wireweave_pricing: { method: "GET", path: "/billing/pricing" },
689
+ // Public gallery
690
+ wireweave_gallery: { method: "GET", path: "/cloud/gallery" }
691
+ };
692
+
693
+ // src/api.ts
694
+ function buildRequest(config, endpoint, args) {
695
+ let path = endpoint.path;
696
+ const body = { ...args };
697
+ if (endpoint.pathParams && args) {
698
+ for (const param of endpoint.pathParams) {
699
+ const value = args[param];
700
+ if (value !== void 0) {
701
+ path = path.replace(`:${param}`, String(value));
702
+ delete body[param];
703
+ }
704
+ }
705
+ }
706
+ let url = `${config.apiUrl}${path}`;
707
+ const options = {
708
+ method: endpoint.method,
709
+ headers: {
710
+ "Content-Type": "application/json",
711
+ "x-api-key": config.apiKey
712
+ }
713
+ };
714
+ if (["POST", "PATCH", "PUT"].includes(endpoint.method) && Object.keys(body).length > 0) {
715
+ options.body = JSON.stringify(body);
716
+ } else if (endpoint.method === "GET" && Object.keys(body).length > 0) {
717
+ const params = new URLSearchParams();
718
+ for (const [key, value] of Object.entries(body)) {
719
+ if (value !== void 0 && value !== null) {
720
+ if (Array.isArray(value)) {
721
+ params.append(key, value.join(","));
722
+ } else {
723
+ params.append(key, String(value));
724
+ }
725
+ }
726
+ }
727
+ url = `${url}?${params.toString()}`;
728
+ }
729
+ return { url, options, bodyForGet: body };
730
+ }
731
+ function parseErrorMessage(status, error) {
732
+ if (status === 401) return "Invalid API key. Get one at https://dashboard.wireweave.org";
733
+ if (status === 402) return `Insufficient credits. ${error.message || "Please add more credits."}`;
734
+ if (status === 403) return "Access denied. Upgrade your plan for this feature.";
735
+ if (status === 429) return "Rate limit exceeded. Please wait and try again.";
736
+ if (status >= 500) return "Service temporarily unavailable";
737
+ return error.error || error.message || "Request failed";
738
+ }
739
+ function extractCreditInfo(headers) {
740
+ return {
741
+ balance: headers.get("X-Credits-Balance") ? parseInt(headers.get("X-Credits-Balance"), 10) : void 0,
742
+ monthlyRemaining: headers.get("X-Credits-Monthly-Remaining") ? parseInt(headers.get("X-Credits-Monthly-Remaining"), 10) : void 0,
743
+ totalAvailable: headers.get("X-Credits-Total-Available") ? parseInt(headers.get("X-Credits-Total-Available"), 10) : void 0
744
+ };
745
+ }
746
+ async function callApi(config, endpoint, args, fetchFn = fetch) {
747
+ if (!config.apiKey) {
748
+ throw new Error("WIREWEAVE_API_KEY environment variable is required");
749
+ }
750
+ const { url, options } = buildRequest(config, endpoint, args);
751
+ const response = await fetchFn(url, options);
752
+ const creditInfo = extractCreditInfo(response.headers);
753
+ if (!response.ok) {
754
+ const error = await response.json().catch(() => ({ error: "Request failed" }));
755
+ const userMessage = parseErrorMessage(response.status, error);
756
+ throw new Error(userMessage);
757
+ }
758
+ const result = await response.json();
759
+ if (creditInfo.balance !== void 0 || creditInfo.totalAvailable !== void 0) {
760
+ return {
761
+ ...result,
762
+ _credits: creditInfo
763
+ };
764
+ }
765
+ return result;
766
+ }
767
+
768
+ // src/index.ts
769
+ var API_URL = process.env.WIREWEAVE_API_URL || "https://api.wireweave.org";
770
+ var API_KEY = process.env.WIREWEAVE_API_KEY || "";
771
+ var apiConfig = {
772
+ apiUrl: API_URL,
773
+ apiKey: API_KEY
774
+ };
775
+ function log(message, level = "info") {
776
+ const prefix = level === "error" ? "\u274C" : level === "warn" ? "\u26A0\uFE0F" : "\u2713";
777
+ console.error(`[Wireweave] ${prefix} ${message}`);
778
+ }
779
+ var server = new Server(
780
+ {
781
+ name: "wireweave-mcp",
782
+ version: "1.0.0"
783
+ },
784
+ {
785
+ capabilities: {
786
+ tools: {}
787
+ }
788
+ }
789
+ );
790
+ server.setRequestHandler(ListToolsRequestSchema, async () => {
791
+ return { tools };
792
+ });
793
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
794
+ const { name, arguments: args } = request.params;
795
+ const endpoint = toolEndpoints[name];
796
+ if (!endpoint) {
797
+ return {
798
+ content: [
799
+ {
800
+ type: "text",
801
+ text: JSON.stringify({
802
+ error: `Unknown tool: ${name}`,
803
+ availableTools: Object.keys(toolEndpoints)
804
+ }, null, 2)
805
+ }
806
+ ],
807
+ isError: true
808
+ };
809
+ }
810
+ try {
811
+ const result = await callApi(apiConfig, endpoint, args);
812
+ return {
813
+ content: [
814
+ {
815
+ type: "text",
816
+ text: JSON.stringify(result, null, 2)
817
+ }
818
+ ]
819
+ };
820
+ } catch (error) {
821
+ return {
822
+ content: [
823
+ {
824
+ type: "text",
825
+ text: JSON.stringify({
826
+ error: error instanceof Error ? error.message : "Unknown error"
827
+ }, null, 2)
828
+ }
829
+ ],
830
+ isError: true
831
+ };
832
+ }
833
+ });
834
+ server.onerror = (error) => {
835
+ log("An error occurred", "error");
836
+ };
837
+ process.on("SIGINT", async () => {
838
+ await server.close();
839
+ process.exit(0);
840
+ });
841
+ async function main() {
842
+ const transport = new StdioServerTransport();
843
+ await server.connect(transport);
844
+ log("MCP server started");
845
+ if (!API_KEY) {
846
+ log("API key not configured. Get one at https://dashboard.wireweave.org", "warn");
847
+ }
848
+ }
849
+ main().catch(() => {
850
+ log("Failed to start server", "error");
851
+ process.exit(1);
852
+ });
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@wireweave/mcp-server",
3
+ "version": "1.0.0",
4
+ "description": "MCP server for Wireweave DSL - Thin client for API Server",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "bin": {
9
+ "wireweave-mcp": "./dist/index.js"
10
+ },
11
+ "scripts": {
12
+ "build": "tsup",
13
+ "dev": "tsup --watch",
14
+ "start": "node dist/index.js",
15
+ "typecheck": "tsc --noEmit",
16
+ "test": "vitest run"
17
+ },
18
+ "dependencies": {
19
+ "@modelcontextprotocol/sdk": "^1.0.0"
20
+ },
21
+ "devDependencies": {
22
+ "@types/node": "^22.0.0",
23
+ "tsup": "^8.3.5",
24
+ "typescript": "^5.7.2",
25
+ "vitest": "^2.1.8"
26
+ },
27
+ "files": [
28
+ "dist"
29
+ ],
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git+https://github.com/wireweave/wireframe-lang.git",
33
+ "directory": "packages/mcp-server"
34
+ },
35
+ "homepage": "https://docs.wireweave.org",
36
+ "bugs": {
37
+ "url": "https://github.com/wireweave/wireframe-lang/issues"
38
+ },
39
+ "keywords": [
40
+ "wireweave",
41
+ "mcp",
42
+ "model-context-protocol",
43
+ "wireframe",
44
+ "dsl",
45
+ "ai",
46
+ "claude",
47
+ "llm",
48
+ "tools",
49
+ "ui-design",
50
+ "prototyping"
51
+ ],
52
+ "license": "MIT"
53
+ }