flowpad-mcp 0.1.2 → 0.2.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.
package/README.md CHANGED
@@ -1,110 +1,91 @@
1
1
  # flowpad-mcp
2
2
 
3
- An [MCP](https://modelcontextprotocol.io) server that lets an external AI
4
- (Claude Desktop, Cursor, Claude Code) work with Flowpad: find a project, inspect
5
- and analyze its canvas, and edit nodes — all through flowpad-be's dedicated
6
- `/mcp/*` endpoints.
3
+ Flowpad's [MCP](https://modelcontextprotocol.io) integration. One repo, **two
4
+ servers** for two different jobs:
5
+
6
+ | | **B — Hosted connector** (main) | **A — Local validator** (this npm package) |
7
+ | ------------------------ | ------------------------------------ | ------------------------------------------------------ |
8
+ | Transport | Streamable HTTP at a URL | stdio via `npx flowpad-mcp` |
9
+ | Auth | OAuth sign-in (or an `fp_live_` key) | **none — keyless** |
10
+ | Canvas read/write (CRUD) | ✅ yes | ❌ never |
11
+ | Talks to flowpad-be | ✅ (per-user, authed) | ❌ (except one anonymous version check) |
12
+ | Tools | full toolset | `describe_engine`, `validate_design`, `preview_layout` |
13
+
14
+ **Connect Claude to the hosted connector** to actually read and edit your canvas
15
+ (Flowpad → **Settings → Integrations**). The **local validator** is an optional
16
+ enhancer you add alongside it: it carries Flowpad's real layout engine
17
+ (`flowpad-core`) on your machine so the AI can validate and preview a design
18
+ locally — instantly, free, offline — before it writes anything through the
19
+ connector. Fewer wrong edits, fewer round-trips.
7
20
 
8
- ## How it works
9
-
10
- ```
11
- Claude Desktop / Cursor / CLI ──MCP──▶ flowpad-mcp ──HTTP /mcp/*──▶ flowpad-be
12
- (the AI / brain) (this relay) (your backend)
13
21
  ```
14
-
15
- This server is a thin relay. All canvas logic lives behind flowpad-be's
16
- `/mcp/*` facade: retrieval (outline/search/node) and analysis are computed
17
- server-side and returned as compact text, so the model's context stays bounded
18
- no matter how large the canvas is. Edits are saved via `PUT /mcp/projects/:id`
19
- with optimistic-concurrency `baseRevision`; AI-driven edits are delegated to the
20
- in-app AI (`POST /mcp/chat/message`), which computes node ids, bounds and layout.
21
-
22
- **Auth:** same user-auth (JWT) as the app, with its own entry point. Generate a
23
- per-user key from Flowpad (**Settings → Integrations**) and set it as
24
- `FLOWPAD_API_KEY` (looks like `fp_live_…`). The server exchanges it at
25
- `POST /mcp/auth/login` for a standard, expiring user JWT, then sends that as a
26
- Bearer token (re-logging in on expiry). flowpad-be resolves the key to your own
27
- account, so the agent acts as you. No account password lives in agent config; a
28
- key is revocable any time from the same screen.
29
-
30
- ## Tools
31
-
32
- **Agentic tools** — let an external agent (Cursor / Claude / Antigravity) work on
33
- an arbitrarily large canvas the way it works on a big repo: navigate with cheap
34
- retrieval, read only what's relevant, make targeted edits. The MCP fetches the
35
- node list once (cached by revision) and returns only compact slices, so the
36
- model's context stays bounded no matter how big the project grows.
37
-
38
- | Tool | Repo analogy | Purpose |
39
- | ----------------- | ------------ | ----------------------------------------------------------------------------------- |
40
- | `get_outline` | `ls -R` | Depth-limited tree: ids, types, names, child counts. |
41
- | `search_nodes` | `grep` | Find nodes by name/description/type/parent (paginated). |
42
- | `get_node` | `cat` | One node's fields + subtree to a depth. |
43
- | `analyze_project` | lint | Canvas stats (counts, depth) + deterministic layout-overflow warnings. |
44
- | `apply_edit` | edit | Targeted add/update/remove in one diff (OCC; conflicts surface, never force-write). |
45
-
46
- **Convenience tools**
47
-
48
- | Tool | Purpose |
49
- | ----------------- | -------------------------------------------------------- |
50
- | `list_projects` | List / search projects (id + name). |
51
- | `get_project` | Show a project's revision and node summary. |
52
- | `ai_edit_project` | One-shot natural-language edit → in-app AI → saved diff. |
53
- | `add_node` | Deterministic single-node add (no AI). |
54
-
55
- ## Setup
56
-
57
- No install needed — the config snippets below run the server via
58
- `npx -y @flowpad/mcp`. Just generate a key from **Settings → Integrations** and
59
- paste the snippet into your MCP host.
60
-
61
- For local development of this server:
62
-
63
- ```bash
64
- cd flowpad-mcp
65
- npm install
66
- npm run build
67
- cp .env.example .env # set FLOWPAD_API_URL + FLOWPAD_API_KEY
22
+ ┌─ A: npx flowpad-mcp (local) ── flowpad-core engine, on your machine
23
+ Claude / Cursor ─┤ validate · preview · describe (keyless, no canvas access)
24
+ └─ B: hosted URL connector ──HTTP──▶ flowpad-be (auth + canvas CRUD)
68
25
  ```
69
26
 
70
- ## Try it (local)
71
-
72
- 1. Run flowpad-be locally (`yarn start:dev`, port 8080).
73
- 2. `npm run inspect` — opens the MCP Inspector. Call `list_projects`, then
74
- `analyze_project`, then `ai_edit_project`.
75
-
76
- ## Use it in a client
27
+ ## A the local validator (this package)
77
28
 
78
- The **same** stdio server works in all three. Pass env vars in the config.
79
- Point `FLOWPAD_API_URL` at your backend (`https://api.getflowpad.com` for the
80
- hosted app, or `http://localhost:8080` for local).
29
+ Keyless. It never touches your account; it only runs the engine locally. Add it
30
+ next to the hosted connector in your MCP host:
81
31
 
82
- ### Claude Desktop — `claude_desktop_config.json`
32
+ ### Claude Desktop — `claude_desktop_config.json` / Cursor — `.cursor/mcp.json`
83
33
 
84
34
  ```json
85
35
  {
86
36
  "mcpServers": {
87
- "flowpad": {
37
+ "flowpad-local": {
88
38
  "command": "npx",
89
- "args": ["-y", "@flowpad/mcp"],
90
- "env": {
91
- "FLOWPAD_API_URL": "https://api.getflowpad.com",
92
- "FLOWPAD_API_KEY": "fp_live_..."
93
- }
39
+ "args": ["-y", "flowpad-mcp"]
94
40
  }
95
41
  }
96
42
  }
97
43
  ```
98
44
 
99
- ### Cursor `.cursor/mcp.json` (project) or global MCP settings
45
+ ### Claude Code (CLI)
46
+
47
+ ```bash
48
+ claude mcp add flowpad-local -- npx -y flowpad-mcp
49
+ ```
50
+
51
+ That's it — no key, no URL. (Advanced: set `FLOWPAD_API_URL` to point its
52
+ best-effort "is my tool up to date?" check at a non-prod backend.)
100
53
 
