@dforge-core/dforge-mcp 0.1.0-rc.1 → 0.1.0-rc.11

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,51 @@
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
+ **New here?** Start with **[docs/creating-modules.md](docs/creating-modules.md)** — three ways to scaffold a module (terminal CLI, VS Code sidebar, AI wizard) and when to pick each.
8
+
9
+ > **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.
10
+
11
+ ## What it depends on at runtime
12
+
13
+ ```
14
+ your AI editor (Claude Code / Cursor / Zed)
15
+
16
+ ▼ stdio JSON-RPC
17
+ @dforge-core/dforge-mcp ← this package; pure JS / TS
18
+
19
+ ▼ shells out for pack / install
20
+ @dforge-core/dforge-cli ← installed as a transitive dep; thin JS wrapper
21
+
22
+ ▼ optionalDependencies
23
+ @dforge-core/dforge-cli-<platform> ← native C# binary per platform (~35 MB)
24
+ ```
25
+
26
+ 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).
27
+
28
+ 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
29
 
10
30
  ```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.
31
+ DFORGE_CLI_BINARY=/Users/me/projects/dForge-core/cli/bin/dForge.Cli
32
+ ```
33
+
34
+ (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.
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
+ ## Install + wire into Claude Code
37
+
38
+ ### Recommended via `claude mcp add` (writes ~/.claude.json for you)
39
+
40
+ ```bash
41
+ claude mcp add dforge --scope user -- npx -y @dforge-core/dforge-mcp
17
42
  ```
18
43
 
19
- ## Wiring it up
44
+ 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
45
 
21
- ### Claude Code
46
+ ### Manual — per-project
22
47
 
23
- Add to `~/.claude/config.json` (or the project-local `.claude/mcp.json`):
48
+ Write `.mcp.json` at **the repo root** (not under `.claude/`):
24
49
 
25
50
  ```json
26
51
  {
@@ -29,55 +54,136 @@ Add to `~/.claude/config.json` (or the project-local `.claude/mcp.json`):
29
54
  "command": "npx",
30
55
  "args": ["-y", "@dforge-core/dforge-mcp"],
31
56
  "env": {
32
- "DFORGE_CLI_BINARY": "/optional/path/to/dForge.Cli"
57
+ "DFORGE_CLI_BINARY": "/optional/abs/path/to/dForge.Cli"
33
58
  }
34
59
  }
35
60
  }
36
61
  }
37
62
  ```
38
63
 
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`).
64
+ Restart Claude Code approve on first prompt.
65
+
66
+ ### Verify it's alive
67
+
68
+ ```bash
69
+ claude mcp list
70
+ # Should show: dforge — npx -y @dforge-core/dforge-mcp — connected
71
+ ```
72
+
73
+ Or inside a Claude Code session, type `/mcp` to see all connected servers + their tools. The 18 `dforge_*` tools should be listed.
43
74
 
44
75
  ### Cursor / Zed
45
76
 
46
- Same shape both editors take a `command + args` MCP config. Refer to
47
- their docs for the exact file path.
77
+ Same `command + args` config shape; check their docs for the file location. Verification is via their respective tool listings.
48
78
 
49
79
  ## What it exposes
50
80
 
51
- ### Tools
81
+ ### Tools (18)
82
+
83
+ 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.
52
84
 
85
+ **Module-level**
53
86
  | Tool | Behavior |
54
87
  |---|---|
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. |
88
+ | `dforge_module_create` | New module scaffold |
89
+ | `dforge_module_inspect` | Read current module state. Full structured data is in `files["_inspect.json"]`; `summary` is one-line stats |
90
+ | `dforge_module_pack` | Shells to `dforge-cli module pack`. Returns tarball path + size |
91
+ | `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 |
60
92
 
61
- The `create` and `entity_add` tools deliberately **return** instead of writing — the LLM previews the file map with the user before commit.
93
+ **Entities (Phase 1)**
94
+ | Tool | Behavior |
95
+ |---|---|
96
+ | `dforge_entity_add` | Add an entity to an existing module |
97
+ | `dforge_entity_field_add` | Patch a single field |
98
+ | `dforge_entity_field_modify` | Replace a field's spec |
99
+ | `dforge_entity_field_remove` | Drop a field (warns about dependents) |
100
+
101
+ **Behavior (Phase 2 — optional)**
102
+ | Tool | Behavior |
103
+ |---|---|
104
+ | `dforge_action_add` | DSL script + `ui/actions.json` entry |
62
105
 
63
- ### Resources
106
+ **Views + reports (Phase 3)**
107
+ | Tool | Behavior |
108
+ |---|---|
109
+ | `dforge_view_add` | Add a data view |
110
+ | `dforge_view_modify` | Replace a view's spec |
111
+ | `dforge_report_add` | Add a report |
112
+ | `dforge_setting_add` | Configurable module-level setting |
113
+
114
+ **Security (Phase 5)**
115
+ | Tool | Behavior |
116
+ |---|---|
117
+ | `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 |
118
+ | `dforge_role_right_set` | Grant/revoke one right on one object (cheap backtrack) |
119
+ | `dforge_folder_add` | Add a security folder (optional — most modules ship with just root) |
120
+
121
+ **Cross-cutting**
122
+ | Tool | Behavior |
123
+ |---|---|
124
+ | `dforge_dependency_add` | Add a dep on another dForge module |
125
+ | `dforge_dbml_import` | Stub — not implemented yet |
126
+
127
+ ### Resources (13)
64
128
 
65
129
  | URI | Content |
66
130
  |---|---|
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 |
131
+ | `dforge://schema/manifest` | manifest.json JSON Schema |
132
+ | `dforge://schema/entity` | entity files |
133
+ | `dforge://schema/data-views` | ui/data_views.json |
134
+ | `dforge://schema/folders` | ui/folders.json |
135
+ | `dforge://schema/menus` | ui/menus.json |
136
+ | `dforge://schema/roles` | security/roles.json |
137
+ | `dforge://schema/jobs` | logic/jobs.json |
138
+ | `dforge://schema/seed-data` | seed-data/*.json |
139
+ | `dforge://schema/reports` | ui/reports.json |
140
+ | `dforge://schema/settings` | settings.json |
141
+ | `dforge://schema/traits` | entity trait codes |
142
+ | `dforge://schema/webhooks` | ui/webhooks.json |
143
+ | `dforge://docs/conventions` | MODULE_CONVENTIONS.md |
144
+
145
+ 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
146
 
72
- The schemas + conventions doc are vendored at build time from
73
- `dForge-core/docs/`. Refresh with `scripts/vendor-resources.sh`.
147
+ ```
148
+ https://cdn.jsdelivr.net/npm/@dforge-core/dforge-mcp@latest/resources/schemas/<name>.schema.json
149
+ ```
150
+
151
+ **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
152
 
75
- ## Claude Skill
153
+ ## Claude Skill — the wizard
76
154
 
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.
155
+ `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:
156
+
157
+ ```bash
158
+ # Resolve the actual latest published version from the npm registry,
159
+ # then pin the jsdelivr URL to it. We don't use jsdelivr's `@latest`
160
+ # alias directly — that CDN endpoint caches aggressively (6-12h lag
161
+ # after a new publish), which silently serves stale Skill content.
162
+ VERSION=$(npm view @dforge-core/dforge-mcp version)
163
+ mkdir -p ~/.claude/skills/dforge-mcp-author
164
+ curl -fsSL "https://cdn.jsdelivr.net/npm/@dforge-core/dforge-mcp@${VERSION}/skills/dforge-mcp-author/SKILL.md" \
165
+ -o ~/.claude/skills/dforge-mcp-author/SKILL.md
166
+
167
+ # Or, straight from GitHub main (always fresh, but pre-release content):
168
+ # curl -fsSL https://raw.githubusercontent.com/dforge-core/dforge-mcp/main/skills/dforge-mcp-author/SKILL.md \
169
+ # -o ~/.claude/skills/dforge-mcp-author/SKILL.md
170
+ ```
171
+
172
+ 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.
173
+
174
+ The phases:
175
+
176
+ | Phase | Required? | Tools used |
177
+ |---|---|---|
178
+ | 0. Intake | yes | (brief written manually) |
179
+ | 1. Domain | yes | `module_create`, `entity_add`, `entity_field_*` |
180
+ | 2. Actions | optional | `action_add` |
181
+ | 3. Views + Reports | views yes, reports optional | `view_*`, `report_add`, `setting_add` |
182
+ | 4. Polish (translations, seed) | optional | (file map authored directly) |
183
+ | 5. Security | roles required, folders optional | `role_add`, `role_right_set`, `folder_add` |
184
+ | 6. Verify | yes | `module_pack`, `module_install` |
185
+
186
+ 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
187
 
82
188
  ## For maintainers
83
189
 
@@ -85,15 +191,18 @@ to enable.
85
191
 
86
192
  ```bash
87
193
  pnpm install
88
- pnpm build # tsup → dist/server.js
194
+ pnpm build # tsup → dist/server.js (bundles SDK + zod + dforge-cli/templates)
89
195
  pnpm typecheck # tsc --noEmit
90
- node dist/server.js # smoke-test via stdio JSON-RPC
196
+ node dist/server.js # stdio JSON-RPC pipe a request to smoke-test
91
197
  ```
92
198
 
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).
199
+ To iterate against an in-tree `dforge-cli`, temporarily pin the dep at the sibling path:
200
+
201
+ ```bash
202
+ sed -i '' 's|"@dforge-core/dforge-cli": "\^0.1.[0-9.]*"|"@dforge-core/dforge-cli": "file:../dforge-cli"|' package.json
203
+ rm -rf node_modules pnpm-lock.yaml && pnpm install
204
+ # Flip back before publish — file: deps don't resolve for npm consumers.
205
+ ```
97
206
 
98
207
  ### Refresh vendored resources
99
208
 
@@ -104,16 +213,34 @@ scripts/vendor-resources.sh # auto-locate ../dForge
104
213
  DFORGE_CORE=/abs/path/to/dForge-core scripts/vendor-resources.sh
105
214
  ```
106
215
 
107
- ### Publishing to npm
216
+ Republish to update jsdelivr-served schemas + the bundled resources.
108
217
 
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.)
218
+ ### Publishing
112
219
 
113
220
  ```bash
114
- npm publish --access public --tag next
221
+ scripts/publish.sh 0.1.0-rc.N --tag latest --otp <code>
115
222
  ```
116
223
 
224
+ `prepublishOnly` runs `tsup` so the tarball gets a fresh `dist/server.js`. No platform binaries to manage.
225
+
226
+ **Pre-publish checklist:**
227
+ - [ ] `@dforge-core/dforge-cli` dep is a real version (not `file:...`)
228
+ - [ ] `pnpm typecheck` passes
229
+ - [ ] Smoke test stdio: `tools/list` returns 18 tools
230
+ - [ ] Skill updated for any new/changed tools (it's a SEPARATE artifact; users sync it manually after upgrades)
231
+
232
+ ### Adding a new tool
233
+
234
+ 1. Drop it in `src/tools/<name>.ts`. Use shared helpers from `src/tools/_helpers.ts` (`loadManifest`, `readJsonOrDefault`, `jsonText`, `makeResult`, `withTodayStamp`). Return a `ToolResult`.
235
+ 2. Import + register in `src/server.ts` via the `envelope()` wrapper.
236
+ 3. Mention it in `skills/dforge-mcp-author/SKILL.md` (which phase, which backtrack scenarios use it).
237
+ 4. Bump `package.json` version, publish.
238
+
239
+ Conventions:
240
+ - Return file maps relative to the module root. Don't write to disk.
241
+ - Reject if the target key already exists (force users to call the matching `*_modify` / `*_remove`).
242
+ - Bump `manifest.updated` on every patch.
243
+
117
244
  ## License
118
245
 
119
246
  MIT.