@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.
@@ -1 +1 @@
1
- ghu_YuVjEsZEU5H77mRApssrqCwO8RHTrg20IR0O
1
+ ghu_qVZZlzCmVSDhuDFh5A3HOIVmkdSZUk3d4nYb
@@ -1 +1 @@
1
- {"token":"eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJtY3AtcmVnaXN0cnkiLCJleHAiOjE3NzE3MDQxMzAsIm5iZiI6MTc3MTcwMzgzMCwiaWF0IjoxNzcxNzAzODMwLCJhdXRoX21ldGhvZCI6ImdpdGh1Yi1hdCIsImF1dGhfbWV0aG9kX3N1YiI6IlNoaXJCYXJadXIiLCJwZXJtaXNzaW9ucyI6W3siYWN0aW9uIjoicHVibGlzaCIsInJlc291cmNlIjoiaW8uZ2l0aHViLlNoaXJCYXJadXIvKiJ9XX0.HGeyUKW2wCkdbtImEDCFQL2NGNCYAR34ruiOqfii50BsUnIGAa4KkDaWv0fS2hOXFaxD3zXyxjeVzaGQEK0HCQ","expires_at":1771704130}
1
+ {"token":"eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJtY3AtcmVnaXN0cnkiLCJleHAiOjE3NzIwODY5MzksIm5iZiI6MTc3MjA4NjYzOSwiaWF0IjoxNzcyMDg2NjM5LCJhdXRoX21ldGhvZCI6ImdpdGh1Yi1hdCIsImF1dGhfbWV0aG9kX3N1YiI6IlNoaXJCYXJadXIiLCJwZXJtaXNzaW9ucyI6W3siYWN0aW9uIjoicHVibGlzaCIsInJlc291cmNlIjoiaW8uZ2l0aHViLlNoaXJCYXJadXIvKiJ9XX0.06x9V-YNUNoTi4TbIuLartAhQ3Q8RvRD-R--r3fCD7ga00EJIZZm1aLJM0g5bLtNYH4m0S_OiBgS6HwhMyD3CQ","expires_at":1772086939}
@@ -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 `device_start` tool in Cursor/Copilot
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**: `device_token_poll` is available as an optional/advanced tool if you need to manually check status, but it's usually not needed
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
- - `backend_health_check` - Check backend API status
137
- - `diagrams_list` - List your diagrams (requires authentication)
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 `device_start` again
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**: `device_start` (required), `device_token_poll` (optional/advanced)
224
- - **Health**: `health_check`, `backend_health_check`
225
- - **Diagrams**: `diagram_create`, `diagram_get`, `diagrams_list`
226
- - **Nodes**: `nodes_create`, `node_update`, `node_verify`, `node_delete`
227
- - **Links**: `links_create`, `link_update`, `link_verify`, `link_delete`
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 `device_start` tool will give you a link and code to sign in at [planform.io](https://www.planform.io) and authorize the connection.
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. Use the device flow authentication to get access tokens.
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
- ### `health_check`
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
- ### `device_start`
145
- Start device code flow for MCP authentication. Returns device_code, user_code, and verification URLs.
143
+ ### Discovery and health
146
144
 
147
- ### `device_token_poll` (Optional/Advanced)
148
- Manually poll for MCP JWT after user approves. Usually not needed since `device_start` polls automatically. Useful for edge cases or debugging.
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
- ### `backend_health_check`
151
- Check the health status of the Planform backend API.
149
+ ### Authentication (required first)
152
150
 
153
- ### `diagram_create`
154
- Create a new diagram (MCP is allowed). Requires user_uuid and title.
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
- ### `diagram_get`
157
- Fetch full diagram (nodes + links) to mirror state locally.
154
+ ### Diagrams
158
155
 
159
- ### `diagrams_list`
160
- List all diagrams of the bound user with pagination support.
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
- ### `nodes_create`
163
- Create UML node with immutable grid placement.
160
+ ### Nodes
164
161
 
165
- ### `node_update`
166
- Update structural fields (MCP authoritative).
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
- ### `node_verify`
169
- Mark a node as verified by MCP after confirming structure in code.
167
+ ### Links
170
168
 
171
- ### `node_delete`
172
- Delete node with status-based logic.
173
-
174
- ### `links_create`
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 Roadmahe health stp
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 diagram_create, diagrams_list, diagram_get tools
199
- - ✅ D24: Implement nodes_create, links_create tools with full CRUD operations
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
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAajF,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,aAAa,CAA0C;;IAsB/D,OAAO,CAAC,aAAa;Y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