@dforge-core/dforge-mcp 0.1.0-rc.3 → 0.1.0-rc.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/README.md CHANGED
@@ -1,26 +1,49 @@
1
1
  # @dforge-core/dforge-mcp
2
2
 
3
- MCP server for dForge module authoring. Exposes scaffold / pack / install
4
- tools and schema resources so AI agents (Claude Code, Cursor, Zed, etc.)
5
- can create and ship dForge modules through structured tool calls instead
6
- of free-form JSON generation.
3
+ MCP server for dForge module authoring. Exposes 18 composable tools and the canonical schemas so AI agents (Claude Code, Cursor, Zed, etc.) can drive the full module lifecycle — scaffold entities actions → views → security → install — through structured tool calls instead of free-form JSON generation.
7
4
 
8
- ## Install
5
+ Ships with a wizard Skill (`skills/dforge-mcp-author/SKILL.md`) that walks the AI through six phases with explicit backtrack support when later phases expose earlier gaps.
6
+
7
+ > **Two GitHub repos to know:** this MCP server lives at `dforge-core/dforge-mcp`. The dForge platform itself (entities, validator, native CLI source) lives at `iash44/dForge-core` — referenced in `homepage` because the schemas + DSL conventions come from there.
8
+
9
+ ## What it depends on at runtime
10
+
11
+ ```
12
+ your AI editor (Claude Code / Cursor / Zed)
13
+
14
+ ▼ stdio JSON-RPC
15
+ @dforge-core/dforge-mcp ← this package; pure JS / TS
16
+
17
+ ▼ shells out for pack / install
18
+ @dforge-core/dforge-cli ← installed as a transitive dep; thin JS wrapper
19
+
20
+ ▼ optionalDependencies
21
+ @dforge-core/dforge-cli-<platform> ← native C# binary per platform (~35 MB)
22
+ ```
23
+
24
+ The native binary actually talks to your tenant. The npm-CLI wrapper is just a launcher that picks the right platform binary and exec's it. **You don't need to install dforge-cli separately** — it comes along when you install dforge-mcp (or when `npx -y @dforge-core/dforge-mcp` runs cold).
25
+
26
+ If you want to use a hand-built native binary instead of the npm-shipped one, point `DFORGE_CLI_BINARY` at the executable file's absolute path:
9
27
 
10
28
  ```bash
11
- # As an MCP server invoked by an AI editor — usually no install needed,
12
- # the editor runs it via npx on demand. See "Wiring it up" below.
29
+ DFORGE_CLI_BINARY=/Users/me/projects/dForge-core/cli/bin/dForge.Cli
30
+ ```
31
+
32
+ (macOS / Linux: no extension. Windows: `dForge.Cli.exe`.) If the path doesn't exist or isn't executable the server reports an error at the first pack/install call.
33
+
34
+ ## Install + wire into Claude Code
13
35
 
14
- # Local install (for development / debugging):
15
- npm install -g @dforge-core/dforge-mcp
16
- dforge-mcp # speaks JSON-RPC over stdio; ctrl+C to quit
36
+ ### Recommended via `claude mcp add` (writes ~/.claude.json for you)
37
+
38
+ ```bash
39
+ claude mcp add dforge --scope user -- npx -y @dforge-core/dforge-mcp
17
40
  ```
18
41
 
19
- ## Wiring it up
42
+ This appends to `~/.claude.json` (the global config — single file in your home dir, no subdirectory). Restart Claude Code; on the first session that activates the server you'll see "Approve MCP server 'dforge'?" — accept it.
20
43
 
21
- ### Claude Code
44
+ ### Manual — per-project
22
45
 
23
- Add to `~/.claude/config.json` (or the project-local `.claude/mcp.json`):
46
+ Write `.mcp.json` at **the repo root** (not under `.claude/`):
24
47
 
25
48
  ```json
26
49
  {
@@ -29,55 +52,133 @@ Add to `~/.claude/config.json` (or the project-local `.claude/mcp.json`):
29
52
  "command": "npx",
30
53
  "args": ["-y", "@dforge-core/dforge-mcp"],
31
54
  "env": {
32
- "DFORGE_CLI_BINARY": "/optional/path/to/dForge.Cli"
55
+ "DFORGE_CLI_BINARY": "/optional/abs/path/to/dForge.Cli"
33
56
  }
34
57
  }
35
58
  }
36
59
  }
37
60
  ```
