@shirbarzur/planform-mcp-server 1.0.1

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.
@@ -0,0 +1,31 @@
1
+ # Publish to npm when a version tag is pushed.
2
+ # Set up the Trusted Publisher on npm (package → Code → Trusted Publisher):
3
+ # Organization or user: your GitHub org or username (e.g. ShirBarZur)
4
+ # Repository: planform-mcp
5
+ # Workflow filename: publish.yml
6
+
7
+ name: Publish to npm
8
+
9
+ on:
10
+ push:
11
+ tags:
12
+ - 'v*'
13
+
14
+ permissions:
15
+ id-token: write # Required for npm OIDC trusted publishing
16
+ contents: read
17
+
18
+ jobs:
19
+ publish:
20
+ runs-on: ubuntu-latest
21
+ steps:
22
+ - uses: actions/checkout@v4
23
+
24
+ - uses: actions/setup-node@v4
25
+ with:
26
+ node-version: '20'
27
+ registry-url: 'https://registry.npmjs.org'
28
+
29
+ - run: npm ci
30
+ - run: npm run build
31
+ - run: npm publish --access public --provenance
@@ -0,0 +1 @@
1
+ ghu_Ga2cE4Cz4yPBSg7GxI1a6dTrv9MyX40uxRYp
@@ -0,0 +1 @@
1
+ {"token":"eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJtY3AtcmVnaXN0cnkiLCJleHAiOjE3NzE3MDEzMDgsIm5iZiI6MTc3MTcwMTAwOCwiaWF0IjoxNzcxNzAxMDA4LCJhdXRoX21ldGhvZCI6ImdpdGh1Yi1hdCIsImF1dGhfbWV0aG9kX3N1YiI6IlNoaXJCYXJadXIiLCJwZXJtaXNzaW9ucyI6W3siYWN0aW9uIjoicHVibGlzaCIsInJlc291cmNlIjoiaW8uZ2l0aHViLlNoaXJCYXJadXIvKiJ9XX0.vl5OH8FXtLLkVLIZOPnKJV_CIliDhwKp3JJ-H2nNqQ0BbVlMHKEiFljipIh09ZSzu09uYi6Gbo-nTzATQO2aAQ","expires_at":1771701308}
@@ -0,0 +1,263 @@
1
+ # Quick Guide: Connecting Planform MCP to Cursor/Copilot
2
+
3
+ This guide will help you connect your local Planform MCP server to Cursor or GitHub Copilot.
4
+
5
+ ## Prerequisites
6
+
7
+ - Node.js 18+ installed
8
+ - Cursor IDE or VS Code with MCP support
9
+ - Planform backend API running (default: `http://localhost:8000`)
10
+
11
+ ## Step 1: Build the MCP Server
12
+
13
+ First, ensure the MCP server is built:
14
+
15
+ ```bash
16
+ npm install
17
+ npm run build
18
+ ```
19
+
20
+ ## Step 2: Configure Environment Variables
21
+
22
+ Create a `.env` file in the project root (copy from `env.example`):
23
+
24
+ ```bash
25
+ cp env.example .env
26
+ ```
27
+
28
+ Edit `.env` with your configuration:
29
+ ```env
30
+ BACKEND_BASE_URL=http://localhost:8000
31
+ MCP_SERVER_NAME=planform-mcp
32
+ MCP_SERVER_VERSION=1.0.0
33
+ LOG_LEVEL=info
34
+
35
+ # Optional: Override verification URI if backend returns wrong port/URL
36
+ # If backend returns http://localhost:3000/activate but you need a different port:
37
+ # FRONTEND_BASE_URL=http://localhost:5173
38
+ ```
39
+
40
+ ## Step 3: Configure Cursor/VS Code
41
+
42
+ ### For Cursor
43
+
44
+ 1. Open Cursor Settings (Ctrl+, or Cmd+,)
45
+ 2. Search for "MCP" or navigate to MCP settings
46
+ 3. Add the following configuration to your MCP settings file
47
+
48
+ **Location**: `%APPDATA%\Cursor\User\globalStorage\mcp.json` (Windows) or `~/Library/Application Support/Cursor/User/globalStorage/mcp.json` (Mac) or `~/.config/Cursor/User/globalStorage/mcp.json` (Linux)
49
+
50
+ **Configuration**:
51
+ ```json
52
+ {
53
+ "mcpServers": {
54
+ "planform": {
55
+ "command": "node",
56
+ "args": [
57
+ "C:\\path\\to\\planform-mcp\\dist\\index.js"
58
+ ],
59
+ "env": {
60
+ "BACKEND_BASE_URL": "http://localhost:8000",
61
+ "MCP_SERVER_NAME": "planform-mcp",
62
+ "MCP_SERVER_VERSION": "1.0.0",
63
+ "LOG_LEVEL": "info",
64
+ "FRONTEND_BASE_URL": "http://localhost:5173"
65
+ }
66
+ }
67
+ }
68
+ }
69
+ ```
70
+
71
+ **Note**: If your backend returns a verification URI with the wrong port, add `FRONTEND_BASE_URL` to the `env` section above with your correct frontend URL (replace `5173` with your actual port).
72
+
73
+ **⚠️ IMPORTANT**:
74
+ - **Replace `C:\\path\\to\\planform-mcp\\dist\\index.js`** with your actual absolute path to `dist/index.js`
75
+ - On Windows, you can use forward slashes: `C:/path/to/planform-mcp/dist/index.js`
76
+ - On Mac/Linux, use: `/Users/username/path/to/planform-mcp/dist/index.js`
77
+
78
+ **To find your path:**
79
+ 1. Navigate to your project folder in File Explorer (Windows) or Finder (Mac)
80
+ 2. Go into the `dist` folder
81
+ 3. Right-click on `index.js` → Properties → Copy the full path
82
+ 4. Use forward slashes or double backslashes for Windows paths
83
+
84
+ ### For VS Code with MCP Extension
85
+
86
+ If using VS Code with an MCP extension, add similar configuration:
87
+
88
+ ```json
89
+ {
90
+ "mcp.servers": {
91
+ "planform": {
92
+ "command": "node",
93
+ "args": ["C:/path/to/planform-mcp/dist/index.js"],
94
+ "env": {
95
+ "BACKEND_BASE_URL": "http://localhost:8000"
96
+ }
97
+ }
98
+ }
99
+ }
100
+ ```
101
+
102
+ **Replace the path** with your actual absolute path to `dist/index.js`.
103
+
104
+ ## Step 4: Restart Cursor/VS Code
105
+
106
+ After adding the configuration, restart Cursor or VS Code to load the MCP server.
107
+
108
+ ## Step 5: Authenticate (Device Flow)
109
+
110
+ The MCP server uses device code authentication. When you first use the MCP tools:
111
+
112
+ 1. **Start Device Flow**: Use the `device_start` tool in Cursor/Copilot
113
+ - This will return a `user_code` (e.g., "ABCD-EFGH") and `verification_uri`
114
+ - **The browser will automatically open** with the verification page
115
+
116
+ 2. **Approve in Browser**:
117
+ - The browser should open automatically with the verification page
118
+ - If it doesn't open automatically, manually open the `verification_uri` from the response
119
+ - Log in with Firebase (if required)
120
+ - Enter the `user_code` when prompted (it may be pre-filled if using `verification_uri_complete`)
121
+ - Click "Allow" to authorize the MCP server
122
+
123
+ 3. **Automatic Token Polling**:
124
+ - The MCP server **automatically polls and waits** for your approval (up to 2 minutes by default)
125
+ - It will poll every few seconds until you approve, deny, or the max wait time is reached
126
+ - Once you approve in the browser, the token will be received automatically
127
+ - You'll see log messages indicating polling status
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
130
+
131
+ ## Step 6: Verify Connection
132
+
133
+ Test the connection by using MCP tools in Cursor:
134
+
135
+ - `health_check` - Check MCP server status
136
+ - `backend_health_check` - Check backend API status
137
+ - `diagrams_list` - List your diagrams (requires authentication)
138
+
139
+ ## Troubleshooting
140
+
141
+ ### Server Not Starting
142
+
143
+ 1. **Check Node.js version**: Ensure Node.js 18+ is installed
144
+ ```bash
145
+ node --version
146
+ ```
147
+
148
+ 2. **Verify build**: Make sure the server is built
149
+ ```bash
150
+ npm run build
151
+ ```
152
+
153
+ 3. **Check file path**: Ensure the absolute path in your MCP config is correct
154
+
155
+ 4. **Check logs**: Look for error messages in Cursor's output panel or terminal
156
+
157
+ ### Authentication Issues
158
+
159
+ 1. **Backend not running**: Ensure your Planform backend is running on the configured URL
160
+ ```bash
161
+ curl http://localhost:8000/healthz
162
+ ```
163
+
164
+ 2. **Token expired**: If your token expires (after 7 days), restart the device flow by calling `device_start` again
165
+
166
+ 3. **User code expired**: Device codes expire after 10 minutes. Start a new flow if needed
167
+
168
+ 4. **Wrong verification URI port**: If the backend returns a verification URI with the wrong port (e.g., `http://localhost:3000/activate` but you need port 5173), add `FRONTEND_BASE_URL` to your MCP configuration's `env` section in `mcp.json`:
169
+ ```json
170
+ "env": {
171
+ "BACKEND_BASE_URL": "http://localhost:8000",
172
+ "FRONTEND_BASE_URL": "http://localhost:5173"
173
+ }
174
+ ```
175
+ Then restart Cursor (no rebuild needed - the code already supports this).
176
+
177
+ ### Path Errors
178
+
179
+ **MODULE_NOT_FOUND or ENOENT errors** usually mean:
180
+ 1. The path in your config is incorrect or uses a placeholder
181
+ 2. You're using `npm start` instead of the direct `node` command
182
+
183
+ **Solution**: Use the direct `node` command with your actual absolute path:
184
+
185
+ ```json
186
+ {
187
+ "mcpServers": {
188
+ "planform": {
189
+ "command": "node",
190
+ "args": ["C:/path/to/planform-mcp/dist/index.js"],
191
+ "env": {
192
+ "BACKEND_BASE_URL": "http://localhost:8000"
193
+ }
194
+ }
195
+ }
196
+ }
197
+ ```
198
+
199
+ **Path format tips:**
200
+ - Windows: Use forward slashes `C:/path/to/file.js` or double backslashes `C:\\path\\to\\file.js`
201
+ - Mac/Linux: Use forward slashes `/Users/username/path/to/file.js`
202
+ - Always use the absolute path, not a relative path
203
+
204
+ ### "Server does not support tools" Error
205
+
206
+ If you see:
207
+ ```
208
+ Error: Server does not support tools (required for tools/list)
209
+ ```
210
+
211
+ This means the server wasn't built with the latest code. **Solution**:
212
+
213
+ 1. Rebuild the server:
214
+ ```bash
215
+ npm run build
216
+ ```
217
+ 2. Restart Cursor/VS Code
218
+
219
+ ## Available MCP Tools
220
+
221
+ Once connected, you can use these tools in Cursor/Copilot:
222
+
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`
228
+
229
+ ## Development Mode
230
+
231
+ For development with hot reload:
232
+
233
+ ```bash
234
+ npm run dev
235
+ ```
236
+
237
+ Then update your MCP config to use `tsx` instead of `node`:
238
+
239
+ ```json
240
+ {
241
+ "mcpServers": {
242
+ "planform": {
243
+ "command": "npx",
244
+ "args": ["tsx", "C:/path/to/planform-mcp/src/index.ts"],
245
+ "env": {
246
+ "BACKEND_BASE_URL": "http://localhost:8000"
247
+ }
248
+ }
249
+ }
250
+ }
251
+ ```
252
+
253
+ **Replace the path** with your actual absolute path to `src/index.ts`.
254
+
255
+ ## Next Steps
256
+
257
+ - Create diagrams using `diagram_create`
258
+ - Add UML nodes from your codebase using `nodes_create`
259
+ - Link nodes together using `links_create`
260
+ - Verify code matches diagrams using `node_verify` and `link_verify`
261
+
262
+ For more details, see the main [README.md](README.md).
263
+
package/README.md ADDED
@@ -0,0 +1,210 @@
1
+ # Planform MCP Server
2
+
3
+ A Model Context Protocol (MCP) server for Planform diagram management. This server allows VS Code, Cursor, and other MCP-compatible clients to interact with the Planform backend API for creating and managing UML diagrams.
4
+
5
+ ## Features
6
+
7
+ - **Device Code Authentication**: Secure OAuth-like flow for MCP authentication
8
+ - **Health Monitoring**: Built-in health check endpoint
9
+ - **Extensible Architecture**: Ready for additional diagram management tools
10
+
11
+ ## Prerequisites
12
+
13
+ - Node.js 18+
14
+ - npm or yarn
15
+ - Access to Planform backend API
16
+
17
+ ## Installation
18
+
19
+ 1. Clone the repository:
20
+ ```bash
21
+ git clone <repository-url>
22
+ cd planform-mcp
23
+ ```
24
+
25
+ 2. Install dependencies:
26
+ ```bash
27
+ npm install
28
+ ```
29
+
30
+ 3. Set up environment variables:
31
+ ```bash
32
+ cp env.example .env
33
+ ```
34
+
35
+ Edit `.env` with your configuration:
36
+ ```env
37
+ BACKEND_BASE_URL=https://www.planform.io/api
38
+ MCP_SERVER_NAME=planform-mcp
39
+ MCP_SERVER_VERSION=1.0.0
40
+ LOG_LEVEL=info
41
+ ```
42
+
43
+ ## Development
44
+
45
+ Build the TypeScript code:
46
+ ```bash
47
+ npm run build
48
+ ```
49
+
50
+ Run in development mode with hot reload:
51
+ ```bash
52
+ npm run dev
53
+ ```
54
+
55
+ Run in watch mode:
56
+ ```bash
57
+ npm run watch
58
+ ```
59
+
60
+ ## Production
61
+
62
+ Build and start the server:
63
+ ```bash
64
+ npm run build
65
+ npm start
66
+ ```
67
+
68
+ ## VS Code Integration
69
+
70
+ To use this MCP server with VS Code or Cursor:
71
+
72
+ 1. Add the server configuration to your MCP settings
73
+ 2. The server will be available via stdio transport
74
+ 3. Use the device flow authentication to get access tokens
75
+
76
+ ## Available Tools
77
+
78
+ ### `health_check`
79
+ Check the health status of the Planform MCP server.
80
+
81
+ ### `device_start`
82
+ Start device code flow for MCP authentication. Returns device_code, user_code, and verification URLs.
83
+
84
+ ### `device_token_poll` (Optional/Advanced)
85
+ Manually poll for MCP JWT after user approves. Usually not needed since `device_start` polls automatically. Useful for edge cases or debugging.
86
+
87
+ ### `backend_health_check`
88
+ Check the health status of the Planform backend API.
89
+
90
+ ### `diagram_create`
91
+ Create a new diagram (MCP is allowed). Requires user_uuid and title.
92
+
93
+ ### `diagram_get`
94
+ Fetch full diagram (nodes + links) to mirror state locally.
95
+
96
+ ### `diagrams_list`
97
+ List all diagrams of the bound user with pagination support.
98
+
99
+ ### `nodes_create`
100
+ Create UML node with immutable grid placement.
101
+
102
+ ### `node_update`
103
+ Update structural fields (MCP authoritative).
104
+
105
+ ### `node_verify`
106
+ Mark a node as verified by MCP after confirming structure in code.
107
+
108
+ ### `node_delete`
109
+ Delete node with status-based logic.
110
+
111
+ ### `links_create`
112
+ Create link between nodes (never moves nodes).
113
+
114
+ ### `link_update`
115
+ Update link fields (MCP authoritative).
116
+
117
+ ### `link_verify`
118
+ Mark a link as verified by MCP after confirming relationship in code.
119
+
120
+ ### `link_delete`
121
+ Delete link with status-based logic.
122
+
123
+ ## Architecture
124
+
125
+ The server is built with:
126
+ - **TypeScript**: Type-safe development
127
+ - **MCP SDK**: Official Model Context Protocol SDK
128
+ - **Axios**: HTTP client for API communication
129
+ - **Modular Design**: Separate concerns for server, API client, and logging
130
+
131
+ ## Development Roadmahe health stp
132
+
133
+ This implements steps D22, D23, and D24 of the Planform implementation plan. Completed:
134
+ - ✅ D22: Scaffold minimal MCP server (Node.js + MCP SDK)
135
+ - ✅ D23: Implement diagram_create, diagrams_list, diagram_get tools
136
+ - ✅ D24: Implement nodes_create, links_create tools with full CRUD operations
137
+
138
+ Future steps will add:
139
+ - D25: Diagram rearrangement capabilities
140
+ - Full integration with the Planform backend
141
+
142
+ ## Publishing to the MCP Registry
143
+
144
+ To make your MCP server discoverable so others can find and use it in Cursor, VS Code, etc., do the following **once** (in order). If you’ve already registered, use the [When you update the MCP](#when-you-update-the-mcp) section instead.
145
+
146
+ ### 1. Publish to npm
147
+
148
+ The MCP Registry only stores metadata; the actual package is installed from npm.
149
+
150
+ - Create an [npm account](https://www.npmjs.com/signup) if you don’t have one.
151
+ - Log in: `npm login`
152
+ - **Scoped package:** The project is set up as `@shirbarzur/planform-mcp-server` (npm) and `io.github.ShirBarZur/planform-mcp` (MCP Registry). Log in to npm with the account that owns the `shirbarzur` scope, and use GitHub account ShirBarZur for `mcp-publisher login github`.
153
+ - Bump version if needed, then publish:
154
+ ```bash
155
+ npm run build
156
+ npm publish --access public
157
+ ```
158
+ (`--access public` is required for scoped packages so they are installable by everyone.)
159
+ - `package.json` already includes `mcpName` so the registry can verify ownership; it must match the `name` in `server.json`.
160
+
161
+ **Optional – Publish from GitHub (no npm token in repo):** On the package page on npm, go to **Code** → **Trusted Publisher** and set up the connection. Use **Organization or user:** your GitHub username or org (e.g. `ShirBarZur`), **Repository:** `planform-mcp`, **Workflow filename:** `publish.yml`. After that, pushing a version tag (e.g. `v1.0.1`) will trigger `.github/workflows/publish.yml` to build and publish to npm via OIDC.
162
+
163
+ ### 2. Install the MCP Publisher CLI
164
+
165
+ - **macOS/Linux/WSL (Homebrew):** `brew install mcp-publisher`
166
+ - **Windows (PowerShell):** Run in PowerShell from this repo (or any folder where you want the binary):
167
+ ```powershell
168
+ $arch = if ([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture -eq "Arm64") { "arm64" } else { "amd64" }
169
+ Invoke-WebRequest -Uri "https://github.com/modelcontextprotocol/registry/releases/latest/download/mcp-publisher_windows_$arch.tar.gz" -OutFile "mcp-publisher.tar.gz" -UseBasicParsing
170
+ tar xf mcp-publisher.tar.gz mcp-publisher.exe
171
+ Remove-Item mcp-publisher.tar.gz
172
+ ```
173
+ Then move `mcp-publisher.exe` to a folder that’s in your PATH (e.g. create `%USERPROFILE%\bin`, add it to [PATH](https://learn.microsoft.com/en-us/windows/win32/procthread/environment-variables), and move the exe there).
174
+
175
+ ### 3. Authenticate and publish to the MCP Registry
176
+
177
+ `server.json` is already configured in this repo; only edit it when you bump the package version (keep it in sync with `package.json`).
178
+
179
+ - Authenticate (e.g. GitHub): `mcp-publisher login github`
180
+ - Publish: `mcp-publisher publish`
181
+ - Confirm your server appears on the [MCP Registry](https://prod.registry.modelcontextprotocol.io/).
182
+
183
+ After that, users can discover “Planform MCP Server” in the registry and add it to their MCP client (e.g. Cursor) from there.
184
+
185
+ **Note:** The MCP Registry is in preview; behavior and schema may change.
186
+
187
+ ### When you update the MCP
188
+
189
+ **Option A – automated (recommended)**
190
+ From the project root:
191
+
192
+ ```bash
193
+ npm run release # bump patch (1.0.0 -> 1.0.1)
194
+ npm run release:minor # bump minor (1.0.0 -> 1.1.0)
195
+ npm run release:major # bump major (1.0.0 -> 2.0.0)
196
+ ```
197
+
198
+ The script bumps the version in `package.json` and `server.json`, runs `npm run build`, then `npm publish --access public`, then `mcp-publisher publish`. Ensure you're logged in to npm and have run `mcp-publisher login github` at least once.
199
+
200
+ **Option B – manual**
201
+
202
+ 1. **Bump the version** in `package.json` (e.g. `1.0.0` → `1.0.1`).
203
+ 2. Bump the version in `server.json` (top-level `"version"` and `packages[0].version`).
204
+ 3. Run `npm run build`, then `npm publish --access public`, then `mcp-publisher publish`.
205
+
206
+ That’s it. Users get updates by upgrading the package (e.g. `npm update @planform/planform-mcp-server` or reinstalling from the registry).
207
+
208
+ ## License
209
+
210
+ MIT