@shirbarzur/planform-mcp-server 1.0.5 → 1.0.7
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/.mcpregistry_github_token +1 -1
- package/.mcpregistry_registry_token +1 -1
- package/MCP_CONNECTION_GUIDE.md +20 -10
- package/README.md +27 -39
- package/dist/server.d.ts +25 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +301 -172
- package/dist/server.js.map +1 -1
- package/dist/token-store.d.ts +21 -0
- package/dist/token-store.d.ts.map +1 -0
- package/dist/token-store.js +88 -0
- package/dist/token-store.js.map +1 -0
- package/dist/usage-examples.d.ts +2 -2
- package/dist/usage-examples.d.ts.map +1 -1
- package/dist/usage-examples.js +31 -22
- package/dist/usage-examples.js.map +1 -1
- package/package.json +1 -1
- package/server.json +2 -2
- package/src/server.ts +313 -191
- package/src/token-store.ts +95 -0
- package/src/usage-examples.ts +31 -22
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
ghu_qVZZlzCmVSDhuDFh5A3HOIVmkdSZUk3d4nYb
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"token":"eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.
|
|
1
|
+
{"token":"eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJtY3AtcmVnaXN0cnkiLCJleHAiOjE3NzIwODY5MzksIm5iZiI6MTc3MjA4NjYzOSwiaWF0IjoxNzcyMDg2NjM5LCJhdXRoX21ldGhvZCI6ImdpdGh1Yi1hdCIsImF1dGhfbWV0aG9kX3N1YiI6IlNoaXJCYXJadXIiLCJwZXJtaXNzaW9ucyI6W3siYWN0aW9uIjoicHVibGlzaCIsInJlc291cmNlIjoiaW8uZ2l0aHViLlNoaXJCYXJadXIvKiJ9XX0.06x9V-YNUNoTi4TbIuLartAhQ3Q8RvRD-R--r3fCD7ga00EJIZZm1aLJM0g5bLtNYH4m0S_OiBgS6HwhMyD3CQ","expires_at":1772086939}
|
package/MCP_CONNECTION_GUIDE.md
CHANGED
|
@@ -109,7 +109,7 @@ After adding the configuration, restart Cursor or VS Code to load the MCP server
|
|
|
109
109
|
|
|
110
110
|
The MCP server uses device code authentication. When you first use the MCP tools:
|
|
111
111
|
|
|
112
|
-
1. **Start Device Flow**: Use the `
|
|
112
|
+
1. **Start Device Flow**: Use the `sign_in` tool in Cursor/Copilot
|
|
113
113
|
- This will return a `user_code` (e.g., "ABCD-EFGH") and `verification_uri`
|
|
114
114
|
- **The browser will automatically open** with the verification page
|
|
115
115
|
|
|
@@ -126,15 +126,25 @@ The MCP server uses device code authentication. When you first use the MCP tools
|
|
|
126
126
|
- Once you approve in the browser, the token will be received automatically
|
|
127
127
|
- You'll see log messages indicating polling status
|
|
128
128
|
- The access token is valid for 7 days and is stored automatically
|
|
129
|
-
- **Note**: `
|
|
129
|
+
- **Note**: `poll_auth_token` is available as an optional/advanced tool if you need to manually check status, but it's usually not needed
|
|
130
|
+
|
|
131
|
+
## After first sign-in (no IDs to pass)
|
|
132
|
+
|
|
133
|
+
Once you have signed in with `sign_in`, the server **remembers your session**. You do not pass or copy any user IDs:
|
|
134
|
+
|
|
135
|
+
- **`list_diagrams`** – No arguments needed; the server uses your stored session.
|
|
136
|
+
- **`create_diagram`** – Pass only `title` and `type`; the new diagram becomes the "current" one.
|
|
137
|
+
- **`open_diagram`** – Pass a **diagram title** (e.g. `"My class diagram"`) to open it by name, or omit to refresh the current diagram. The opened diagram becomes current.
|
|
138
|
+
- **`create_node`** and **`create_link`** – Use the **current diagram** automatically (the one you just created or opened). For links, use **node names** for `from` and `to` (e.g. `"User"`, `"Account"`); the server resolves them. No diagram or node UUIDs needed.
|
|
139
|
+
- **`update_node`** / **`delete_node`** – Refer to nodes by **name** (e.g. `"User"`). **`update_link`** / **`delete_link`** need `link_id` from the response when you created the link or from `open_diagram`.
|
|
130
140
|
|
|
131
141
|
## Step 6: Verify Connection
|
|
132
142
|
|
|
133
143
|
Test the connection by using MCP tools in Cursor:
|
|
134
144
|
|
|
135
145
|
- `health_check` - Check MCP server status
|
|
136
|
-
- `
|
|
137
|
-
- `
|
|
146
|
+
- `check_backend_health` - Check backend API status
|
|
147
|
+
- `list_diagrams` - List your diagrams (uses your session; no arguments needed)
|
|
138
148
|
|
|
139
149
|
## Troubleshooting
|
|
140
150
|
|
|
@@ -161,7 +171,7 @@ Test the connection by using MCP tools in Cursor:
|
|
|
161
171
|
curl http://localhost:8000/healthz
|
|
162
172
|
```
|
|
163
173
|
|
|
164
|
-
2. **Token expired**: If your token expires (after 7 days), restart the device flow by calling `
|
|
174
|
+
2. **Token expired**: If your token expires (after 7 days), restart the device flow by calling `sign_in` again
|
|
165
175
|
|
|
166
176
|
3. **User code expired**: Device codes expire after 10 minutes. Start a new flow if needed
|
|
167
177
|
|
|
@@ -220,11 +230,11 @@ This means the server wasn't built with the latest code. **Solution**:
|
|
|
220
230
|
|
|
221
231
|
Once connected, you can use these tools in Cursor/Copilot:
|
|
222
232
|
|
|
223
|
-
- **Authentication**: `
|
|
224
|
-
- **Health**: `health_check`, `
|
|
225
|
-
- **Diagrams**: `
|
|
226
|
-
- **Nodes**: `
|
|
227
|
-
- **Links**: `
|
|
233
|
+
- **Authentication**: `sign_in` (required), `poll_auth_token` (optional/advanced)
|
|
234
|
+
- **Health**: `health_check`, `check_backend_health`
|
|
235
|
+
- **Diagrams**: `create_diagram`, `open_diagram`, `list_diagrams`
|
|
236
|
+
- **Nodes**: `create_node`, `update_node`, `verify_node`, `delete_node`
|
|
237
|
+
- **Links**: `create_link`, `update_link`, `verify_link`, `delete_link`
|
|
228
238
|
|
|
229
239
|
## Development Mode
|
|
230
240
|
|
package/README.md
CHANGED
|
@@ -126,7 +126,7 @@ You can omit the `env` block to use the built-in defaults (production Planform A
|
|
|
126
126
|
|
|
127
127
|
The server loads `.env` only from the **package directory** (next to the executable), not from your workspace, so your project’s `.env` does not override the default (production) backend URL.
|
|
128
128
|
|
|
129
|
-
**First use:** When you use the MCP, the `
|
|
129
|
+
**First use:** When you use the MCP, the `sign_in` tool will give you a link and code to sign in at [planform.io](https://www.planform.io) and authorize the connection. The access token is stored on disk (`~/.planform/mcp-token.json`) so it persists across tool calls even if the MCP server is restarted each time.
|
|
130
130
|
|
|
131
131
|
## VS Code Integration
|
|
132
132
|
|
|
@@ -134,54 +134,42 @@ To use this MCP server with VS Code (with an MCP extension):
|
|
|
134
134
|
|
|
135
135
|
1. Add the server configuration to your MCP settings (same structure as above, under the key your extension expects, e.g. `mcp.servers`).
|
|
136
136
|
2. The server runs via stdio transport.
|
|
137
|
-
3.
|
|
137
|
+
3. Call `sign_in` once to authenticate; the server then remembers your session and current diagram—no IDs to pass to other tools.
|
|
138
138
|
|
|
139
139
|
## Available Tools
|
|
140
140
|
|
|
141
|
-
|
|
142
|
-
Check the health status of the Planform MCP server.
|
|
141
|
+
Tools are listed in recommended flow order: authenticate first, then diagrams, then nodes, then links. All use verb_noun names; the server handles session and current diagram—no UUIDs to pass.
|
|
143
142
|
|
|
144
|
-
###
|
|
145
|
-
Start device code flow for MCP authentication. Returns device_code, user_code, and verification URLs.
|
|
143
|
+
### Discovery and health
|
|
146
144
|
|
|
147
|
-
|
|
148
|
-
|
|
145
|
+
- **`health_check`** – Check the health status of the Planform MCP server.
|
|
146
|
+
- **`get_usage_guide`** – Get step-by-step instructions and recommended flow. Call when unsure how to use the server.
|
|
147
|
+
- **`check_backend_health`** – Check the health status of the Planform backend API.
|
|
149
148
|
|
|
150
|
-
###
|
|
151
|
-
Check the health status of the Planform backend API.
|
|
149
|
+
### Authentication (required first)
|
|
152
150
|
|
|
153
|
-
|
|
154
|
-
|
|
151
|
+
- **`sign_in`** – **Call this first**. Opens browser for you to approve; the server remembers your session. No IDs to pass to other tools.
|
|
152
|
+
- **`poll_auth_token`** (optional/advanced) – Manually poll for auth token after user approves. Usually not needed since `sign_in` polls automatically.
|
|
155
153
|
|
|
156
|
-
###
|
|
157
|
-
Fetch full diagram (nodes + links) to mirror state locally.
|
|
154
|
+
### Diagrams
|
|
158
155
|
|
|
159
|
-
|
|
160
|
-
|
|
156
|
+
- **`list_diagrams`** – List your diagrams. Uses your session; no arguments required (optional: status, page, page_size).
|
|
157
|
+
- **`create_diagram`** – Create a new diagram (title, type). Becomes the current diagram for node/link tools.
|
|
158
|
+
- **`open_diagram`** – Open a diagram by title or ID; omit to refresh the current diagram. Opened diagram becomes current.
|
|
161
159
|
|
|
162
|
-
###
|
|
163
|
-
Create UML node with immutable grid placement.
|
|
160
|
+
### Nodes
|
|
164
161
|
|
|
165
|
-
|
|
166
|
-
Update
|
|
162
|
+
- **`create_node`** – Add a node (class, interface, enum) to the current diagram. Refer to nodes by name elsewhere.
|
|
163
|
+
- **`update_node`** – Update a node's fields, methods, or name. Use node name (e.g. "User"); uses current diagram.
|
|
164
|
+
- **`verify_node`** – Mark a node as verified. Use node name.
|
|
165
|
+
- **`delete_node`** – Delete a node. Use node name.
|
|
167
166
|
|
|
168
|
-
###
|
|
169
|
-
Mark a node as verified by MCP after confirming structure in code.
|
|
167
|
+
### Links
|
|
170
168
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
Create link between nodes (never moves nodes).
|
|
176
|
-
|
|
177
|
-
### `link_update`
|
|
178
|
-
Update link fields (MCP authoritative).
|
|
179
|
-
|
|
180
|
-
### `link_verify`
|
|
181
|
-
Mark a link as verified by MCP after confirming relationship in code.
|
|
182
|
-
|
|
183
|
-
### `link_delete`
|
|
184
|
-
Delete link with status-based logic.
|
|
169
|
+
- **`create_link`** – Create a link between two nodes. Use **node names** for `from` and `to` (e.g. "User", "Account"); server resolves them.
|
|
170
|
+
- **`update_link`** – Update a link's label, direction, etc. Use `link_id` from `create_link` or `open_diagram` response.
|
|
171
|
+
- **`verify_link`** – Mark a link as verified. Use `link_id` from response.
|
|
172
|
+
- **`delete_link`** – Delete a link. Use `link_id` from response.
|
|
185
173
|
|
|
186
174
|
## Architecture
|
|
187
175
|
|
|
@@ -191,12 +179,12 @@ The server is built with:
|
|
|
191
179
|
- **Axios**: HTTP client for API communication
|
|
192
180
|
- **Modular Design**: Separate concerns for server, API client, and logging
|
|
193
181
|
|
|
194
|
-
## Development
|
|
182
|
+
## Development Roadmap
|
|
195
183
|
|
|
196
184
|
This implements steps D22, D23, and D24 of the Planform implementation plan. Completed:
|
|
197
185
|
- ✅ D22: Scaffold minimal MCP server (Node.js + MCP SDK)
|
|
198
|
-
- ✅ D23: Implement
|
|
199
|
-
- ✅ D24: Implement
|
|
186
|
+
- ✅ D23: Implement create_diagram, list_diagrams, open_diagram tools
|
|
187
|
+
- ✅ D24: Implement create_node, create_link tools with full CRUD operations
|
|
200
188
|
|
|
201
189
|
Future steps will add:
|
|
202
190
|
- D25: Diagram rearrangement capabilities
|
package/dist/server.d.ts
CHANGED
|
@@ -4,7 +4,19 @@ export declare class PlanformMCPServer {
|
|
|
4
4
|
private apiClient;
|
|
5
5
|
private logger;
|
|
6
6
|
private activePolling;
|
|
7
|
+
/** Set after successful sign_in; used for list_diagrams and create_diagram so callers need not pass user_uuid */
|
|
8
|
+
private sessionUserUuid;
|
|
9
|
+
/** Set after create_diagram or open_diagram; used for node/link tools so callers need not pass diagram_uuid */
|
|
10
|
+
private currentDiagramUuid;
|
|
7
11
|
constructor();
|
|
12
|
+
/**
|
|
13
|
+
* Load token and user UUID from disk and apply to apiClient and sessionUserUuid.
|
|
14
|
+
* Call at server init and at the start of each tool call so auth persists across process restarts.
|
|
15
|
+
* If user_uuid is missing from storage, we try to read it from the JWT "sub" claim (many backends put user id there).
|
|
16
|
+
*/
|
|
17
|
+
private restoreSessionFromDisk;
|
|
18
|
+
/** Decode JWT payload and return "sub" claim if present (no signature verification). */
|
|
19
|
+
private decodeJwtSub;
|
|
8
20
|
private setupHandlers;
|
|
9
21
|
private handleHealthCheck;
|
|
10
22
|
private handleGetUsageExamples;
|
|
@@ -14,6 +26,19 @@ export declare class PlanformMCPServer {
|
|
|
14
26
|
* Returns a promise that resolves when polling completes
|
|
15
27
|
*/
|
|
16
28
|
private pollUntilApproved;
|
|
29
|
+
/**
|
|
30
|
+
* Returns the current diagram data (nodes, links, etc.). Throws if no diagram is selected.
|
|
31
|
+
* Used to resolve node names to uuids/labels under the hood.
|
|
32
|
+
*/
|
|
33
|
+
private getCurrentDiagramData;
|
|
34
|
+
/**
|
|
35
|
+
* Resolve node_identifier (name or UUID) to node UUID using the current diagram.
|
|
36
|
+
*/
|
|
37
|
+
private resolveNodeToUuid;
|
|
38
|
+
/**
|
|
39
|
+
* Resolve node reference (name or label like n-1) to node label for create_link.
|
|
40
|
+
*/
|
|
41
|
+
private resolveNodeToLabel;
|
|
17
42
|
/**
|
|
18
43
|
* Start automatic background polling for device token (kept for backward compatibility)
|
|
19
44
|
* @deprecated Use pollUntilApproved for synchronous polling
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAmBjF,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,aAAa,CAA0C;IAC/D,iHAAiH;IACjH,OAAO,CAAC,eAAe,CAAuB;IAC9C,+GAA+G;IAC/G,OAAO,CAAC,kBAAkB,CAAuB;;IAuBjD;;;;OAIG;IACH,OAAO,CAAC,sBAAsB;IAY9B,wFAAwF;IACxF,OAAO,CAAC,YAAY;IAapB,OAAO,CAAC,aAAa;YAsZP,iBAAiB;YAoBjB,sBAAsB;YAatB,iBAAiB;IAqG/B;;;OAGG;YACW,iBAAiB;IA2E/B;;;OAGG;YACW,qBAAqB;IAanC;;OAEG;YACW,iBAAiB;IAiB/B;;OAEG;YACW,kBAAkB;IAiBhC;;;OAGG;IACH,OAAO,CAAC,qBAAqB;YAmEf,qBAAqB;YAyBrB,wBAAwB;YAqBxB,mBAAmB;YA6CnB,gBAAgB;YA2DhB,kBAAkB;YA4ClB,iBAAiB;YA8CjB,gBAAgB;YAoChB,gBAAgB;YAiChB,gBAAgB;YA8BhB,iBAAiB;YAoDjB,gBAAgB;YA+BhB,gBAAgB;YA4BhB,gBAAgB;IA4BxB,KAAK,CAAC,SAAS,EAAE,oBAAoB;CAI5C"}
|