38
61
 
39
- `DFORGE_CLI_BINARY` is only needed if you want `dforge_module_pack` /
40
- `dforge_module_install` to use a non-published native binary (e.g. a
41
- local C# build). Otherwise the server uses whatever `dforge-cli` is on
42
- PATH (install via `npm install -g @dforge-core/dforge-cli`).
62
+ Restart Claude Code approve on first prompt.
63
+
64
+ ### Verify it's alive
65
+
66
+ ```bash
67
+ claude mcp list
68
+ # Should show: dforge — npx -y @dforge-core/dforge-mcp — connected
69
+ ```
70
+
71
+ Or inside a Claude Code session, type `/mcp` to see all connected servers + their tools. The 18 `dforge_*` tools should be listed.
43
72
 
44
73
  ### Cursor / Zed
45
74
 
46
- Same shape both editors take a `command + args` MCP config. Refer to
47
- their docs for the exact file path.
75
+ Same `command + args` config shape; check their docs for the file location. Verification is via their respective tool listings.
48
76
 
49
77
  ## What it exposes
50
78
 
51
- ### Tools
79
+ ### Tools (18)
80
+
81
+ Grouped by typical phase in the wizard flow. All "return" tools emit `{ summary, files: { '<relPath>': '<contents>' } }`; the client decides whether to write — lets the AI preview diffs with the user before committing.
82
+
83
+ **Module-level**
84
+ | Tool | Behavior |
85
+ |---|---|
86
+ | `dforge_module_create` | New module scaffold |
87
+ | `dforge_module_inspect` | Read current module state. Full structured data is in `files["_inspect.json"]`; `summary` is one-line stats |
88
+ | `dforge_module_pack` | Shells to `dforge-cli module pack`. Returns tarball path + size |
89
+ | `dforge_module_install` | Shells to `dforge-cli module install`. Args: `pathOrTarball`, optional `tenantUrl` / `token` / `tenantCode` — fall back to `DFORGE_URL` / `DFORGE_TOKEN` env. `tenantCode` is an optional `--code` sanity check the server cross-references against the JWT |
90
+
91
+ **Entities (Phase 1)**
92
+ | Tool | Behavior |
93
+ |---|---|
94
+ | `dforge_entity_add` | Add an entity to an existing module |
95
+ | `dforge_entity_field_add` | Patch a single field |
96
+ | `dforge_entity_field_modify` | Replace a field's spec |
97
+ | `dforge_entity_field_remove` | Drop a field (warns about dependents) |
98
+
99
+ **Behavior (Phase 2 — optional)**
100
+ | Tool | Behavior |
101
+ |---|---|
102
+ | `dforge_action_add` | DSL script + `ui/actions.json` entry |
52
103
 
104
+ **Views + reports (Phase 3)**
53
105
  | Tool | Behavior |
54
106
  |---|---|
55
- | `dforge_module_create` | Returns a file map for a new module. Client writes the files. |
56
- | `dforge_entity_add` | Reads an existing module, returns the updated file map (manifest + new entity + regenerated UI/security). |
57
- | `dforge_module_pack` | Shells to `dforge-cli module pack`. Returns tarball path + size. |
58
- | `dforge_module_install` | Shells to `dforge-cli module install`. Returns CLI output. |
59
- | `dforge_dbml_import` | Stub. Returns "not yet implemented" until the underlying CLI command lands. |
107
+ | `dforge_view_add` | Add a data view |
108
+ | `dforge_view_modify` | Replace a view's spec |
109
+ | `dforge_report_add` | Add a report |
110
+ | `dforge_setting_add` | Configurable module-level setting |
60
111
 
61
- The `create` and `entity_add` tools deliberately **return** instead of writing — the LLM previews the file map with the user before commit.
112
+ **Security (Phase 5)**
113
+ | Tool | Behavior |
114
+ |---|---|
115
+ | `dforge_role_add` | Add a role + rights matrix. **Fails if role already exists** — the scaffolder pre-creates `<code>.admin`, so use `role_right_set` to amend it instead |
116
+ | `dforge_role_right_set` | Grant/revoke one right on one object (cheap backtrack) |
117
+ | `dforge_folder_add` | Add a security folder (optional — most modules ship with just root) |
118
+
119
+ **Cross-cutting**
120
+ | Tool | Behavior |
121
+ |---|---|
122
+ | `dforge_dependency_add` | Add a dep on another dForge module |
123
+ | `dforge_dbml_import` | Stub — not implemented yet |
62
124
 
63
- ### Resources
125
+ ### Resources (13)
64
126
 
65
127
  | URI | Content |
66
128
  |---|---|
67
- | `dforge://schema/manifest` | JSON Schema for manifest.json |
68
- | `dforge://schema/entity` | JSON Schema for entity files |
69
- | `dforge://schema/data-view` | JSON Schema for ui/data_views.json |
70
- | `dforge://docs/conventions` | MODULE_CONVENTIONS.md from dForge-core |
129
+ | `dforge://schema/manifest` | manifest.json JSON Schema |
130
+ | `dforge://schema/entity` | entity files |
131
+ | `dforge://schema/data-views` | ui/data_views.json |
132
+ | `dforge://schema/folders` | ui/folders.json |
133
+ | `dforge://schema/menus` | ui/menus.json |
134
+ | `dforge://schema/roles` | security/roles.json |
135
+ | `dforge://schema/jobs` | logic/jobs.json |
136
+ | `dforge://schema/seed-data` | seed-data/*.json |
137
+ | `dforge://schema/reports` | ui/reports.json |
138
+ | `dforge://schema/settings` | settings.json |
139
+ | `dforge://schema/traits` | entity trait codes |
140
+ | `dforge://schema/webhooks` | ui/webhooks.json |
141
+ | `dforge://docs/conventions` | MODULE_CONVENTIONS.md |
142
+
143
+ Schemas + conventions are vendored at build time from `iash44/dForge-core`'s `docs/`. The published npm tarball ships them under `resources/`, and jsdelivr serves them at:
71
144
 
72
- The schemas + conventions doc are vendored at build time from
73
- `dForge-core/docs/`. Refresh with `scripts/vendor-resources.sh`.
145
+ ```
146
+ https://cdn.jsdelivr.net/npm/@dforge-core/dforge-mcp@latest/resources/schemas/<name>.schema.json
147
+ ```
148
+
149
+ **Compatibility:** schemas vendored for this release came from `iash44/dForge-core` `main` as of the publish date stamped in `package.json`. If the platform adds new entity properties / field types after this release, generated modules using those features may validate locally but be rejected at install time. Bump the dforge-mcp version when the platform schemas change materially.
74
150
 
75
- ## Claude Skill
151
+ ## Claude Skill — the wizard
76
152
 
77
- `skills/dforge-mcp-author/SKILL.md` is a Skill file that teaches Claude
78
- how to drive the tools — gather requirements → preview → write → iterate.
79
- Copy it into your `~/.claude/skills/` (or per-project `.claude/skills/`)
80
- to enable.
153
+ `skills/dforge-mcp-author/SKILL.md` teaches Claude how to drive the tools as a six-phase wizard. **It is NOT auto-installed by `npm install` — the Skill file ships in the npm tarball but Claude Code looks for Skills in `~/.claude/skills/`, not in node_modules.** Sync it manually:
154
+
155
+ ```bash
156
+ # from the published npm tarball
157
+ mkdir -p ~/.claude/skills/dforge-mcp-author
158
+ curl -fsSL https://cdn.jsdelivr.net/npm/@dforge-core/dforge-mcp@latest/skills/dforge-mcp-author/SKILL.md \
159
+ -o ~/.claude/skills/dforge-mcp-author/SKILL.md
160
+
161
+ # or from this repo
162
+ mkdir -p ~/.claude/skills/dforge-mcp-author
163
+ curl -fsSL https://raw.githubusercontent.com/dforge-core/dforge-mcp/main/skills/dforge-mcp-author/SKILL.md \
164
+ -o ~/.claude/skills/dforge-mcp-author/SKILL.md
165
+ ```
166
+
167
+ Re-run after every dforge-mcp upgrade — the Skill version isn't checked at runtime, so a stale Skill against new tools will misroute calls.
168
+
169
+ The phases:
170
+
171
+ | Phase | Required? | Tools used |
172
+ |---|---|---|
173
+ | 0. Intake | yes | (brief written manually) |
174
+ | 1. Domain | yes | `module_create`, `entity_add`, `entity_field_*` |
175
+ | 2. Actions | optional | `action_add` |
176
+ | 3. Views + Reports | views yes, reports optional | `view_*`, `report_add`, `setting_add` |
177
+ | 4. Polish (translations, seed) | optional | (file map authored directly) |
178
+ | 5. Security | roles required, folders optional | `role_add`, `role_right_set`, `folder_add` |
179
+ | 6. Verify | yes | `module_pack`, `module_install` |
180
+
181
+ Key principles encoded in the Skill: inspect-before-patch, one-at-a-time, deterministic backtrack on earliest-phase-first rule, tool-failure protocol that distinguishes auth/connectivity from module defects, end-of-session cleanup user-driven.
81
182
 
82
183
  ## For maintainers
83
184
 
@@ -85,15 +186,18 @@ to enable.
85
186
 
86
187
  ```bash
87
188
  pnpm install
88
- pnpm build # tsup → dist/server.js
189
+ pnpm build # tsup → dist/server.js (bundles SDK + zod + dforge-cli/templates)
89
190
  pnpm typecheck # tsc --noEmit
90
- node dist/server.js # smoke-test via stdio JSON-RPC
191
+ node dist/server.js # stdio JSON-RPC pipe a request to smoke-test
91
192
  ```
92
193
 
93
- The `@dforge-core/dforge-cli` dep is currently pinned to a `file:`
94
- sibling path so this repo can be developed alongside `dforge-cli`. Before
95
- publishing, change to a real npm version (`^0.1.0-rc.5` or higher — the
96
- first version that exposes the `templates` subpath export).
194
+ To iterate against an in-tree `dforge-cli`, temporarily pin the dep at the sibling path:
195
+
196
+ ```bash
197
+ sed -i '' 's|"@dforge-core/dforge-cli": "\^0.1.[0-9.]*"|"@dforge-core/dforge-cli": "file:../dforge-cli"|' package.json
198
+ rm -rf node_modules pnpm-lock.yaml && pnpm install
199
+ # Flip back before publish — file: deps don't resolve for npm consumers.
200
+ ```
97
201
 
98
202
  ### Refresh vendored resources
99
203
 
@@ -104,16 +208,34 @@ scripts/vendor-resources.sh # auto-locate ../dForge
104
208
  DFORGE_CORE=/abs/path/to/dForge-core scripts/vendor-resources.sh
105
209
  ```
106
210
 
107
- ### Publishing to npm
211
+ Republish to update jsdelivr-served schemas + the bundled resources.
108
212
 
109
- (Same approach as dforge-cli — `prepublishOnly` runs tsup so the
110
- published tarball gets a fresh `dist/server.js`. No platform binaries to
111
- manage, so a single `npm publish` covers it.)
213
+ ### Publishing
112
214
 
113
215
  ```bash
114
- npm publish --access public --tag next
216
+ scripts/publish.sh 0.1.0-rc.N --tag latest --otp <code>
115
217
  ```
116
218
 
219
+ `prepublishOnly` runs `tsup` so the tarball gets a fresh `dist/server.js`. No platform binaries to manage.
220
+
221
+ **Pre-publish checklist:**
222
+ - [ ] `@dforge-core/dforge-cli` dep is a real version (not `file:...`)
223
+ - [ ] `pnpm typecheck` passes
224
+ - [ ] Smoke test stdio: `tools/list` returns 18 tools
225
+ - [ ] Skill updated for any new/changed tools (it's a SEPARATE artifact; users sync it manually after upgrades)
226
+
227
+ ### Adding a new tool
228
+
229
+ 1. Drop it in `src/tools/<name>.ts`. Use shared helpers from `src/tools/_helpers.ts` (`loadManifest`, `readJsonOrDefault`, `jsonText`, `makeResult`, `withTodayStamp`). Return a `ToolResult`.
230
+ 2. Import + register in `src/server.ts` via the `envelope()` wrapper.
231
+ 3. Mention it in `skills/dforge-mcp-author/SKILL.md` (which phase, which backtrack scenarios use it).
232
+ 4. Bump `package.json` version, publish.
233
+
234
+ Conventions:
235
+ - Return file maps relative to the module root. Don't write to disk.
236
+ - Reject if the target key already exists (force users to call the matching `*_modify` / `*_remove`).
237
+ - Bump `manifest.updated` on every patch.
238
+
117
239
  ## License
118
240
 
119
241
  MIT.