@ontrails/mcp 1.0.0-beta.2 → 1.0.0-beta.22
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/CHANGELOG.md +306 -5
- package/README.md +70 -21
- package/package.json +11 -3
- package/src/annotations.ts +32 -9
- package/src/build.ts +1236 -137
- package/src/index.ts +31 -4
- package/src/progress.ts +22 -0
- package/src/resources.ts +228 -0
- package/src/stdio.ts +9 -1
- package/src/surface.ts +279 -0
- package/.turbo/turbo-build.log +0 -1
- package/.turbo/turbo-lint.log +0 -3
- package/.turbo/turbo-typecheck.log +0 -1
- package/dist/annotations.d.ts +0 -19
- package/dist/annotations.d.ts.map +0 -1
- package/dist/annotations.js +0 -29
- package/dist/annotations.js.map +0 -1
- package/dist/blaze.d.ts +0 -36
- package/dist/blaze.d.ts.map +0 -1
- package/dist/blaze.js +0 -96
- package/dist/blaze.js.map +0 -1
- package/dist/build.d.ts +0 -40
- package/dist/build.d.ts.map +0 -1
- package/dist/build.js +0 -190
- package/dist/build.js.map +0 -1
- package/dist/index.d.ts +0 -7
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -13
- package/dist/index.js.map +0 -1
- package/dist/progress.d.ts +0 -13
- package/dist/progress.d.ts.map +0 -1
- package/dist/progress.js +0 -51
- package/dist/progress.js.map +0 -1
- package/dist/stdio.d.ts +0 -12
- package/dist/stdio.d.ts.map +0 -1
- package/dist/stdio.js +0 -15
- package/dist/stdio.js.map +0 -1
- package/dist/tool-name.d.ts +0 -15
- package/dist/tool-name.d.ts.map +0 -1
- package/dist/tool-name.js +0 -19
- package/dist/tool-name.js.map +0 -1
- package/src/__tests__/annotations.test.ts +0 -70
- package/src/__tests__/blaze.test.ts +0 -105
- package/src/__tests__/build.test.ts +0 -377
- package/src/__tests__/progress.test.ts +0 -136
- package/src/__tests__/tool-name.test.ts +0 -46
- package/src/blaze.ts +0 -146
- package/tsconfig.json +0 -9
- package/tsconfig.tsbuildinfo +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,306 @@
|
|
|
1
1
|
# @ontrails/mcp
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.22
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @ontrails/core@1.0.0-beta.22
|
|
8
|
+
|
|
9
|
+
## 1.0.0-beta.21
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [99523f2]
|
|
14
|
+
- @ontrails/core@1.0.0-beta.21
|
|
15
|
+
|
|
16
|
+
## 1.0.0-beta.20
|
|
17
|
+
|
|
18
|
+
### Minor Changes
|
|
19
|
+
|
|
20
|
+
- accb9ec: Add MCP surface facets, MCP resource projection for cold context, and deferred-loading metadata hints.
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- 9bec01c: Document MCP resource projection and deferred-loading options for cold surface context.
|
|
25
|
+
- Updated dependencies [851a2a3]
|
|
26
|
+
- @ontrails/core@1.0.0-beta.20
|
|
27
|
+
|
|
28
|
+
## 1.0.0-beta.19
|
|
29
|
+
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- e41c382: Document beta-channel install guidance in package and adapter README install snippets so consumers use explicit `@beta` (or pinned `1.0.0-beta.N`) tags instead of accidental `latest` resolution during the prerelease line. Adds the policy doc at `docs/releases/beta-channel-policy.md`, prints both `latest` and `beta` dist-tags in `bun run publish:registry-check`, and aligns plugin/skill install snippets.
|
|
33
|
+
- 1eb5bdc: Rename first-class trail composition from the `cross` API family to the `compose` family across core contracts, testing helpers, topo projections, Warden rules, CLI scaffolds, and docs. `composes`, `ctx.compose`, `composeInput`, and `Compose*` type names are now the public authoring vocabulary; topo persistence migrates legacy composition rows and graph keys forward.
|
|
34
|
+
- 8638dae: Add a public API example for MCP `deriveAnnotations` annotation derivation.
|
|
35
|
+
- 8638dae: Add public API examples for the MCP tool metadata keys.
|
|
36
|
+
- 8638dae: Add a public API example for the MCP progress callback bridge.
|
|
37
|
+
- 84f56a5: Project live trail-version metadata on CLI, HTTP, and MCP surfaces and thread explicit surface version selection into shared trail execution.
|
|
38
|
+
- 5d88104: Polish Trails blaze terminology across package docs and Warden guidance.
|
|
39
|
+
- Updated dependencies [e41c382]
|
|
40
|
+
- Updated dependencies [1eb5bdc]
|
|
41
|
+
- Updated dependencies [f8d80b9]
|
|
42
|
+
- Updated dependencies [846a597]
|
|
43
|
+
- Updated dependencies [223aaad]
|
|
44
|
+
- Updated dependencies [3125f4d]
|
|
45
|
+
- Updated dependencies [2494dc6]
|
|
46
|
+
- Updated dependencies [2d53717]
|
|
47
|
+
- Updated dependencies [16cb740]
|
|
48
|
+
- Updated dependencies [8894ecb]
|
|
49
|
+
- Updated dependencies [fdf7ec9]
|
|
50
|
+
- Updated dependencies [d76be13]
|
|
51
|
+
- Updated dependencies [84f56a5]
|
|
52
|
+
- Updated dependencies [431b04c]
|
|
53
|
+
- Updated dependencies [5d88104]
|
|
54
|
+
- Updated dependencies [f04a9ef]
|
|
55
|
+
- @ontrails/core@1.0.0-beta.19
|
|
56
|
+
|
|
57
|
+
## 1.0.0-beta.18
|
|
58
|
+
|
|
59
|
+
### Patch Changes
|
|
60
|
+
|
|
61
|
+
- @ontrails/core@1.0.0-beta.18
|
|
62
|
+
|
|
63
|
+
## 1.0.0-beta.17
|
|
64
|
+
|
|
65
|
+
### Patch Changes
|
|
66
|
+
|
|
67
|
+
- 61497c5: Add v1-minimum public API examples for shipped surface entrypoints.
|
|
68
|
+
- Updated dependencies [3dc8254]
|
|
69
|
+
- @ontrails/core@1.0.0-beta.17
|
|
70
|
+
|
|
71
|
+
## 1.0.0-beta.16
|
|
72
|
+
|
|
73
|
+
### Minor Changes
|
|
74
|
+
|
|
75
|
+
- 26f9ffd: Project typed-layer `input` schemas onto MCP and HTTP surfaces. Closes Phase 7. Lifts `collectAttachedTypedLayers` and `projectLayerFieldName` (collision-rename rule) into `@ontrails/core/internal/layer-projection` so all three surfaces share one source of truth. The CLI surface refactors to consume the lifted helpers (no behavior change). MCP merges layer fields into each tool's `inputSchema` and partitions inbound args at invocation time. HTTP merges layer fields into the route's request schema (query for reads, body for writes) and exposes new optional `HttpRouteDefinition.inputSchema` + `layerInputProjections` for surface adapters / OpenAPI generators. Collision rule matches TRL-473's: deterministic rename to a layer-prefixed camelCase name with the original captured in the routing table. Side fix: MCP and HTTP handlers now forward `topoLayers: graph.layers` + `surfaceLayers: layers` so topo-scope layers actually compose at runtime (previously the handlers used the deprecated `layers` alias and never read `graph.layers`).
|
|
76
|
+
|
|
77
|
+
### Patch Changes
|
|
78
|
+
|
|
79
|
+
- 6300f70: Refresh source comments and test labels for retired connector terminology as adapter guardrails become strict.
|
|
80
|
+
- 20d7a5c: Enforce the shared safe error projection policy for public error bodies, diagnostics, serialized payloads, and CLI stderr.
|
|
81
|
+
- 49c2e7d: Refresh published package README taxonomy to use adapter language instead of retired connector vocabulary.
|
|
82
|
+
- Updated dependencies [73622ae]
|
|
83
|
+
- Updated dependencies [6300f70]
|
|
84
|
+
- Updated dependencies [d172013]
|
|
85
|
+
- Updated dependencies [c3fc5c3]
|
|
86
|
+
- Updated dependencies [20d7a5c]
|
|
87
|
+
- Updated dependencies [be5fb46]
|
|
88
|
+
- Updated dependencies [e898cc4]
|
|
89
|
+
- Updated dependencies [3395234]
|
|
90
|
+
- Updated dependencies [bcdc484]
|
|
91
|
+
- Updated dependencies [331e3a9]
|
|
92
|
+
- Updated dependencies [4399fdb]
|
|
93
|
+
- Updated dependencies [4b8d13b]
|
|
94
|
+
- Updated dependencies [112b9f2]
|
|
95
|
+
- Updated dependencies [893025e]
|
|
96
|
+
- Updated dependencies [eec5e9d]
|
|
97
|
+
- Updated dependencies [ebd4434]
|
|
98
|
+
- Updated dependencies [863d473]
|
|
99
|
+
- Updated dependencies [344f2f7]
|
|
100
|
+
- Updated dependencies [26f9ffd]
|
|
101
|
+
- Updated dependencies [10eae9a]
|
|
102
|
+
- Updated dependencies [22c6c06]
|
|
103
|
+
- @ontrails/core@1.0.0-beta.16
|
|
104
|
+
|
|
105
|
+
## 1.0.0-beta.15
|
|
106
|
+
|
|
107
|
+
### Patch Changes
|
|
108
|
+
|
|
109
|
+
- Updated dependencies [4ad6b25]
|
|
110
|
+
- @ontrails/core@1.0.0-beta.15
|
|
111
|
+
|
|
112
|
+
## 1.0.0-beta.14
|
|
113
|
+
|
|
114
|
+
### Minor Changes
|
|
115
|
+
|
|
116
|
+
- 69057e9: Add hierarchical CLI command trees and structured input, enforce established-only topo exports across trailheads, move developer topo and tracker state onto shared `trails.db` with pins and maintenance flows, and ship schema-derived stores through `@ontrails/store` and its Drizzle runtime.
|
|
117
|
+
|
|
118
|
+
### Patch Changes
|
|
119
|
+
|
|
120
|
+
- Updated dependencies [69057e9]
|
|
121
|
+
- @ontrails/core@1.0.0-beta.14
|
|
122
|
+
|
|
123
|
+
## 1.0.0-beta.13
|
|
124
|
+
|
|
125
|
+
### Minor Changes
|
|
126
|
+
|
|
127
|
+
- Trail-native vocabulary cutover. Breaking API field renames across all packages:
|
|
128
|
+
|
|
129
|
+
- Trail spec: `run:` → `blaze:`, `follow:` → `crosses:`, `services:` → `provisions:`, `metadata:` → `meta:`, `emits:` → `signals:`
|
|
130
|
+
- Runtime: `ctx.follow()` → `ctx.cross()`, `ctx.emit()` → `ctx.signal()`, `ctx.signal` (abort) → `ctx.abortSignal`
|
|
131
|
+
- Entry points: `blaze(app)` → `trailhead(app)`
|
|
132
|
+
- Package rename: `@ontrails/crumbs` → `@ontrails/tracker`
|
|
133
|
+
- Wrapper types: `Layer` → `Gate`, `layers`/`middleware` → `gates`
|
|
134
|
+
- Transport: `surface` → `trailhead`, `adapter` → `connector`
|
|
135
|
+
|
|
136
|
+
### Patch Changes
|
|
137
|
+
|
|
138
|
+
- 6944147: Complete trifecta for config, permits, and tracker (formerly tracks)
|
|
139
|
+
|
|
140
|
+
- **config**: Add `configProvision`, `configGate`, `config.trail`, and `config.workspace` trails with full `defineConfig`, `resolve`, `describe`, `explain`, `doctor`, and code generation support
|
|
141
|
+
- **permits**: Add `authService` and `auth.verify` trail for runtime authorization checks
|
|
142
|
+
- **tracker**: Rename tracks to tracker; add `trackerProvision` and `tracker.status` trail for structured signal tracking
|
|
143
|
+
- **cli**: Fix build flag handling and improve bootstrap scaffolding
|
|
144
|
+
- **testing**: Expand test context helpers and example-based testing utilities
|
|
145
|
+
- **core/mcp/http**: Internal alignment for provision and composition updates
|
|
146
|
+
|
|
147
|
+
- Updated dependencies [6944147]
|
|
148
|
+
- Updated dependencies
|
|
149
|
+
- @ontrails/core@1.0.0-beta.13
|
|
150
|
+
|
|
151
|
+
## 1.0.0-beta.12
|
|
152
|
+
|
|
153
|
+
### Patch Changes
|
|
154
|
+
|
|
155
|
+
- Complete trifecta for config, permits, and tracker (formerly tracks)
|
|
156
|
+
|
|
157
|
+
- **config**: Add `configProvision`, `config.gate`, `config.trail`, and `config.workspace` trails with full `defineConfig`, `resolve`, `describe`, `explain`, `doctor`, and code generation support
|
|
158
|
+
- **permits**: Add `authProvision` and `auth.verify` trail for runtime authorization checks
|
|
159
|
+
- **tracker**: Rename tracks to tracker; add `trackerProvision` and `tracker.status` trail for structured event tracking
|
|
160
|
+
- **cli**: Fix build flag handling and improve bootstrap scaffolding
|
|
161
|
+
- **testing**: Expand test context helpers and example-based testing utilities
|
|
162
|
+
- **core/mcp/http**: Internal alignment for provision and composition updates
|
|
163
|
+
|
|
164
|
+
- Updated dependencies
|
|
165
|
+
- @ontrails/core@1.0.0-beta.12
|
|
166
|
+
|
|
167
|
+
## 1.0.0-beta.11
|
|
168
|
+
|
|
169
|
+
### Patch Changes
|
|
170
|
+
|
|
171
|
+
- Add provisions as a first-class primitive.
|
|
172
|
+
|
|
173
|
+
Provisions make infrastructure dependencies declarative, injectable, and governable. Define a provision with `provision()`, declare it on a trail with `provisions: [db]`, and access it with `db.from(ctx)` or `ctx.provision()`.
|
|
174
|
+
|
|
175
|
+
**Core:** `provision()` factory, `ProvisionSpec<T>`, `ProvisionContext`, singleton resolution in `executeTrail`, in-flight creation dedup, `isProvision` guard, `findDuplicateProvisionId`, topo provision discovery and validation, `provisions` field on trail specs.
|
|
176
|
+
|
|
177
|
+
**Testing:** Auto-resolution of `mock` factories in `testAll`, `testExamples`, `testContracts`, and `testCrosses`. Explicit `provisions` overrides with correct precedence (`explicit > ctx.extensions > auto-mock`). Provision mock propagation through crossing graphs.
|
|
178
|
+
|
|
179
|
+
**Warden:** `provision-declarations` rule validates `db.from(ctx)` and `ctx.provision()` usage matches declared `provisions: [...]`. `provision-exists` rule validates declared provision IDs resolve in project context. Scope-aware AST walking skips nested function boundaries.
|
|
180
|
+
|
|
181
|
+
**Trailheads:** Provision overrides thread through `run` and `trailhead` on CLI, MCP, and HTTP.
|
|
182
|
+
|
|
183
|
+
**Introspection:** Survey and trailhead map outputs include provision graph. Topo exposes `.provisions`, `.getProvision()`, `.hasProvision()`, `.listProvisions()`, `.provisionIds()`, `.provisionCount`.
|
|
184
|
+
|
|
185
|
+
**Docs:** ADR-009 accepted. Unified provisions guide, updated vocabulary, getting-started, architecture, and package READMEs.
|
|
186
|
+
|
|
187
|
+
- Updated dependencies
|
|
188
|
+
- @ontrails/core@1.0.0-beta.11
|
|
189
|
+
|
|
190
|
+
## 1.0.0-beta.10
|
|
191
|
+
|
|
192
|
+
### Patch Changes
|
|
193
|
+
|
|
194
|
+
- Cleanup and hardening pass across all packages.
|
|
195
|
+
|
|
196
|
+
**core**: Deduplicate `DispatchOptions` as type alias of `ExecuteTrailOptions`. Replace `TrailContext` index signature with typed `extensions` field for type safety. Deep-merge `extensions` in `executeTrail` context resolution. Remove unused `Trailhead` type, `connectors.ts`, `health.ts`, and `job.ts` proof-of-concept from published package.
|
|
197
|
+
|
|
198
|
+
**cli**: Remove vestigial `kind` checks from build. Run `validateTopo()` automatically in `trailhead()` with opt-out via `validate: false`.
|
|
199
|
+
|
|
200
|
+
**http**: Remove vestigial `kind` checks from build. Run `validateTopo()` automatically in `trailhead()` with opt-out.
|
|
201
|
+
|
|
202
|
+
**mcp**: Remove vestigial `kind` checks from build. Run `validateTopo()` automatically in `trailhead()` with opt-out.
|
|
203
|
+
|
|
204
|
+
**warden**: Project-aware rule context preserved in trail wrappers.
|
|
205
|
+
|
|
206
|
+
- Updated dependencies
|
|
207
|
+
- @ontrails/core@1.0.0-beta.10
|
|
208
|
+
|
|
209
|
+
## 1.0.0-beta.9
|
|
210
|
+
|
|
211
|
+
### Minor Changes
|
|
212
|
+
|
|
213
|
+
- Consolidated improvements across all trailhead packages.
|
|
214
|
+
|
|
215
|
+
**core**: Add `TrailResult<T>` utility type, `topo.ids()` and `topo.count` accessors, `run()` for headless trail execution, and extract shared `executeTrail` pipeline used by CLI/MCP/HTTP.
|
|
216
|
+
|
|
217
|
+
**http**: Detect route path collisions and return `Result` from `buildHttpRoutes()`, wire request `AbortSignal` through to trail context, and make write → POST mapping explicit in intent-to-method lookup.
|
|
218
|
+
|
|
219
|
+
**mcp**: Return `Result` from `buildMcpTools()` on collision instead of throwing.
|
|
220
|
+
|
|
221
|
+
**cli**: Verify exception catching via centralized `executeTrail`.
|
|
222
|
+
|
|
223
|
+
**testing**: Cross-context awareness improvements.
|
|
224
|
+
|
|
225
|
+
**warden**: Refactor rules as composable trails with examples.
|
|
226
|
+
|
|
227
|
+
**schema**: Error code and empty body fixes.
|
|
228
|
+
|
|
229
|
+
### Patch Changes
|
|
230
|
+
|
|
231
|
+
- Updated dependencies
|
|
232
|
+
- @ontrails/core@1.0.0-beta.9
|
|
233
|
+
|
|
234
|
+
## 1.0.0-beta.8
|
|
235
|
+
|
|
236
|
+
### Patch Changes
|
|
237
|
+
|
|
238
|
+
- @ontrails/core@1.0.0-beta.8
|
|
239
|
+
|
|
240
|
+
## 1.0.0-beta.7
|
|
241
|
+
|
|
242
|
+
### Patch Changes
|
|
243
|
+
|
|
244
|
+
- @ontrails/core@1.0.0-beta.7
|
|
245
|
+
|
|
246
|
+
## 1.0.0-beta.6
|
|
247
|
+
|
|
248
|
+
### Patch Changes
|
|
249
|
+
|
|
250
|
+
- Updated dependencies
|
|
251
|
+
- @ontrails/core@1.0.0-beta.6
|
|
252
|
+
|
|
253
|
+
## 1.0.0-beta.5
|
|
254
|
+
|
|
255
|
+
### Patch Changes
|
|
256
|
+
|
|
257
|
+
- Updated dependencies
|
|
258
|
+
- @ontrails/core@1.0.0-beta.5
|
|
259
|
+
|
|
260
|
+
## 1.0.0-beta.4
|
|
261
|
+
|
|
262
|
+
### Major Changes
|
|
263
|
+
|
|
264
|
+
- API simplification: unified trail model, intent enum, run, metadata.
|
|
265
|
+
|
|
266
|
+
**BREAKING CHANGES:**
|
|
267
|
+
|
|
268
|
+
- `hike()` removed — use `trail()` with optional `crosses: [...]` field
|
|
269
|
+
- `follows` renamed to `crosses` (matching `ctx.cross()`)
|
|
270
|
+
- `topo.hikes` removed — single `topo.trails` map
|
|
271
|
+
- `kind: 'hike'` removed — everything is `kind: 'trail'`
|
|
272
|
+
- `readOnly`/`destructive` booleans replaced by `intent: 'read' | 'write' | 'destroy'`
|
|
273
|
+
- `implementation` field renamed to `run`
|
|
274
|
+
- `markers` field renamed to `metadata`
|
|
275
|
+
- `testHike` renamed to `testCrosses`, `HikeScenario` to `CrossScenario`
|
|
276
|
+
- `trailhead()` now returns the trailhead handle (`Command` for CLI, `Server` for MCP)
|
|
277
|
+
|
|
278
|
+
### Patch Changes
|
|
279
|
+
|
|
280
|
+
- Updated dependencies
|
|
281
|
+
- @ontrails/core@1.0.0-beta.4
|
|
282
|
+
|
|
283
|
+
## 1.0.0-beta.3
|
|
284
|
+
|
|
285
|
+
### Minor Changes
|
|
286
|
+
|
|
287
|
+
- Bug fixes across all trailhead packages found via parallel Codex review.
|
|
288
|
+
|
|
289
|
+
**core**: Fix Result.toJson false circular detection on DAGs, deserializeError subclass round-trip, topo cross-kind ID collisions, validateTopo multi-node cycle detection, error example input validation bypass, and deriveFields array type collapse.
|
|
290
|
+
|
|
291
|
+
**cli**: Switch trailhead to parseAsync for proper async error handling, add boolean flag negation (--no-flag), and strict number parsing that rejects partial input.
|
|
292
|
+
|
|
293
|
+
**mcp**: Align BlobRef with core (including ReadableStream support) and detect tool-name collisions after normalization.
|
|
294
|
+
|
|
295
|
+
**testing**: Include hikes in testContracts validation, with cross-context awareness.
|
|
296
|
+
|
|
297
|
+
**warden**: Collect hike detour targets, validate detour refs in hike specs, and stop implementation-returns-result from walking into nested function bodies.
|
|
298
|
+
|
|
299
|
+
### Patch Changes
|
|
300
|
+
|
|
301
|
+
- Updated dependencies
|
|
302
|
+
- @ontrails/core@1.0.0-beta.3
|
|
303
|
+
|
|
3
304
|
## 1.0.0-beta.2
|
|
4
305
|
|
|
5
306
|
### Patch Changes
|
|
@@ -26,12 +327,12 @@
|
|
|
26
327
|
- Initial v1 beta release of the Trails framework.
|
|
27
328
|
|
|
28
329
|
- **@ontrails/core** — Result type, error taxonomy, trail/hike/event/topo, validateTopo, validateInput/Output, deriveFields, patterns, redaction, branded types, resilience
|
|
29
|
-
- **@ontrails/cli** — CLI
|
|
30
|
-
- **@ontrails/mcp** — MCP
|
|
31
|
-
- **@ontrails/logging** — Structured logging, sinks, formatters, LogTape
|
|
32
|
-
- **@ontrails/testing** — testAll, testExamples, testTrail, testHike, testContracts, testDetours,
|
|
330
|
+
- **@ontrails/cli** — CLI trailhead connector, Commander integration, flag derivation, gates
|
|
331
|
+
- **@ontrails/mcp** — MCP trailhead connector, tool generation, annotations, progress bridge
|
|
332
|
+
- **@ontrails/logging** — Structured logging, sinks, formatters, LogTape connector
|
|
333
|
+
- **@ontrails/testing** — testAll, testExamples, testTrail, testHike, testContracts, testDetours, trailhead harnesses
|
|
33
334
|
- **@ontrails/warden** — AST-based code convention rules via oxc-parser, drift detection, CI formatters
|
|
34
|
-
- **@ontrails/schema** —
|
|
335
|
+
- **@ontrails/schema** — Trailhead map generation, hashing, semantic diffing
|
|
35
336
|
|
|
36
337
|
### Patch Changes
|
|
37
338
|
|
package/README.md
CHANGED
|
@@ -1,76 +1,123 @@
|
|
|
1
1
|
# @ontrails/mcp
|
|
2
2
|
|
|
3
|
-
MCP surface adapter. One `
|
|
3
|
+
MCP surface adapter. One `surface()` call turns a topo into an MCP server with tool definitions, annotations, and progress bridging -- all derived from the trail contracts.
|
|
4
4
|
|
|
5
5
|
## Usage
|
|
6
6
|
|
|
7
7
|
```typescript
|
|
8
8
|
import { trail, topo, Result } from '@ontrails/core';
|
|
9
|
-
import {
|
|
9
|
+
import { surface } from '@ontrails/mcp';
|
|
10
10
|
import { z } from 'zod';
|
|
11
11
|
|
|
12
12
|
const greet = trail('greet', {
|
|
13
13
|
input: z.object({ name: z.string().describe('Who to greet') }),
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
output: z.object({ greeting: z.string() }),
|
|
15
|
+
intent: 'read',
|
|
16
|
+
examples: [
|
|
17
|
+
{
|
|
18
|
+
expected: { greeting: 'Hello, Ada!' },
|
|
19
|
+
input: { name: 'Ada' },
|
|
20
|
+
name: 'Ada',
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
blaze: (input) => Result.ok({ greeting: `Hello, ${input.name}!` }),
|
|
16
24
|
});
|
|
17
25
|
|
|
18
|
-
const
|
|
19
|
-
await
|
|
26
|
+
const graph = topo('myapp', { greet });
|
|
27
|
+
await surface(graph);
|
|
20
28
|
```
|
|
21
29
|
|
|
22
|
-
This starts an MCP server over stdio with a `myapp_greet` tool. The tool gets `readOnlyHint: true
|
|
30
|
+
This starts an MCP server over stdio with a `myapp_greet` tool. The tool gets `readOnlyHint: true`, JSON Schema input, JSON Schema output, and structured examples -- all derived from the trail definition.
|
|
23
31
|
|
|
24
32
|
For more control, build the tools yourself:
|
|
25
33
|
|
|
26
34
|
```typescript
|
|
27
|
-
import {
|
|
35
|
+
import { deriveMcpTools } from '@ontrails/mcp';
|
|
28
36
|
|
|
29
|
-
const
|
|
30
|
-
|
|
37
|
+
const result = deriveMcpTools(graph);
|
|
38
|
+
if (result.isErr()) throw result.error; // ValidationError on tool-name collision
|
|
39
|
+
for (const tool of result.value) {
|
|
31
40
|
server.registerTool(tool.name, tool.handler, {
|
|
32
41
|
inputSchema: tool.inputSchema,
|
|
42
|
+
outputSchema: tool.outputSchema,
|
|
33
43
|
annotations: tool.annotations,
|
|
44
|
+
_meta: tool._meta,
|
|
34
45
|
});
|
|
35
46
|
}
|
|
36
47
|
```
|
|
37
48
|
|
|
49
|
+
`deriveMcpTools` returns `Result<McpToolDefinition[], Error>` rather than a bare array. It returns `Result.err(ValidationError)` if two trails derive the same MCP tool name. Each `McpToolDefinition` includes a `trailId` field that records which trail the tool was derived from.
|
|
50
|
+
|
|
38
51
|
## API
|
|
39
52
|
|
|
40
53
|
| Export | What it does |
|
|
41
54
|
| --- | --- |
|
|
42
|
-
| `
|
|
43
|
-
| `
|
|
55
|
+
| `surface(graph, options?)` | Start an MCP server with all trails as tools |
|
|
56
|
+
| `deriveMcpTools(graph, options?)` | Build tool definitions without starting a server |
|
|
57
|
+
| `buildMcpResources(graph, tools, config?)` | Build MCP resource listings and read handlers for cold context |
|
|
44
58
|
| `deriveToolName(appName, trailId)` | Compute the MCP tool name from app and trail IDs |
|
|
45
|
-
| `deriveAnnotations(trail)` | Extract MCP annotations from trail
|
|
59
|
+
| `deriveAnnotations(trail)` | Extract MCP annotations from trail intent, idempotency, and description |
|
|
46
60
|
| `createMcpProgressCallback(server)` | Bridge `ctx.progress` to MCP `notifications/progress` |
|
|
47
61
|
|
|
48
62
|
See the [API Reference](../../docs/api-reference.md) for the full list.
|
|
49
63
|
|
|
50
64
|
## Annotations
|
|
51
65
|
|
|
52
|
-
Trail
|
|
66
|
+
Trail intent, idempotency, and description map directly to MCP annotations:
|
|
53
67
|
|
|
54
68
|
| Trail field | MCP annotation |
|
|
55
69
|
| --- | --- |
|
|
56
|
-
| `
|
|
57
|
-
| `
|
|
70
|
+
| `intent: 'read'` | `readOnlyHint: true` |
|
|
71
|
+
| `intent: 'destroy'` | `destructiveHint: true` |
|
|
58
72
|
| `idempotent: true` | `idempotentHint: true` |
|
|
59
73
|
| `description` | `title` |
|
|
60
74
|
|
|
61
75
|
No manual annotation definitions. The contract is the source of truth.
|
|
62
76
|
|
|
77
|
+
## Schemas and Examples
|
|
78
|
+
|
|
79
|
+
MCP tool definitions include the trail's input schema, and trails with an `output` schema also project that schema into MCP `outputSchema`. Non-object trail outputs are wrapped in a `{ data: ... }` object because MCP structured tool results are object-shaped.
|
|
80
|
+
|
|
81
|
+
Trail examples are projected as structured metadata under `_meta["ontrails/examples"]`. Each projected example preserves its input, expected output or error, a success/error kind, and provenance pointing back to the authored `trail.examples` field.
|
|
82
|
+
|
|
83
|
+
## MCP resources and deferred loading
|
|
84
|
+
|
|
85
|
+
Cold context is projected through MCP resources, not extra Trails resources. `surface(graph)` and `createServer(graph)` expose MCP resources by default:
|
|
86
|
+
|
|
87
|
+
- `trails://surface-map` lists the resolved MCP tool projection, including ordinary tools, facet tools, schemas, versions, deferred hints, and member trail IDs.
|
|
88
|
+
- `trails://examples/<trailId>` exposes structured examples for exposed trails that define examples.
|
|
89
|
+
|
|
90
|
+
Disable resource projection only when the host needs a minimal MCP capability surface:
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
await surface(graph, { mcpResources: false });
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Or choose a narrower resource set:
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
await surface(graph, {
|
|
100
|
+
mcpResources: { examples: false, surfaceMap: true },
|
|
101
|
+
});
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Facet definitions may set `mcp: { loading: 'deferred' }`. In this release, deferred loading is a compatibility hint under `_meta["ontrails/deferred"]`; the MCP tool schema remains present so clients that do not understand deferred loading continue to work.
|
|
105
|
+
|
|
63
106
|
## Tool naming
|
|
64
107
|
|
|
65
108
|
Trail IDs become MCP tool names with the app prefix: `entity.show` in app `myapp` becomes `myapp_entity_show`. Dots and hyphens become underscores, everything lowercase.
|
|
66
109
|
|
|
110
|
+
## Resource resolution
|
|
111
|
+
|
|
112
|
+
Declared resources on each trail are resolved into the context before the blaze receives input.
|
|
113
|
+
|
|
67
114
|
## Progress bridge
|
|
68
115
|
|
|
69
|
-
|
|
116
|
+
Blazes report progress through `ctx.progress`. On MCP, these bridge to `notifications/progress` when the client sends a `progressToken`:
|
|
70
117
|
|
|
71
118
|
```typescript
|
|
72
119
|
const importTrail = trail('data.import', {
|
|
73
|
-
|
|
120
|
+
blaze: async (input, ctx) => {
|
|
74
121
|
for (let i = 0; i < items.length; i++) {
|
|
75
122
|
await processItem(items[i]);
|
|
76
123
|
ctx.progress?.({ type: 'progress', current: i + 1, total: items.length });
|
|
@@ -83,12 +130,14 @@ const importTrail = trail('data.import', {
|
|
|
83
130
|
## Filtering
|
|
84
131
|
|
|
85
132
|
```typescript
|
|
86
|
-
await
|
|
87
|
-
await
|
|
133
|
+
await surface(graph, { include: ['entity.**', 'search'] });
|
|
134
|
+
await surface(graph, { exclude: ['internal.debug'] });
|
|
88
135
|
```
|
|
89
136
|
|
|
137
|
+
`*` matches one dotted segment and `**` matches any depth. Trails declared with `visibility: 'internal'` stay hidden unless you include their exact trail ID.
|
|
138
|
+
|
|
90
139
|
## Installation
|
|
91
140
|
|
|
92
141
|
```bash
|
|
93
|
-
bun add @ontrails/mcp
|
|
142
|
+
bun add @ontrails/mcp@beta
|
|
94
143
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ontrails/mcp",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.22",
|
|
4
|
+
"files": [
|
|
5
|
+
"src/**/*.ts",
|
|
6
|
+
"!src/**/__tests__/**",
|
|
7
|
+
"!src/**/*.test.ts",
|
|
8
|
+
"!src/**/*.test-d.ts",
|
|
9
|
+
"README.md",
|
|
10
|
+
"CHANGELOG.md"
|
|
11
|
+
],
|
|
4
12
|
"type": "module",
|
|
5
13
|
"exports": {
|
|
6
14
|
".": "./src/index.ts",
|
|
@@ -14,10 +22,10 @@
|
|
|
14
22
|
"clean": "rm -rf dist *.tsbuildinfo"
|
|
15
23
|
},
|
|
16
24
|
"dependencies": {
|
|
17
|
-
"@ontrails/core": "^1.0.0-beta.
|
|
25
|
+
"@ontrails/core": "^1.0.0-beta.22"
|
|
18
26
|
},
|
|
19
27
|
"peerDependencies": {
|
|
20
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
28
|
+
"@modelcontextprotocol/sdk": "^1.28.0",
|
|
21
29
|
"zod": "^4.3.5"
|
|
22
30
|
}
|
|
23
31
|
}
|
package/src/annotations.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Derive MCP tool annotations from trail spec
|
|
2
|
+
* Derive MCP tool annotations from trail spec fields.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import type { Trail } from '@ontrails/core';
|
|
5
|
+
import type { Intent, Trail } from '@ontrails/core';
|
|
6
6
|
|
|
7
7
|
// ---------------------------------------------------------------------------
|
|
8
8
|
// Types
|
|
@@ -25,20 +25,43 @@ export interface McpAnnotations {
|
|
|
25
25
|
*
|
|
26
26
|
* Only sets hints that are explicitly declared on the trail.
|
|
27
27
|
* Omitted hints let the MCP SDK use its defaults.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* import { deriveAnnotations } from '@ontrails/mcp';
|
|
32
|
+
*
|
|
33
|
+
* const annotations = deriveAnnotations({
|
|
34
|
+
* intent: 'read',
|
|
35
|
+
* idempotent: true,
|
|
36
|
+
* description: 'Show account',
|
|
37
|
+
* });
|
|
38
|
+
*
|
|
39
|
+
* // read intent -> readOnlyHint, idempotent -> idempotentHint, description -> title.
|
|
40
|
+
* annotations.readOnlyHint === true;
|
|
41
|
+
* annotations.idempotentHint === true;
|
|
42
|
+
* annotations.title === 'Show account';
|
|
43
|
+
*
|
|
44
|
+
* // destroy intent -> destructiveHint.
|
|
45
|
+
* const destroyAnnotations = deriveAnnotations({ intent: 'destroy' });
|
|
46
|
+
* destroyAnnotations.destructiveHint === true;
|
|
47
|
+
* ```
|
|
28
48
|
*/
|
|
29
49
|
export const deriveAnnotations = (
|
|
30
50
|
trail: Pick<
|
|
31
|
-
Trail<unknown, unknown>,
|
|
32
|
-
'
|
|
51
|
+
Trail<unknown, unknown, unknown>,
|
|
52
|
+
'intent' | 'idempotent' | 'description'
|
|
33
53
|
>
|
|
34
54
|
): McpAnnotations => {
|
|
35
55
|
const annotations: Record<string, unknown> = {};
|
|
36
56
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
57
|
+
const intentToHint: Partial<Record<Intent, string>> = {
|
|
58
|
+
destroy: 'destructiveHint',
|
|
59
|
+
read: 'readOnlyHint',
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const hint = intentToHint[trail.intent];
|
|
63
|
+
if (hint) {
|
|
64
|
+
annotations[hint] = true;
|
|
42
65
|
}
|
|
43
66
|
if (trail.idempotent === true) {
|
|
44
67
|
annotations['idempotentHint'] = true;
|