@hiabhee/archdraw-mcp-server 1.0.4 → 1.0.5
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/dist/index.js +5 -813
- package/dist/index.js.map +1 -1
- package/dist/lib/checkpoints.d.ts +4 -0
- package/dist/lib/checkpoints.d.ts.map +1 -1
- package/dist/lib/checkpoints.js +14 -1
- package/dist/lib/checkpoints.js.map +1 -1
- package/dist/lib/diagram-state.d.ts +1 -0
- package/dist/lib/diagram-state.d.ts.map +1 -1
- package/dist/lib/diagram-state.js +5 -2
- package/dist/lib/diagram-state.js.map +1 -1
- package/dist/lib/http.d.ts +12 -0
- package/dist/lib/http.d.ts.map +1 -1
- package/dist/lib/http.js +11 -1
- package/dist/lib/http.js.map +1 -1
- package/dist/server.d.ts +32 -34
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +739 -141
- package/dist/server.js.map +1 -1
- package/dist/tools/apply-template.js +2 -2
- package/dist/tools/apply-template.js.map +1 -1
- package/dist/tools/export-diagram.d.ts +1 -1
- package/dist/tools/export-diagram.d.ts.map +1 -1
- package/dist/tools/export-diagram.js +6 -6
- package/dist/tools/export-diagram.js.map +1 -1
- package/dist/tools/fix-layout.js +2 -2
- package/dist/tools/fix-layout.js.map +1 -1
- package/dist/tools/generate-diagram.js +2 -2
- package/dist/tools/generate-diagram.js.map +1 -1
- package/dist/tools/update-diagram.js +2 -2
- package/dist/tools/update-diagram.js.map +1 -1
- package/package.json +12 -3
- package/dist/lib/__tests__/constants.test.d.ts +0 -2
- package/dist/lib/__tests__/constants.test.d.ts.map +0 -1
- package/dist/lib/__tests__/constants.test.js +0 -47
- package/dist/lib/__tests__/constants.test.js.map +0 -1
- package/dist/lib/__tests__/diagram-state.test.d.ts +0 -2
- package/dist/lib/__tests__/diagram-state.test.d.ts.map +0 -1
- package/dist/lib/__tests__/diagram-state.test.js +0 -82
- package/dist/lib/__tests__/diagram-state.test.js.map +0 -1
- package/dist/lib/__tests__/elk-runner.test.d.ts +0 -2
- package/dist/lib/__tests__/elk-runner.test.d.ts.map +0 -1
- package/dist/lib/__tests__/elk-runner.test.js +0 -87
- package/dist/lib/__tests__/elk-runner.test.js.map +0 -1
- package/dist/lib/elk-runner.d.ts +0 -29
- package/dist/lib/elk-runner.d.ts.map +0 -1
- package/dist/lib/elk-runner.js +0 -532
- package/dist/lib/elk-runner.js.map +0 -1
- package/dist/lib/prompt-builder.d.ts +0 -14
- package/dist/lib/prompt-builder.d.ts.map +0 -1
- package/dist/lib/prompt-builder.js +0 -133
- package/dist/lib/prompt-builder.js.map +0 -1
- package/dist/tools/__tests__/export-diagram.test.d.ts +0 -2
- package/dist/tools/__tests__/export-diagram.test.d.ts.map +0 -1
- package/dist/tools/__tests__/export-diagram.test.js +0 -40
- package/dist/tools/__tests__/export-diagram.test.js.map +0 -1
- package/dist/tools/__tests__/preview-links.test.d.ts +0 -2
- package/dist/tools/__tests__/preview-links.test.d.ts.map +0 -1
- package/dist/tools/__tests__/preview-links.test.js +0 -74
- package/dist/tools/__tests__/preview-links.test.js.map +0 -1
- package/dist/tools/__tests__/update-diagram.test.d.ts +0 -2
- package/dist/tools/__tests__/update-diagram.test.d.ts.map +0 -1
- package/dist/tools/__tests__/update-diagram.test.js +0 -98
- package/dist/tools/__tests__/update-diagram.test.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,816 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { randomUUID } from 'node:crypto';
|
|
3
|
-
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
4
2
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import { getReadMe } from './tools/read-me.js';
|
|
11
|
-
import { getDiagramState } from './lib/diagram-state.js';
|
|
12
|
-
import { validateDiagram } from './tools/validate-diagram.js';
|
|
13
|
-
import { updateDiagram } from './tools/update-diagram.js';
|
|
14
|
-
import { saveCheckpoint } from './tools/save-checkpoint.js';
|
|
15
|
-
import { loadCheckpoint } from './tools/load-checkpoint.js';
|
|
16
|
-
import { exportDiagram } from './tools/export-diagram.js';
|
|
17
|
-
import { GenerateDiagramInputSchema, FixLayoutInputSchema, ListNodeTypesInputSchema, ApplyTemplateInputSchema, UpdateDiagramInputSchema, SaveCheckpointInputSchema, LoadCheckpointInputSchema, ExportDiagramInputSchema, } from './lib/schema.js';
|
|
18
|
-
import { DIAGRAM_WIDGET_HTML, DIAGRAM_WIDGET_URI } from './ui/diagram-widget.js';
|
|
19
|
-
import { formatPreviewLinks } from './lib/preview-links.js';
|
|
20
|
-
const TOOLS = [
|
|
21
|
-
{
|
|
22
|
-
name: 'generate_diagram',
|
|
23
|
-
title: 'Generate an ArchDraw diagram',
|
|
24
|
-
description: `Generate a rich architecture diagram with groups, labeled edges, and visual hierarchy. Compatible chat clients display the result as an inline interactive preview; text-only clients receive a concise summary and the ArchDraw site link.
|
|
25
|
-
|
|
26
|
-
**ALWAYS show the returned preview link (shareUrl) and edit link (diagramUrl) to the user in your reply** — the diagram is visual and the link is the only way users of text-only clients can see it. Links are created by default in the same response (no extra call needed); they are unguessable, view-by-link, and expire after 7 days.
|
|
27
|
-
|
|
28
|
-
**INPUT MODES — choose ONE**:
|
|
29
|
-
|
|
30
|
-
**Mode 1 (RECOMMENDED): Mermaid code** — pass a \`graph LR\` / \`graph TD\` diagram in \`mermaid\`.
|
|
31
|
-
This runs the same parser + layout engine the web editor uses, so output is guaranteed to match the product.
|
|
32
|
-
Example:
|
|
33
|
-
graph LR
|
|
34
|
-
subgraph client["Client Tier"]
|
|
35
|
-
Web[Web App]
|
|
36
|
-
Mobile[Mobile App]
|
|
37
|
-
end
|
|
38
|
-
subgraph edge["API Gateway Tier"]
|
|
39
|
-
GW[API Gateway]
|
|
40
|
-
end
|
|
41
|
-
subgraph data["Data Tier"]
|
|
42
|
-
DB[("PostgreSQL")]
|
|
43
|
-
end
|
|
44
|
-
Web --> GW
|
|
45
|
-
Mobile --> GW
|
|
46
|
-
GW --> DB
|
|
47
|
-
Use \`direction\` to pick LR (default) or TD. Any graph \`graph TD\` implies top-down.
|
|
48
|
-
The web parser runs Mermaid → React Flow → Dagre layout, so positions come out clean automatically.
|
|
49
|
-
Optional directives like \`%% archdraw-shape: {"id":"<id>","shape":"shield"}\` are supported for non-native shapes.
|
|
50
|
-
|
|
51
|
-
**Mode 2 (compatibility): Structured JSON** — pass \`nodes\` and \`edges\` arrays (schemas below). ArchDraw converts this input to Mermaid and uses the same editor pipeline.
|
|
52
|
-
|
|
53
|
-
**ALWAYS ALSO PASS** (when you have them):
|
|
54
|
-
- \`userPrompt\`: the user's request verbatim — node subtitles must reflect any tech stack they named.
|
|
55
|
-
- \`techStack\`: explicit list of technologies (["Next.js", "PostgreSQL 15", "Redis"]).
|
|
56
|
-
- \`customFeatures\`: features the user explicitly asked for.
|
|
57
|
-
|
|
58
|
-
**Architecture guidance, not hard rules:** use groups and concise labels where they help comprehension. Model only the components and flows supported by the user’s context. Gateways, event brokers, direct client streams, and domain-specific services are valid when the architecture calls for them.
|
|
59
|
-
|
|
60
|
-
**Privacy:** pass \`publish:false\` only if the user asks to keep the diagram private; then no link is created and the diagram stays in this MCP session. Retain and resend \`workingSessionId\` from the result when working on more than one diagram in parallel.
|
|
61
|
-
|
|
62
|
-
**WORKFLOW**:
|
|
63
|
-
1. Identify the user’s actual domain and constraints
|
|
64
|
-
2. Model only supported components and relationships
|
|
65
|
-
3. Optionally call list_node_types to find icon names
|
|
66
|
-
4. Design the Mermaid graph: groups (subgraphs) first, then children inside them
|
|
67
|
-
5. Design edges: use correct communicationType, audit Auth Service edges, verify no security bypass
|
|
68
|
-
6. **EDGE AUDIT (mandatory)**: Before calling this tool, scan every edge you planned:
|
|
69
|
-
- Does any edge have a client-tier node as the TARGET? DELETE IT (unless both source and target are client tier)
|
|
70
|
-
- Does any single node receive >45% of all edges? That node is a hub -- redistribute connections
|
|
71
|
-
- Do all edges flow LEFT->RIGHT (lower tier -> higher tier)? If not, fix direction.
|
|
72
|
-
7. Call this tool
|
|
73
|
-
|
|
74
|
-
**NODE FIELDS (JSON mode)**:
|
|
75
|
-
- id (required): snake_case unique ID
|
|
76
|
-
- label (required): 1-3 word display name
|
|
77
|
-
- tier (required): client | edge | compute | async | data | external | observe
|
|
78
|
-
- subtitle (required): specific description of what this service does
|
|
79
|
-
- isGroup: true = swimlane container wrapping child nodes
|
|
80
|
-
- parentId: ID of parent group (places this node inside that group)
|
|
81
|
-
- groupColor: hex background tint for group containers
|
|
82
|
-
- icon: lucide icon name (box, server, database, zap, shield, globe, etc.)
|
|
83
|
-
- accentColor: override highlight color (15 palette options)
|
|
84
|
-
- status: healthy | warning | error | unknown
|
|
85
|
-
- width/height: pixel size (groups: 400-800px wide, 200-400px tall)
|
|
86
|
-
|
|
87
|
-
**EDGE FIELDS (JSON mode)**:
|
|
88
|
-
- source, target (required): node IDs
|
|
89
|
-
- communicationType: sync | async | stream | event | dep
|
|
90
|
-
- label: required for async/stream/event — name the message or event
|
|
91
|
-
- pathType: Smoothstep | bezier | step | straight
|
|
92
|
-
|
|
93
|
-
**TIER COLORS**:
|
|
94
|
-
- client: #64748b (slate) — browsers, mobile apps
|
|
95
|
-
- edge: #6366f1 (indigo) — API gateways, load balancers, CDN
|
|
96
|
-
- compute: #0d9488 (teal) — microservices, workers, APIs
|
|
97
|
-
- async: #d97706 (amber) — queues, event buses, Kafka
|
|
98
|
-
- data: #3b82f6 (blue) — databases, caches, object storage
|
|
99
|
-
- external: #8b5cf6 (violet) — third-party APIs, payment gateways
|
|
100
|
-
- observe: #6b7280 (gray) — monitoring, logging, tracing`,
|
|
101
|
-
inputSchema: {
|
|
102
|
-
type: 'object',
|
|
103
|
-
properties: {
|
|
104
|
-
mermaid: {
|
|
105
|
-
type: 'string',
|
|
106
|
-
description: 'RECOMMENDED: Mermaid code for the diagram (graph LR or graph TD with subgraphs). Uses the web pipeline parser + Dagre layout.',
|
|
107
|
-
},
|
|
108
|
-
nodes: {
|
|
109
|
-
type: 'array',
|
|
110
|
-
description: 'Legacy JSON mode (only if not using mermaid). Array of nodes. RULES: (1) every node needs id+label+tier+subtitle, (2) include at least one isGroup:true node, (3) use parentId to nest nodes inside groups, (4) use accentColor to visually differentiate nodes in the same tier.',
|
|
111
|
-
items: {
|
|
112
|
-
type: 'object',
|
|
113
|
-
properties: {
|
|
114
|
-
id: { type: 'string', description: 'Unique snake_case identifier (e.g. "api_gateway", "postgres_db")' },
|
|
115
|
-
label: { type: 'string', description: 'Short display name (1-3 words)' },
|
|
116
|
-
tier: { type: 'string', description: 'Tier: client | edge | compute | async | data | external | observe' },
|
|
117
|
-
layer: { type: 'string', description: 'Alias for tier' },
|
|
118
|
-
subtitle: { type: 'string', description: 'REQUIRED: Specific description (e.g. "PostgreSQL 15, stores orders and users")' },
|
|
119
|
-
isGroup: { type: 'boolean', description: 'true = swimlane container. Use to cluster related services.' },
|
|
120
|
-
parentId: { type: 'string', description: 'ID of parent group — places this node inside that group' },
|
|
121
|
-
groupColor: { type: 'string', description: 'Background hex for group containers (e.g. "#0f172a")' },
|
|
122
|
-
icon: { type: 'string', description: 'Lucide icon name (server, database, zap, globe, shield, cpu, activity, box, cloud, layers, user, lock, wifi)' },
|
|
123
|
-
tierColor: { type: 'string', description: 'Override tier color hex' },
|
|
124
|
-
accentColor: { type: 'string', description: 'Highlight color: #3b82f6 #0ea5e9 #06b6d4 #14b8a6 #22c55e #f59e0b #f97316 #ef4444 #ec4899 #6b7280 #f43f5e #a855f7 #84cc16 #fb923c' },
|
|
125
|
-
status: { type: 'string', enum: ['healthy', 'warning', 'error', 'unknown'], description: 'Status dot shown on node' },
|
|
126
|
-
width: { type: 'number', description: 'Width px. Groups: 400-800. Nodes: 160-260.' },
|
|
127
|
-
height: { type: 'number', description: 'Height px. Groups: 200-400. Nodes: 60-90.' },
|
|
128
|
-
shape: { type: 'string', enum: ['rectangle', 'diamond', 'ellipse', 'hexagon'], description: 'Node shape' },
|
|
129
|
-
},
|
|
130
|
-
required: ['id', 'label', 'tier', 'subtitle'],
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
edges: {
|
|
134
|
-
type: 'array',
|
|
135
|
-
description: 'Legacy JSON mode (only if not using mermaid). Array of edges. REQUIRED. Add labels to all async/event/stream edges. Do not connect data tier directly to client tier.',
|
|
136
|
-
items: {
|
|
137
|
-
type: 'object',
|
|
138
|
-
properties: {
|
|
139
|
-
id: { type: 'string', description: 'Unique edge identifier' },
|
|
140
|
-
source: { type: 'string', description: 'Source node ID' },
|
|
141
|
-
target: { type: 'string', description: 'Target node ID' },
|
|
142
|
-
communicationType: {
|
|
143
|
-
type: 'string',
|
|
144
|
-
enum: ['sync', 'async', 'stream', 'event', 'dep'],
|
|
145
|
-
default: 'sync',
|
|
146
|
-
description: 'sync=REST/gRPC, async=queue/kafka, stream=WebSocket/SSE, event=pub-sub, dep=dependency',
|
|
147
|
-
},
|
|
148
|
-
pathType: {
|
|
149
|
-
type: 'string',
|
|
150
|
-
enum: ['smooth', 'Smoothstep', 'bezier', 'step', 'straight'],
|
|
151
|
-
default: 'Smoothstep',
|
|
152
|
-
description: 'Edge path style',
|
|
153
|
-
},
|
|
154
|
-
label: { type: 'string', description: 'Edge label. REQUIRED for async/stream/event. Describe the message or event name.' },
|
|
155
|
-
},
|
|
156
|
-
required: ['source', 'target', 'label'],
|
|
157
|
-
},
|
|
158
|
-
},
|
|
159
|
-
direction: {
|
|
160
|
-
type: 'string',
|
|
161
|
-
enum: ['RIGHT', 'DOWN', 'LEFT', 'UP'],
|
|
162
|
-
default: 'RIGHT',
|
|
163
|
-
description: 'Layout direction: RIGHT (LR, default), DOWN (TB for pipelines)',
|
|
164
|
-
},
|
|
165
|
-
label: { type: 'string', description: 'Diagram title' },
|
|
166
|
-
diagramDescription: { type: 'string', description: 'One-sentence description of what this architecture does' },
|
|
167
|
-
userPrompt: { type: 'string', description: 'The user\'s original request verbatim. Subtitle content must reflect any tech stack/services the user named.' },
|
|
168
|
-
techStack: { type: 'array', items: { type: 'string' }, description: 'Explicit technologies/services extracted from the prompt (e.g. ["Next.js", "PostgreSQL 15"]).' },
|
|
169
|
-
customFeatures: { type: 'array', items: { type: 'string' }, description: 'Custom features/components the user explicitly requested.' },
|
|
170
|
-
publish: { type: 'boolean', default: true, description: 'Create a preview link (default true). Set false only when the user asks to keep the diagram private.' },
|
|
171
|
-
workingSessionId: { type: 'string', description: 'Opaque local workspace key. Resend it to keep parallel diagrams isolated.' },
|
|
172
|
-
},
|
|
173
|
-
required: [],
|
|
174
|
-
},
|
|
175
|
-
outputSchema: {
|
|
176
|
-
type: 'object',
|
|
177
|
-
properties: {
|
|
178
|
-
success: { type: 'boolean' },
|
|
179
|
-
nodes: { type: 'array', items: { type: 'object' } },
|
|
180
|
-
edges: { type: 'array', items: { type: 'object' } },
|
|
181
|
-
diagramUrl: { type: 'string' },
|
|
182
|
-
shareUrl: { type: 'string' },
|
|
183
|
-
sessionId: { type: 'string' },
|
|
184
|
-
workingSessionId: { type: 'string' },
|
|
185
|
-
label: { type: 'string' },
|
|
186
|
-
metadata: {
|
|
187
|
-
type: 'object',
|
|
188
|
-
properties: {
|
|
189
|
-
nodeCount: { type: 'number' },
|
|
190
|
-
edgeCount: { type: 'number' },
|
|
191
|
-
layoutAlgorithm: { type: 'string' },
|
|
192
|
-
direction: { type: 'string' },
|
|
193
|
-
groupCount: { type: 'number' },
|
|
194
|
-
},
|
|
195
|
-
},
|
|
196
|
-
errors: { type: 'array', items: { type: 'string' } },
|
|
197
|
-
},
|
|
198
|
-
required: ['success', 'nodes', 'edges', 'workingSessionId', 'metadata'],
|
|
199
|
-
},
|
|
200
|
-
annotations: { title: 'Generate an ArchDraw diagram', openWorldHint: true },
|
|
201
|
-
_meta: {
|
|
202
|
-
ui: { resourceUri: DIAGRAM_WIDGET_URI },
|
|
203
|
-
'openai/toolInvocation/invoking': 'Generating diagram…',
|
|
204
|
-
'openai/toolInvocation/invoked': 'Diagram preview ready',
|
|
205
|
-
},
|
|
206
|
-
},
|
|
207
|
-
{
|
|
208
|
-
name: 'fix_layout',
|
|
209
|
-
description: `Apply the same Mermaid → Dagre auto-layout pipeline used by the ArchDraw editor.
|
|
210
|
-
|
|
211
|
-
**USE WHEN**: User provides nodes/edges that need automatic positioning
|
|
212
|
-
**INPUT**: Nodes with their tier assignments, plus edges between them
|
|
213
|
-
**OUTPUT**: Returns nodes with x,y positions computed by the editor pipeline
|
|
214
|
-
|
|
215
|
-
This tool does NOT generate or modify nodes/edges - it only computes optimal positions.
|
|
216
|
-
|
|
217
|
-
**INPUT**:
|
|
218
|
-
- nodes: Array of nodes (id, label, layer/tier required)
|
|
219
|
-
- edges: Array of connections between nodes
|
|
220
|
-
- direction: Layout direction (RIGHT is default, means left-to-right)`,
|
|
221
|
-
inputSchema: {
|
|
222
|
-
type: 'object',
|
|
223
|
-
properties: {
|
|
224
|
-
nodes: {
|
|
225
|
-
type: 'array',
|
|
226
|
-
description: 'Array of nodes with layer assignments',
|
|
227
|
-
items: {
|
|
228
|
-
type: 'object',
|
|
229
|
-
properties: {
|
|
230
|
-
id: { type: 'string', description: 'Unique node identifier' },
|
|
231
|
-
label: { type: 'string', description: 'Node label/name' },
|
|
232
|
-
layer: { type: 'string', description: 'Tier layer: client, edge, compute, async, data, observe, external' },
|
|
233
|
-
width: { type: 'number', default: 180, description: 'Node width' },
|
|
234
|
-
height: { type: 'number', default: 70, description: 'Node height' },
|
|
235
|
-
},
|
|
236
|
-
required: ['id', 'label', 'layer'],
|
|
237
|
-
},
|
|
238
|
-
},
|
|
239
|
-
edges: {
|
|
240
|
-
type: 'array',
|
|
241
|
-
description: 'Array of edges connecting the nodes',
|
|
242
|
-
items: {
|
|
243
|
-
type: 'object',
|
|
244
|
-
properties: {
|
|
245
|
-
id: { type: 'string', description: 'Unique edge identifier' },
|
|
246
|
-
source: { type: 'string', description: 'Source node ID' },
|
|
247
|
-
target: { type: 'string', description: 'Target node ID' },
|
|
248
|
-
communicationType: {
|
|
249
|
-
type: 'string',
|
|
250
|
-
enum: ['sync', 'async', 'stream', 'event', 'dep'],
|
|
251
|
-
default: 'sync',
|
|
252
|
-
description: 'Communication type between nodes',
|
|
253
|
-
},
|
|
254
|
-
},
|
|
255
|
-
required: ['source', 'target'],
|
|
256
|
-
},
|
|
257
|
-
},
|
|
258
|
-
direction: {
|
|
259
|
-
type: 'string',
|
|
260
|
-
enum: ['RIGHT', 'DOWN', 'LEFT', 'UP'],
|
|
261
|
-
default: 'RIGHT',
|
|
262
|
-
description: 'Layout direction',
|
|
263
|
-
},
|
|
264
|
-
},
|
|
265
|
-
required: ['nodes'],
|
|
266
|
-
},
|
|
267
|
-
},
|
|
268
|
-
{
|
|
269
|
-
name: 'list_node_types',
|
|
270
|
-
description: `List all available pre-made component types from the ArchDraw component library.
|
|
271
|
-
|
|
272
|
-
**USE WHEN**: You want to see what components are available before generating a diagram
|
|
273
|
-
**OUTPUT**: Categorized list of 150+ component types with their icons and descriptions
|
|
274
|
-
|
|
275
|
-
**FILTERING**:
|
|
276
|
-
- category: Filter by category name (e.g., "AI / ML", "Data Storage", "Compute", "Messaging & Events")
|
|
277
|
-
- search: Search by label, description, or category
|
|
278
|
-
- limit: Max results (default 50, max 200)
|
|
279
|
-
|
|
280
|
-
**CATEGORIES INCLUDE**:
|
|
281
|
-
- Client & Entry (CDN, Load Balancer, API Gateway)
|
|
282
|
-
- Compute (API Server, Auth Service, Workers, Containers)
|
|
283
|
-
- AI / ML (LLM Models, Vector DB, Embedding Service, RAG)
|
|
284
|
-
- Data Storage (PostgreSQL, MongoDB, Redis, S3)
|
|
285
|
-
- Messaging & Events (Kafka, RabbitMQ, SQS)
|
|
286
|
-
- Observability (Prometheus, Grafana, ELK Stack)
|
|
287
|
-
- External Services (Stripe, Twilio, SendGrid)`,
|
|
288
|
-
inputSchema: {
|
|
289
|
-
type: 'object',
|
|
290
|
-
properties: {
|
|
291
|
-
category: {
|
|
292
|
-
type: 'string',
|
|
293
|
-
description: 'Filter by category name (e.g., "AI / ML", "Data Storage", "Compute")',
|
|
294
|
-
},
|
|
295
|
-
search: {
|
|
296
|
-
type: 'string',
|
|
297
|
-
description: 'Search by label, description, or category',
|
|
298
|
-
},
|
|
299
|
-
limit: {
|
|
300
|
-
type: 'number',
|
|
301
|
-
default: 50,
|
|
302
|
-
minimum: 1,
|
|
303
|
-
maximum: 200,
|
|
304
|
-
description: 'Maximum number of results',
|
|
305
|
-
},
|
|
306
|
-
},
|
|
307
|
-
},
|
|
308
|
-
},
|
|
309
|
-
{
|
|
310
|
-
name: 'apply_template',
|
|
311
|
-
title: 'Apply an ArchDraw template',
|
|
312
|
-
description: `Apply a pre-built architecture template with pre-defined nodes and edges. Compatible chat clients display the result as an inline preview.
|
|
313
|
-
|
|
314
|
-
**USE WHEN**: User wants a common architecture pattern (e-commerce, chat app, rideshare, etc.)
|
|
315
|
-
**OUTPUT**: Full diagram with positioned nodes and edges, plus a preview link (shareUrl) and edit link (diagramUrl) created by default. ALWAYS show those links to the user. Pass publish:false only if the user asks to keep it private.
|
|
316
|
-
|
|
317
|
-
**AVAILABLE TEMPLATES**:
|
|
318
|
-
- archflow: ArchDraw's own architecture (modern SaaS)
|
|
319
|
-
- chatgpt: LLM chat app with RAG, vector DB, streaming
|
|
320
|
-
- instagram: Social platform with Kafka, media storage, search
|
|
321
|
-
- rideshare: Uber-like with real-time tracking and dynamic pricing
|
|
322
|
-
- ecommerce: Full e-commerce with cart, payments, order management
|
|
323
|
-
|
|
324
|
-
**CUSTOMIZATIONS**:
|
|
325
|
-
- renameNodes: Map of node ID to new label
|
|
326
|
-
- addNodes: Additional nodes to include`,
|
|
327
|
-
inputSchema: {
|
|
328
|
-
type: 'object',
|
|
329
|
-
properties: {
|
|
330
|
-
templateId: {
|
|
331
|
-
type: 'string',
|
|
332
|
-
description: 'Template identifier: archflow, chatgpt, instagram, rideshare, ecommerce',
|
|
333
|
-
},
|
|
334
|
-
customizations: {
|
|
335
|
-
type: 'object',
|
|
336
|
-
description: 'Optional customizations to apply',
|
|
337
|
-
properties: {
|
|
338
|
-
renameNodes: {
|
|
339
|
-
type: 'object',
|
|
340
|
-
description: 'Map of node ID to new label',
|
|
341
|
-
additionalProperties: { type: 'string' },
|
|
342
|
-
},
|
|
343
|
-
addNodes: {
|
|
344
|
-
type: 'array',
|
|
345
|
-
description: 'Additional nodes to add',
|
|
346
|
-
items: {
|
|
347
|
-
type: 'object',
|
|
348
|
-
properties: {
|
|
349
|
-
id: { type: 'string' },
|
|
350
|
-
label: { type: 'string' },
|
|
351
|
-
category: { type: 'string' },
|
|
352
|
-
color: { type: 'string' },
|
|
353
|
-
icon: { type: 'string' },
|
|
354
|
-
},
|
|
355
|
-
},
|
|
356
|
-
},
|
|
357
|
-
},
|
|
358
|
-
},
|
|
359
|
-
publish: { type: 'boolean', default: true, description: 'Create a preview link (default true). Set false only when the user asks to keep the diagram private.' },
|
|
360
|
-
workingSessionId: { type: 'string', description: 'Opaque local workspace key for isolating parallel diagrams.' },
|
|
361
|
-
},
|
|
362
|
-
required: ['templateId'],
|
|
363
|
-
},
|
|
364
|
-
_meta: {
|
|
365
|
-
ui: { resourceUri: DIAGRAM_WIDGET_URI },
|
|
366
|
-
'openai/toolInvocation/invoking': 'Loading template…',
|
|
367
|
-
'openai/toolInvocation/invoked': 'Diagram preview ready',
|
|
368
|
-
},
|
|
369
|
-
},
|
|
370
|
-
{
|
|
371
|
-
name: 'list_templates',
|
|
372
|
-
description: 'List all available architecture templates with their descriptions',
|
|
373
|
-
inputSchema: {
|
|
374
|
-
type: 'object',
|
|
375
|
-
properties: {},
|
|
376
|
-
},
|
|
377
|
-
},
|
|
378
|
-
{
|
|
379
|
-
name: 'read_me',
|
|
380
|
-
description: `Returns a compact LLM-optimized reference guide for ArchDraw — tiers, node types,
|
|
381
|
-
edge communication types, layout rules, and best practices. Call this FIRST before generating
|
|
382
|
-
any diagram to produce accurate, professional output.`,
|
|
383
|
-
inputSchema: {
|
|
384
|
-
type: 'object',
|
|
385
|
-
properties: {},
|
|
386
|
-
},
|
|
387
|
-
},
|
|
388
|
-
{
|
|
389
|
-
name: 'get_diagram_state',
|
|
390
|
-
description: `Returns the current diagram's nodes and edges as structured JSON.
|
|
391
|
-
Call this before update_diagram to read what's on the canvas.
|
|
392
|
-
Optionally pass a sessionId to load that diagram first (e.g. a link the user opened).`,
|
|
393
|
-
inputSchema: {
|
|
394
|
-
type: 'object',
|
|
395
|
-
properties: {
|
|
396
|
-
sessionId: { type: 'string', description: 'Optional session ID to load before returning state (e.g. from a diagramUrl the user shared).' },
|
|
397
|
-
},
|
|
398
|
-
},
|
|
399
|
-
},
|
|
400
|
-
{
|
|
401
|
-
name: 'update_diagram',
|
|
402
|
-
description: `Surgically modifies an existing diagram. Add nodes, remove nodes,
|
|
403
|
-
add edges, remove edges, or update node properties — without regenerating the whole diagram.`,
|
|
404
|
-
inputSchema: {
|
|
405
|
-
type: 'object',
|
|
406
|
-
properties: {
|
|
407
|
-
addNodes: {
|
|
408
|
-
type: 'array',
|
|
409
|
-
description: 'Nodes to add',
|
|
410
|
-
items: {
|
|
411
|
-
type: 'object',
|
|
412
|
-
properties: {
|
|
413
|
-
id: { type: 'string', description: 'Unique node identifier' },
|
|
414
|
-
label: { type: 'string', description: 'Display name' },
|
|
415
|
-
tier: { type: 'string', description: 'Tier: client, edge, compute, async, data, observe, external' },
|
|
416
|
-
subtitle: { type: 'string', description: 'Optional short description' },
|
|
417
|
-
icon: { type: 'string', description: 'Optional icon name' },
|
|
418
|
-
},
|
|
419
|
-
required: ['id', 'label', 'tier'],
|
|
420
|
-
},
|
|
421
|
-
},
|
|
422
|
-
removeNodeIds: {
|
|
423
|
-
type: 'array',
|
|
424
|
-
description: 'Node IDs to remove',
|
|
425
|
-
items: { type: 'string' },
|
|
426
|
-
},
|
|
427
|
-
addEdges: {
|
|
428
|
-
type: 'array',
|
|
429
|
-
description: 'Edges to add',
|
|
430
|
-
items: {
|
|
431
|
-
type: 'object',
|
|
432
|
-
properties: {
|
|
433
|
-
source: { type: 'string', description: 'Source node ID' },
|
|
434
|
-
target: { type: 'string', description: 'Target node ID' },
|
|
435
|
-
communicationType: { type: 'string', enum: ['sync', 'async', 'stream', 'event', 'dep'] },
|
|
436
|
-
label: { type: 'string', description: 'Optional edge label' },
|
|
437
|
-
},
|
|
438
|
-
required: ['source', 'target'],
|
|
439
|
-
},
|
|
440
|
-
},
|
|
441
|
-
removeEdgeIds: {
|
|
442
|
-
type: 'array',
|
|
443
|
-
description: 'Edge IDs to remove',
|
|
444
|
-
items: { type: 'string' },
|
|
445
|
-
},
|
|
446
|
-
updateNodes: {
|
|
447
|
-
type: 'array',
|
|
448
|
-
description: 'Nodes to update',
|
|
449
|
-
items: {
|
|
450
|
-
type: 'object',
|
|
451
|
-
properties: {
|
|
452
|
-
id: { type: 'string', description: 'Node ID to update' },
|
|
453
|
-
label: { type: 'string', description: 'New label' },
|
|
454
|
-
subtitle: { type: 'string', description: 'New subtitle' },
|
|
455
|
-
tier: { type: 'string', description: 'New tier' },
|
|
456
|
-
},
|
|
457
|
-
required: ['id'],
|
|
458
|
-
},
|
|
459
|
-
},
|
|
460
|
-
},
|
|
461
|
-
},
|
|
462
|
-
},
|
|
463
|
-
{
|
|
464
|
-
name: 'validate_diagram',
|
|
465
|
-
description: `Analyses the current diagram and returns a list of structural issues
|
|
466
|
-
and improvement suggestions. Use after generating to catch problems before rendering.`,
|
|
467
|
-
inputSchema: {
|
|
468
|
-
type: 'object',
|
|
469
|
-
properties: {},
|
|
470
|
-
},
|
|
471
|
-
},
|
|
472
|
-
{
|
|
473
|
-
name: 'save_checkpoint',
|
|
474
|
-
description: `Saves the current diagram state with a named label so it can be restored later.
|
|
475
|
-
Useful for multi-turn workflows: save before a major change, restore if needed.`,
|
|
476
|
-
inputSchema: {
|
|
477
|
-
type: 'object',
|
|
478
|
-
properties: {
|
|
479
|
-
name: { type: 'string', description: 'Checkpoint name (e.g. "before-refactor")' },
|
|
480
|
-
description: { type: 'string', description: 'Optional description' },
|
|
481
|
-
},
|
|
482
|
-
required: ['name'],
|
|
483
|
-
},
|
|
484
|
-
},
|
|
485
|
-
{
|
|
486
|
-
name: 'load_checkpoint',
|
|
487
|
-
description: `Restores a previously saved diagram state by name.`,
|
|
488
|
-
inputSchema: {
|
|
489
|
-
type: 'object',
|
|
490
|
-
properties: {
|
|
491
|
-
name: { type: 'string', description: 'Checkpoint name to restore' },
|
|
492
|
-
listAvailable: { type: 'boolean', description: 'If true, list all checkpoints without restoring' },
|
|
493
|
-
},
|
|
494
|
-
required: ['name'],
|
|
495
|
-
},
|
|
496
|
-
},
|
|
497
|
-
{
|
|
498
|
-
name: 'export_diagram',
|
|
499
|
-
description: `Export the current diagram in various formats.
|
|
500
|
-
|
|
501
|
-
**USE WHEN**: User wants to save or download the diagram
|
|
502
|
-
**OUTPUT**: Returns the diagram data or instructions for image export
|
|
503
|
-
|
|
504
|
-
**FORMATS**:
|
|
505
|
-
- json: Returns raw nodes and edges as JSON (recommended for saving)
|
|
506
|
-
- png: Returns instructions to export as PNG from the editor
|
|
507
|
-
- svg: Returns instructions to export as SVG from the editor
|
|
508
|
-
|
|
509
|
-
**REQUIREMENT**: You must have a diagram loaded (generate or apply a template first).`,
|
|
510
|
-
inputSchema: {
|
|
511
|
-
type: 'object',
|
|
512
|
-
properties: {
|
|
513
|
-
sessionId: { type: 'string', description: 'Session ID from a previous diagram operation. Omit to use the most recent session.' },
|
|
514
|
-
format: { type: 'string', enum: ['json', 'png', 'svg'], default: 'json', description: 'Export format' },
|
|
515
|
-
},
|
|
516
|
-
required: [],
|
|
517
|
-
},
|
|
518
|
-
},
|
|
519
|
-
];
|
|
520
|
-
class ArchDrawMCPServer {
|
|
521
|
-
server;
|
|
522
|
-
constructor() {
|
|
523
|
-
this.server = new Server({
|
|
524
|
-
name: 'archdraw-mcp-server',
|
|
525
|
-
version: '1.0.4',
|
|
526
|
-
}, {
|
|
527
|
-
capabilities: {
|
|
528
|
-
tools: {},
|
|
529
|
-
resources: {},
|
|
530
|
-
},
|
|
531
|
-
});
|
|
532
|
-
this.setupHandlers();
|
|
533
|
-
}
|
|
534
|
-
setupHandlers() {
|
|
535
|
-
this.server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
536
|
-
return { tools: TOOLS };
|
|
537
|
-
});
|
|
538
|
-
this.server.setRequestHandler(ListResourcesRequestSchema, async () => ({
|
|
539
|
-
resources: [{
|
|
540
|
-
uri: DIAGRAM_WIDGET_URI,
|
|
541
|
-
name: 'ArchDraw diagram preview',
|
|
542
|
-
description: 'Inline diagram preview and prompt form for generating another ArchDraw diagram in the chat.',
|
|
543
|
-
mimeType: 'text/html;profile=mcp-app',
|
|
544
|
-
}],
|
|
545
|
-
}));
|
|
546
|
-
this.server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
|
|
547
|
-
if (request.params.uri !== DIAGRAM_WIDGET_URI) {
|
|
548
|
-
throw new Error(`Unknown resource: ${request.params.uri}`);
|
|
549
|
-
}
|
|
550
|
-
return {
|
|
551
|
-
contents: [{
|
|
552
|
-
uri: DIAGRAM_WIDGET_URI,
|
|
553
|
-
mimeType: 'text/html;profile=mcp-app',
|
|
554
|
-
text: DIAGRAM_WIDGET_HTML,
|
|
555
|
-
_meta: { ui: { prefersBorder: true } },
|
|
556
|
-
}],
|
|
557
|
-
};
|
|
558
|
-
});
|
|
559
|
-
this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
560
|
-
const { name, arguments: args } = request.params;
|
|
561
|
-
// Stdio normally has one client, but hosts can multiplex calls. Agents
|
|
562
|
-
// should retain and resend this opaque key to isolate parallel diagrams.
|
|
563
|
-
let workingSession = typeof args?.workingSessionId === 'string' && args.workingSessionId.trim()
|
|
564
|
-
? args.workingSessionId.trim()
|
|
565
|
-
: '';
|
|
566
|
-
if (!workingSession && (name === 'generate_diagram' || name === 'apply_template')) {
|
|
567
|
-
workingSession = randomUUID();
|
|
568
|
-
}
|
|
569
|
-
if (!workingSession)
|
|
570
|
-
workingSession = 'default';
|
|
571
|
-
try {
|
|
572
|
-
switch (name) {
|
|
573
|
-
case 'generate_diagram': {
|
|
574
|
-
const input = GenerateDiagramInputSchema.parse(args);
|
|
575
|
-
const result = await generateDiagram(input);
|
|
576
|
-
if (result.success) {
|
|
577
|
-
const { setDiagramState } = await import('./lib/diagram-state.js');
|
|
578
|
-
setDiagramState({ nodes: result.nodes, edges: result.edges, sessionId: result.sessionId, updateToken: result.updateToken }, workingSession);
|
|
579
|
-
}
|
|
580
|
-
const structuredContent = {
|
|
581
|
-
success: result.success,
|
|
582
|
-
nodes: result.nodes,
|
|
583
|
-
edges: result.edges,
|
|
584
|
-
...(result.diagramUrl ? { diagramUrl: result.diagramUrl } : {}),
|
|
585
|
-
...(result.shareUrl ? { shareUrl: result.shareUrl } : {}),
|
|
586
|
-
...(result.sessionId ? { sessionId: result.sessionId } : {}),
|
|
587
|
-
workingSessionId: workingSession,
|
|
588
|
-
label: input.label || 'ArchDraw diagram',
|
|
589
|
-
metadata: result.metadata,
|
|
590
|
-
...(result.errors?.length ? { errors: result.errors } : {}),
|
|
591
|
-
};
|
|
592
|
-
const summary = result.message || `Diagram generated with ${result.metadata.nodeCount} nodes and ${result.metadata.edgeCount} connections.`;
|
|
593
|
-
const text = result.success
|
|
594
|
-
? `${formatPreviewLinks({ ...result, privateByRequest: input.publish === false })}\n\n${summary}`
|
|
595
|
-
: `Diagram generation failed: ${(result.errors || ['Unknown error']).join('; ')}`;
|
|
596
|
-
return {
|
|
597
|
-
structuredContent: { ...structuredContent, ...(result.linkError ? { linkError: result.linkError } : {}) },
|
|
598
|
-
content: [{ type: 'text', text }],
|
|
599
|
-
};
|
|
600
|
-
}
|
|
601
|
-
case 'fix_layout': {
|
|
602
|
-
const input = FixLayoutInputSchema.parse(args);
|
|
603
|
-
const result = await fixLayout(input);
|
|
604
|
-
return {
|
|
605
|
-
content: [
|
|
606
|
-
{
|
|
607
|
-
type: 'text',
|
|
608
|
-
text: JSON.stringify(result, null, 2),
|
|
609
|
-
},
|
|
610
|
-
],
|
|
611
|
-
};
|
|
612
|
-
}
|
|
613
|
-
case 'list_node_types': {
|
|
614
|
-
const input = ListNodeTypesInputSchema.parse(args ?? {});
|
|
615
|
-
const result = await listNodeTypes(input);
|
|
616
|
-
return {
|
|
617
|
-
content: [
|
|
618
|
-
{
|
|
619
|
-
type: 'text',
|
|
620
|
-
text: JSON.stringify(result, null, 2),
|
|
621
|
-
},
|
|
622
|
-
],
|
|
623
|
-
};
|
|
624
|
-
}
|
|
625
|
-
case 'apply_template': {
|
|
626
|
-
const input = ApplyTemplateInputSchema.parse(args);
|
|
627
|
-
const result = await applyTemplate(input);
|
|
628
|
-
if (result.success) {
|
|
629
|
-
const { setDiagramState } = await import('./lib/diagram-state.js');
|
|
630
|
-
setDiagramState({ nodes: result.nodes, edges: result.edges, sessionId: result.sessionId, updateToken: result.updateToken }, workingSession);
|
|
631
|
-
}
|
|
632
|
-
const structuredContent = {
|
|
633
|
-
success: result.success,
|
|
634
|
-
nodes: result.nodes,
|
|
635
|
-
edges: result.edges,
|
|
636
|
-
...(result.diagramUrl ? { diagramUrl: result.diagramUrl } : {}),
|
|
637
|
-
...(result.shareUrl ? { shareUrl: result.shareUrl } : {}),
|
|
638
|
-
...(result.sessionId ? { sessionId: result.sessionId } : {}),
|
|
639
|
-
workingSessionId: workingSession,
|
|
640
|
-
label: input.templateId,
|
|
641
|
-
metadata: {
|
|
642
|
-
nodeCount: result.nodes.length,
|
|
643
|
-
edgeCount: result.edges.length,
|
|
644
|
-
groupCount: result.nodes.filter(node => node.data?.isGroup).length,
|
|
645
|
-
layoutAlgorithm: 'template',
|
|
646
|
-
},
|
|
647
|
-
...(result.errors?.length ? { errors: result.errors } : {}),
|
|
648
|
-
};
|
|
649
|
-
const text = result.success
|
|
650
|
-
? `${formatPreviewLinks({ ...result, privateByRequest: input.publish === false })}\n\n${result.message || `${input.templateId} template is ready.`}`
|
|
651
|
-
: `Template failed: ${(result.errors || ['Unknown error']).join('; ')}`;
|
|
652
|
-
return {
|
|
653
|
-
structuredContent: { ...structuredContent, ...(result.linkError ? { linkError: result.linkError } : {}) },
|
|
654
|
-
content: [{ type: 'text', text }],
|
|
655
|
-
};
|
|
656
|
-
}
|
|
657
|
-
case 'list_templates': {
|
|
658
|
-
const templates = getAvailableTemplates();
|
|
659
|
-
return {
|
|
660
|
-
content: [
|
|
661
|
-
{
|
|
662
|
-
type: 'text',
|
|
663
|
-
text: JSON.stringify({ templates }, null, 2),
|
|
664
|
-
},
|
|
665
|
-
],
|
|
666
|
-
};
|
|
667
|
-
}
|
|
668
|
-
case 'read_me': {
|
|
669
|
-
const readmeContent = getReadMe();
|
|
670
|
-
return {
|
|
671
|
-
content: [
|
|
672
|
-
{
|
|
673
|
-
type: 'text',
|
|
674
|
-
text: readmeContent,
|
|
675
|
-
},
|
|
676
|
-
],
|
|
677
|
-
};
|
|
678
|
-
}
|
|
679
|
-
case 'get_diagram_state': {
|
|
680
|
-
const { sessionId } = (args ?? {});
|
|
681
|
-
if (typeof sessionId === 'string' && sessionId.trim().length > 0) {
|
|
682
|
-
const { syncDiagramStateFromSession } = await import('./lib/diagram-state.js');
|
|
683
|
-
const synced = await syncDiagramStateFromSession(sessionId.trim(), undefined, workingSession);
|
|
684
|
-
if (!synced) {
|
|
685
|
-
return {
|
|
686
|
-
content: [
|
|
687
|
-
{
|
|
688
|
-
type: 'text',
|
|
689
|
-
text: JSON.stringify({ error: `Could not load session '${sessionId}'. It may not exist or the frontend is unreachable.` }, null, 2),
|
|
690
|
-
},
|
|
691
|
-
],
|
|
692
|
-
isError: true,
|
|
693
|
-
};
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
const state = getDiagramState(workingSession);
|
|
697
|
-
return {
|
|
698
|
-
content: [
|
|
699
|
-
{
|
|
700
|
-
type: 'text',
|
|
701
|
-
text: JSON.stringify(state.nodes.length === 0 && state.edges.length === 0
|
|
702
|
-
? { nodes: [], edges: [], message: 'No diagram loaded yet.' }
|
|
703
|
-
: state, null, 2),
|
|
704
|
-
},
|
|
705
|
-
],
|
|
706
|
-
};
|
|
707
|
-
}
|
|
708
|
-
case 'update_diagram': {
|
|
709
|
-
const input = UpdateDiagramInputSchema.parse(args);
|
|
710
|
-
const result = await updateDiagram(input, workingSession);
|
|
711
|
-
if (result.success) {
|
|
712
|
-
const { setDiagramState } = await import('./lib/diagram-state.js');
|
|
713
|
-
const previous = getDiagramState(workingSession);
|
|
714
|
-
setDiagramState({ nodes: result.nodes, edges: result.edges, sessionId: result.sessionId, updateToken: previous.updateToken }, workingSession);
|
|
715
|
-
}
|
|
716
|
-
const details = JSON.stringify({
|
|
717
|
-
success: result.success,
|
|
718
|
-
message: result.message,
|
|
719
|
-
error: result.error,
|
|
720
|
-
changes: result.changes,
|
|
721
|
-
diagramUrl: result.diagramUrl,
|
|
722
|
-
shareUrl: result.shareUrl,
|
|
723
|
-
sessionId: result.sessionId,
|
|
724
|
-
workingSessionId: workingSession,
|
|
725
|
-
note: 'Raw nodes and edges omitted for brevity.',
|
|
726
|
-
}, null, 2);
|
|
727
|
-
// The published link is updated in place — resurface it so the
|
|
728
|
-
// user can see the change without asking for the link again.
|
|
729
|
-
const linkBlock = result.success && (result.shareUrl || result.diagramUrl)
|
|
730
|
-
? `${formatPreviewLinks(result)}\n\n`
|
|
731
|
-
: '';
|
|
732
|
-
return {
|
|
733
|
-
content: [{ type: 'text', text: `${linkBlock}${details}` }],
|
|
734
|
-
};
|
|
735
|
-
}
|
|
736
|
-
case 'validate_diagram': {
|
|
737
|
-
const result = await validateDiagram(workingSession);
|
|
738
|
-
return {
|
|
739
|
-
content: [
|
|
740
|
-
{
|
|
741
|
-
type: 'text',
|
|
742
|
-
text: JSON.stringify(result, null, 2),
|
|
743
|
-
},
|
|
744
|
-
],
|
|
745
|
-
};
|
|
746
|
-
}
|
|
747
|
-
case 'save_checkpoint': {
|
|
748
|
-
const input = SaveCheckpointInputSchema.parse(args);
|
|
749
|
-
const result = await saveCheckpoint(input, workingSession);
|
|
750
|
-
return {
|
|
751
|
-
content: [
|
|
752
|
-
{
|
|
753
|
-
type: 'text',
|
|
754
|
-
text: JSON.stringify(result, null, 2),
|
|
755
|
-
},
|
|
756
|
-
],
|
|
757
|
-
};
|
|
758
|
-
}
|
|
759
|
-
case 'load_checkpoint': {
|
|
760
|
-
const input = LoadCheckpointInputSchema.parse(args);
|
|
761
|
-
const result = await loadCheckpoint(input, workingSession);
|
|
762
|
-
return {
|
|
763
|
-
content: [
|
|
764
|
-
{
|
|
765
|
-
type: 'text',
|
|
766
|
-
text: JSON.stringify(result, null, 2),
|
|
767
|
-
},
|
|
768
|
-
],
|
|
769
|
-
};
|
|
770
|
-
}
|
|
771
|
-
case 'export_diagram': {
|
|
772
|
-
const input = ExportDiagramInputSchema.parse(args);
|
|
773
|
-
const result = await exportDiagram(input);
|
|
774
|
-
return {
|
|
775
|
-
content: [
|
|
776
|
-
{
|
|
777
|
-
type: 'text',
|
|
778
|
-
text: JSON.stringify(result, null, 2),
|
|
779
|
-
},
|
|
780
|
-
],
|
|
781
|
-
};
|
|
782
|
-
}
|
|
783
|
-
default:
|
|
784
|
-
return {
|
|
785
|
-
content: [
|
|
786
|
-
{
|
|
787
|
-
type: 'text',
|
|
788
|
-
text: `Unknown tool: ${name}`,
|
|
789
|
-
},
|
|
790
|
-
],
|
|
791
|
-
isError: true,
|
|
792
|
-
};
|
|
793
|
-
}
|
|
794
|
-
}
|
|
795
|
-
catch (error) {
|
|
796
|
-
return {
|
|
797
|
-
content: [
|
|
798
|
-
{
|
|
799
|
-
type: 'text',
|
|
800
|
-
text: error instanceof Error ? error.message : String(error),
|
|
801
|
-
},
|
|
802
|
-
],
|
|
803
|
-
isError: true,
|
|
804
|
-
};
|
|
805
|
-
}
|
|
806
|
-
});
|
|
807
|
-
}
|
|
808
|
-
async run() {
|
|
809
|
-
const transport = new StdioServerTransport();
|
|
810
|
-
await this.server.connect(transport);
|
|
811
|
-
console.error('ArchDraw MCP server running on stdio');
|
|
812
|
-
}
|
|
813
|
-
}
|
|
814
|
-
const server = new ArchDrawMCPServer();
|
|
815
|
-
server.run().catch(console.error);
|
|
3
|
+
import { createArchDrawMCPServer } from './server.js';
|
|
4
|
+
const server = createArchDrawMCPServer();
|
|
5
|
+
server.connect(new StdioServerTransport())
|
|
6
|
+
.then(() => console.error('ArchDraw MCP server running on stdio'))
|
|
7
|
+
.catch(console.error);
|
|
816
8
|
//# sourceMappingURL=index.js.map
|