101
- Same `mcpServers` block as above.
54
+ **Tools**
102
55
 
103
- ### Claude Code (CLI)
56
+ | Tool | Purpose |
57
+ | ----------------- | ------------------------------------------------------------------------------------------------------------------ |
58
+ | `describe_engine` | The exact node types, layout values and limits to design within. |
59
+ | `validate_design` | Run the SAME engine rules the backend enforces on a planned diff — catch a malformed node/edge before you send it. |
60
+ | `preview_layout` | Compute where an auto-layout container's children land + flag overflow, before you write. |
61
+
62
+ All three run entirely on the bundled `flowpad-core` (no network), so a passing
63
+ `validate_design` means the backend won't reject the shape.
64
+
65
+ ## B — the hosted connector
66
+
67
+ The channel that actually reads and writes the canvas, behind per-user auth. It
68
+ runs the full toolset (retrieval, analysis, CRUD, templates, tasks) plus the same
69
+ three local engine tools. Served over Streamable HTTP from `src/index.ts` →
70
+ `src/http.ts`; deployed (not published to npm). Get its URL and sign in from
71
+ Flowpad → **Settings → Integrations**.
72
+
73
+ ## Development
104
74
 
105
75
  ```bash
106
- claude mcp add flowpad \
107
- --env FLOWPAD_API_URL=https://api.getflowpad.com \
108
- --env FLOWPAD_API_KEY=fp_live_... \
109
- -- npx -y @flowpad/mcp
76
+ cd flowpad-mcp
77
+ yarn install
78
+ yarn dev # A: the local stdio validator (src/local-index.ts)
79
+ yarn dev:http # B: the hosted HTTP server (src/index.ts)
80
+ yarn inspect # open the MCP Inspector against A
81
+ yarn validate # tsc + eslint + prettier + tool-parity + version-sync
110
82
  ```
83
+
84
+ - **A** entry: `src/local-index.ts` → `createLocalServer` (`src/local-server.ts`),
85
+ which registers `src/local-tools.ts`. Published as the bundled bin `dist/local.js`
86
+ (esbuild inlines `flowpad-core`, so the npx tool installs nothing).
87
+ - **B** entry: `src/index.ts` → `startHttpServer` (`src/http.ts`) →
88
+ `createServer` (`src/server.ts`), which folds in the same `local-tools.ts` trio.
89
+ - The MCP tool surface is mirrored from flowpad-be's tool catalog
90
+ (`src/generated/tool-catalog.json`); `scripts/check-tool-parity.ts` asserts both
91
+ the full (B) and local (A) surfaces against it.