@ontrails/mcp 1.0.0-beta.12 → 1.0.0-beta.13
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 +60 -32
- package/README.md +10 -10
- package/dist/blaze.js +1 -1
- package/dist/blaze.js.map +1 -1
- package/dist/build.d.ts +6 -6
- package/dist/build.d.ts.map +1 -1
- package/dist/build.js +20 -20
- package/dist/build.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/stdio.d.ts +1 -1
- package/dist/stdio.js +1 -1
- package/dist/trailhead.d.ts +41 -0
- package/dist/trailhead.d.ts.map +1 -0
- package/dist/trailhead.js +108 -0
- package/dist/trailhead.js.map +1 -0
- package/package.json +1 -1
- package/src/__tests__/build.test.ts +45 -45
- package/src/__tests__/{blaze.test.ts → trailhead.test.ts} +20 -20
- package/src/build.ts +26 -26
- package/src/index.ts +2 -2
- package/src/stdio.ts +1 -1
- package/src/{blaze.ts → trailhead.ts} +14 -14
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,17 +1,45 @@
|
|
|
1
1
|
# @ontrails/mcp
|
|
2
2
|
|
|
3
|
-
## 1.0.0-beta.
|
|
3
|
+
## 1.0.0-beta.13
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Trail-native vocabulary cutover. Breaking API field renames across all packages:
|
|
8
|
+
|
|
9
|
+
- Trail spec: `run:` → `blaze:`, `follow:` → `crosses:`, `services:` → `provisions:`, `metadata:` → `meta:`, `emits:` → `signals:`
|
|
10
|
+
- Runtime: `ctx.follow()` → `ctx.cross()`, `ctx.emit()` → `ctx.signal()`, `ctx.signal` (abort) → `ctx.abortSignal`
|
|
11
|
+
- Entry points: `blaze(app)` → `trailhead(app)`
|
|
12
|
+
- Package rename: `@ontrails/crumbs` → `@ontrails/tracker`
|
|
13
|
+
- Wrapper types: `Layer` → `Gate`, `layers`/`middleware` → `gates`
|
|
14
|
+
- Transport: `surface` → `trailhead`, `adapter` → `connector`
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
6
17
|
|
|
7
|
-
- Complete trifecta for config, permits, and
|
|
18
|
+
- 6944147: Complete trifecta for config, permits, and tracker (formerly tracks)
|
|
8
19
|
|
|
9
|
-
- **config**: Add `
|
|
20
|
+
- **config**: Add `configProvision`, `configGate`, `config.trail`, and `config.workspace` trails with full `defineConfig`, `resolve`, `describe`, `explain`, `doctor`, and code generation support
|
|
10
21
|
- **permits**: Add `authService` and `auth.verify` trail for runtime authorization checks
|
|
11
|
-
- **
|
|
22
|
+
- **tracker**: Rename tracks to tracker; add `trackerProvision` and `tracker.status` trail for structured signal tracking
|
|
23
|
+
- **cli**: Fix build flag handling and improve bootstrap scaffolding
|
|
24
|
+
- **testing**: Expand test context helpers and example-based testing utilities
|
|
25
|
+
- **core/mcp/http**: Internal alignment for provision and composition updates
|
|
26
|
+
|
|
27
|
+
- Updated dependencies [6944147]
|
|
28
|
+
- Updated dependencies
|
|
29
|
+
- @ontrails/core@1.0.0-beta.13
|
|
30
|
+
|
|
31
|
+
## 1.0.0-beta.12
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- Complete trifecta for config, permits, and tracker (formerly tracks)
|
|
36
|
+
|
|
37
|
+
- **config**: Add `configProvision`, `config.gate`, `config.trail`, and `config.workspace` trails with full `defineConfig`, `resolve`, `describe`, `explain`, `doctor`, and code generation support
|
|
38
|
+
- **permits**: Add `authProvision` and `auth.verify` trail for runtime authorization checks
|
|
39
|
+
- **tracker**: Rename tracks to tracker; add `trackerProvision` and `tracker.status` trail for structured event tracking
|
|
12
40
|
- **cli**: Fix build flag handling and improve bootstrap scaffolding
|
|
13
41
|
- **testing**: Expand test context helpers and example-based testing utilities
|
|
14
|
-
- **core/mcp/http**: Internal alignment for
|
|
42
|
+
- **core/mcp/http**: Internal alignment for provision and composition updates
|
|
15
43
|
|
|
16
44
|
- Updated dependencies
|
|
17
45
|
- @ontrails/core@1.0.0-beta.12
|
|
@@ -20,21 +48,21 @@
|
|
|
20
48
|
|
|
21
49
|
### Patch Changes
|
|
22
50
|
|
|
23
|
-
- Add
|
|
51
|
+
- Add provisions as a first-class primitive.
|
|
24
52
|
|
|
25
|
-
|
|
53
|
+
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()`.
|
|
26
54
|
|
|
27
|
-
**Core:** `
|
|
55
|
+
**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.
|
|
28
56
|
|
|
29
|
-
**Testing:** Auto-resolution of `mock` factories in `testAll`, `testExamples`, `testContracts`, and `
|
|
57
|
+
**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.
|
|
30
58
|
|
|
31
|
-
**Warden:** `
|
|
59
|
+
**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.
|
|
32
60
|
|
|
33
|
-
**
|
|
61
|
+
**Trailheads:** Provision overrides thread through `run` and `trailhead` on CLI, MCP, and HTTP.
|
|
34
62
|
|
|
35
|
-
**Introspection:** Survey and
|
|
63
|
+
**Introspection:** Survey and trailhead map outputs include provision graph. Topo exposes `.provisions`, `.getProvision()`, `.hasProvision()`, `.listProvisions()`, `.provisionIds()`, `.provisionCount`.
|
|
36
64
|
|
|
37
|
-
**Docs:** ADR-009 accepted. Unified
|
|
65
|
+
**Docs:** ADR-009 accepted. Unified provisions guide, updated vocabulary, getting-started, architecture, and package READMEs.
|
|
38
66
|
|
|
39
67
|
- Updated dependencies
|
|
40
68
|
- @ontrails/core@1.0.0-beta.11
|
|
@@ -45,13 +73,13 @@
|
|
|
45
73
|
|
|
46
74
|
- Cleanup and hardening pass across all packages.
|
|
47
75
|
|
|
48
|
-
**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 `
|
|
76
|
+
**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.
|
|
49
77
|
|
|
50
|
-
**cli**: Remove vestigial `kind` checks from build. Run `validateTopo()` automatically in `
|
|
78
|
+
**cli**: Remove vestigial `kind` checks from build. Run `validateTopo()` automatically in `trailhead()` with opt-out via `validate: false`.
|
|
51
79
|
|
|
52
|
-
**http**: Remove vestigial `kind` checks from build. Run `validateTopo()` automatically in `
|
|
80
|
+
**http**: Remove vestigial `kind` checks from build. Run `validateTopo()` automatically in `trailhead()` with opt-out.
|
|
53
81
|
|
|
54
|
-
**mcp**: Remove vestigial `kind` checks from build. Run `validateTopo()` automatically in `
|
|
82
|
+
**mcp**: Remove vestigial `kind` checks from build. Run `validateTopo()` automatically in `trailhead()` with opt-out.
|
|
55
83
|
|
|
56
84
|
**warden**: Project-aware rule context preserved in trail wrappers.
|
|
57
85
|
|
|
@@ -62,9 +90,9 @@
|
|
|
62
90
|
|
|
63
91
|
### Minor Changes
|
|
64
92
|
|
|
65
|
-
- Consolidated improvements across all
|
|
93
|
+
- Consolidated improvements across all trailhead packages.
|
|
66
94
|
|
|
67
|
-
**core**: Add `TrailResult<T>` utility type, `topo.ids()` and `topo.count` accessors, `
|
|
95
|
+
**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.
|
|
68
96
|
|
|
69
97
|
**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.
|
|
70
98
|
|
|
@@ -72,7 +100,7 @@
|
|
|
72
100
|
|
|
73
101
|
**cli**: Verify exception catching via centralized `executeTrail`.
|
|
74
102
|
|
|
75
|
-
**testing**:
|
|
103
|
+
**testing**: Cross-context awareness improvements.
|
|
76
104
|
|
|
77
105
|
**warden**: Refactor rules as composable trails with examples.
|
|
78
106
|
|
|
@@ -117,15 +145,15 @@
|
|
|
117
145
|
|
|
118
146
|
**BREAKING CHANGES:**
|
|
119
147
|
|
|
120
|
-
- `hike()` removed — use `trail()` with optional `
|
|
121
|
-
- `follows` renamed to `
|
|
148
|
+
- `hike()` removed — use `trail()` with optional `crosses: [...]` field
|
|
149
|
+
- `follows` renamed to `crosses` (matching `ctx.cross()`)
|
|
122
150
|
- `topo.hikes` removed — single `topo.trails` map
|
|
123
151
|
- `kind: 'hike'` removed — everything is `kind: 'trail'`
|
|
124
152
|
- `readOnly`/`destructive` booleans replaced by `intent: 'read' | 'write' | 'destroy'`
|
|
125
153
|
- `implementation` field renamed to `run`
|
|
126
154
|
- `markers` field renamed to `metadata`
|
|
127
|
-
- `testHike` renamed to `
|
|
128
|
-
- `
|
|
155
|
+
- `testHike` renamed to `testCrosses`, `HikeScenario` to `CrossScenario`
|
|
156
|
+
- `trailhead()` now returns the trailhead handle (`Command` for CLI, `Server` for MCP)
|
|
129
157
|
|
|
130
158
|
### Patch Changes
|
|
131
159
|
|
|
@@ -136,15 +164,15 @@
|
|
|
136
164
|
|
|
137
165
|
### Minor Changes
|
|
138
166
|
|
|
139
|
-
- Bug fixes across all
|
|
167
|
+
- Bug fixes across all trailhead packages found via parallel Codex review.
|
|
140
168
|
|
|
141
169
|
**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.
|
|
142
170
|
|
|
143
|
-
**cli**: Switch
|
|
171
|
+
**cli**: Switch trailhead to parseAsync for proper async error handling, add boolean flag negation (--no-flag), and strict number parsing that rejects partial input.
|
|
144
172
|
|
|
145
173
|
**mcp**: Align BlobRef with core (including ReadableStream support) and detect tool-name collisions after normalization.
|
|
146
174
|
|
|
147
|
-
**testing**: Include hikes in testContracts validation, with
|
|
175
|
+
**testing**: Include hikes in testContracts validation, with cross-context awareness.
|
|
148
176
|
|
|
149
177
|
**warden**: Collect hike detour targets, validate detour refs in hike specs, and stop implementation-returns-result from walking into nested function bodies.
|
|
150
178
|
|
|
@@ -179,12 +207,12 @@
|
|
|
179
207
|
- Initial v1 beta release of the Trails framework.
|
|
180
208
|
|
|
181
209
|
- **@ontrails/core** — Result type, error taxonomy, trail/hike/event/topo, validateTopo, validateInput/Output, deriveFields, patterns, redaction, branded types, resilience
|
|
182
|
-
- **@ontrails/cli** — CLI
|
|
183
|
-
- **@ontrails/mcp** — MCP
|
|
184
|
-
- **@ontrails/logging** — Structured logging, sinks, formatters, LogTape
|
|
185
|
-
- **@ontrails/testing** — testAll, testExamples, testTrail, testHike, testContracts, testDetours,
|
|
210
|
+
- **@ontrails/cli** — CLI trailhead connector, Commander integration, flag derivation, gates
|
|
211
|
+
- **@ontrails/mcp** — MCP trailhead connector, tool generation, annotations, progress bridge
|
|
212
|
+
- **@ontrails/logging** — Structured logging, sinks, formatters, LogTape connector
|
|
213
|
+
- **@ontrails/testing** — testAll, testExamples, testTrail, testHike, testContracts, testDetours, trailhead harnesses
|
|
186
214
|
- **@ontrails/warden** — AST-based code convention rules via oxc-parser, drift detection, CI formatters
|
|
187
|
-
- **@ontrails/schema** —
|
|
215
|
+
- **@ontrails/schema** — Trailhead map generation, hashing, semantic diffing
|
|
188
216
|
|
|
189
217
|
### Patch Changes
|
|
190
218
|
|
package/README.md
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
# @ontrails/mcp
|
|
2
2
|
|
|
3
|
-
MCP
|
|
3
|
+
MCP trailhead connector. One `trailhead()` 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 { trailhead } 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
14
|
intent: 'read',
|
|
15
|
-
|
|
15
|
+
blaze: (input) => Result.ok(`Hello, ${input.name}!`),
|
|
16
16
|
});
|
|
17
17
|
|
|
18
18
|
const app = topo('myapp', { greet });
|
|
19
|
-
await
|
|
19
|
+
await trailhead(app);
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
This starts an MCP server over stdio with a `myapp_greet` tool. The tool gets `readOnlyHint: true` and a JSON Schema input -- both derived from the trail definition.
|
|
@@ -42,7 +42,7 @@ for (const tool of result.value) {
|
|
|
42
42
|
|
|
43
43
|
| Export | What it does |
|
|
44
44
|
| --- | --- |
|
|
45
|
-
| `
|
|
45
|
+
| `trailhead(app, options?)` | Start an MCP server with all trails as tools |
|
|
46
46
|
| `buildMcpTools(app, options?)` | Build tool definitions without starting a server |
|
|
47
47
|
| `deriveToolName(appName, trailId)` | Compute the MCP tool name from app and trail IDs |
|
|
48
48
|
| `deriveAnnotations(trail)` | Extract MCP annotations from trail intent and metadata |
|
|
@@ -67,9 +67,9 @@ No manual annotation definitions. The contract is the source of truth.
|
|
|
67
67
|
|
|
68
68
|
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.
|
|
69
69
|
|
|
70
|
-
##
|
|
70
|
+
## Provision resolution
|
|
71
71
|
|
|
72
|
-
Declared
|
|
72
|
+
Declared provisions on each trail are resolved into the context before the implementation runs.
|
|
73
73
|
|
|
74
74
|
## Progress bridge
|
|
75
75
|
|
|
@@ -77,7 +77,7 @@ Implementations report progress through `ctx.progress`. On MCP, these bridge to
|
|
|
77
77
|
|
|
78
78
|
```typescript
|
|
79
79
|
const importTrail = trail('data.import', {
|
|
80
|
-
|
|
80
|
+
blaze: async (input, ctx) => {
|
|
81
81
|
for (let i = 0; i < items.length; i++) {
|
|
82
82
|
await processItem(items[i]);
|
|
83
83
|
ctx.progress?.({ type: 'progress', current: i + 1, total: items.length });
|
|
@@ -90,8 +90,8 @@ const importTrail = trail('data.import', {
|
|
|
90
90
|
## Filtering
|
|
91
91
|
|
|
92
92
|
```typescript
|
|
93
|
-
await
|
|
94
|
-
await
|
|
93
|
+
await trailhead(app, { includeTrails: ['entity.show', 'search'] });
|
|
94
|
+
await trailhead(app, { excludeTrails: ['internal.debug'] });
|
|
95
95
|
```
|
|
96
96
|
|
|
97
97
|
## Installation
|
package/dist/blaze.js
CHANGED
|
@@ -65,9 +65,9 @@ export const createMcpServer = (tools, info) => {
|
|
|
65
65
|
});
|
|
66
66
|
};
|
|
67
67
|
const extra = {
|
|
68
|
+
abortSignal: undefined,
|
|
68
69
|
progressToken,
|
|
69
70
|
sendProgress,
|
|
70
|
-
signal: undefined,
|
|
71
71
|
};
|
|
72
72
|
const result = await tool.handler(args, extra);
|
|
73
73
|
// Spread to satisfy MCP SDK's index-signature requirement
|
package/dist/blaze.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blaze.js","sourceRoot":"","sources":["../src/blaze.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;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CAAC,aAAa;QACpC,aAAa,EAAE,OAAO,CAAC,aAAa;QACpC,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,QAAQ,EAAE,OAAO,CAAC,QAAQ;KAC3B,CAAC,CAAC;IAEH,IAAI,WAAW,CAAC,KAAK,EAAE,EAAE,CAAC;QACxB,MAAM,WAAW,CAAC,KAAK,CAAC;IAC1B,CAAC;IAED,MAAM,MAAM,GAAG,eAAe,CAAC,WAAW,CAAC,KAAK,EAAE;QAChD,IAAI,EAAE,OAAO,CAAC,UAAU,EAAE,IAAI,IAAI,GAAG,CAAC,IAAI;QAC1C,OAAO,EAAE,OAAO,CAAC,UAAU,EAAE,OAAO,IAAI,OAAO;KAChD,CAAC,CAAC;IAEH,MAAM,YAAY,CAAC,MAAM,CAAC,CAAC;AAC7B,CAAC,CAAC"}
|
package/dist/build.d.ts
CHANGED
|
@@ -2,20 +2,20 @@
|
|
|
2
2
|
* Build MCP tool definitions from a Trails App.
|
|
3
3
|
*
|
|
4
4
|
* Iterates the topo, generates McpToolDefinition[] with handlers that
|
|
5
|
-
* validate input, compose
|
|
5
|
+
* validate input, compose gates, execute the implementation, and map
|
|
6
6
|
* Results to MCP responses.
|
|
7
7
|
*/
|
|
8
8
|
import { Result } from '@ontrails/core';
|
|
9
|
-
import type {
|
|
9
|
+
import type { Gate, ProvisionOverrideMap, Topo, TrailContextInit } from '@ontrails/core';
|
|
10
10
|
import type { McpAnnotations } from './annotations.js';
|
|
11
11
|
export interface BuildMcpToolsOptions {
|
|
12
|
-
/** Config values for
|
|
12
|
+
/** Config values for provisions that declare a `config` schema, keyed by provision ID. */
|
|
13
13
|
readonly configValues?: Readonly<Record<string, Record<string, unknown>>> | undefined;
|
|
14
14
|
readonly createContext?: (() => TrailContextInit | Promise<TrailContextInit>) | undefined;
|
|
15
15
|
readonly excludeTrails?: readonly string[] | undefined;
|
|
16
16
|
readonly includeTrails?: readonly string[] | undefined;
|
|
17
|
-
readonly
|
|
18
|
-
readonly
|
|
17
|
+
readonly gates?: readonly Gate[] | undefined;
|
|
18
|
+
readonly provisions?: ProvisionOverrideMap | undefined;
|
|
19
19
|
}
|
|
20
20
|
export interface McpToolDefinition {
|
|
21
21
|
readonly annotations: McpAnnotations | undefined;
|
|
@@ -29,7 +29,7 @@ export interface McpToolDefinition {
|
|
|
29
29
|
export interface McpExtra {
|
|
30
30
|
readonly progressToken?: string | number | undefined;
|
|
31
31
|
readonly sendProgress?: ((current: number, total: number) => Promise<void>) | undefined;
|
|
32
|
-
readonly
|
|
32
|
+
readonly abortSignal?: AbortSignal | undefined;
|
|
33
33
|
}
|
|
34
34
|
export interface McpToolResult {
|
|
35
35
|
readonly content: readonly McpContent[];
|
package/dist/build.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,MAAM,EAMP,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAEV,
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,MAAM,EAMP,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAEV,IAAI,EACJ,oBAAoB,EACpB,IAAI,EAEJ,gBAAgB,EACjB,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AASvD,MAAM,WAAW,oBAAoB;IACnC,0FAA0F;IAC1F,QAAQ,CAAC,YAAY,CAAC,EAClB,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,GACjD,SAAS,CAAC;IACd,QAAQ,CAAC,aAAa,CAAC,EACnB,CAAC,MAAM,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,GACpD,SAAS,CAAC;I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AAU;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,UAAU,CAAC;IAC7C,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACnC;AA8QD,eAAO,MAAM,aAAa,GACxB,KAAK,IAAI,EACT,UAAS,oBAAyB,KACjC,MAAM,CAAC,iBAAiB,EAAE,EAAE,KAAK,CAoBnC,CAAC"}
|
package/dist/build.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* Build MCP tool definitions from a Trails App.
|
|
3
3
|
*
|
|
4
4
|
* Iterates the topo, generates McpToolDefinition[] with handlers that
|
|
5
|
-
* validate input, compose
|
|
5
|
+
* validate input, compose gates, execute the implementation, and map
|
|
6
6
|
* Results to MCP responses.
|
|
7
7
|
*/
|
|
8
|
-
import { Result,
|
|
8
|
+
import { Result, TRAILHEAD_KEY, ValidationError, executeTrail, isBlobRef, zodToJsonSchema, } from '@ontrails/core';
|
|
9
9
|
import { deriveAnnotations } from './annotations.js';
|
|
10
10
|
import { createMcpProgressCallback } from './progress.js';
|
|
11
11
|
import { deriveToolName } from './tool-name.js';
|
|
@@ -114,22 +114,22 @@ const mcpError = (message) => ({
|
|
|
114
114
|
content: [{ text: message, type: 'text' }],
|
|
115
115
|
isError: true,
|
|
116
116
|
});
|
|
117
|
-
/** Add the MCP
|
|
118
|
-
const
|
|
117
|
+
/** Add the MCP trailhead marker while preserving any existing context extras. */
|
|
118
|
+
const withMcpTrailhead = (progressCb) => ({
|
|
119
119
|
...(progressCb === undefined ? {} : { progress: progressCb }),
|
|
120
120
|
extensions: {
|
|
121
|
-
[
|
|
121
|
+
[TRAILHEAD_KEY]: 'mcp',
|
|
122
122
|
},
|
|
123
123
|
});
|
|
124
|
-
const createHandler = (t,
|
|
124
|
+
const createHandler = (t, gates, options) => async (args, extra) => {
|
|
125
125
|
const progressCb = createMcpProgressCallback(extra);
|
|
126
126
|
const result = await executeTrail(t, args, {
|
|
127
|
+
abortSignal: extra.abortSignal,
|
|
127
128
|
configValues: options.configValues,
|
|
128
129
|
createContext: options.createContext,
|
|
129
|
-
ctx:
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
signal: extra.signal,
|
|
130
|
+
ctx: withMcpTrailhead(progressCb),
|
|
131
|
+
gates,
|
|
132
|
+
provisions: options.provisions,
|
|
133
133
|
});
|
|
134
134
|
if (result.isOk()) {
|
|
135
135
|
return { content: await serializeOutput(result.value) };
|
|
@@ -145,12 +145,12 @@ const createHandler = (t, layers, options) => async (args, extra) => {
|
|
|
145
145
|
* Each trail in the topo becomes an McpToolDefinition with:
|
|
146
146
|
* - A derived tool name (app-prefixed, underscore-delimited)
|
|
147
147
|
* - JSON Schema input from zodToJsonSchema
|
|
148
|
-
* - MCP annotations from trail
|
|
149
|
-
* - A handler that validates, composes
|
|
148
|
+
* - MCP annotations from trail meta
|
|
149
|
+
* - A handler that validates, composes gates, executes, and maps results
|
|
150
150
|
*/
|
|
151
|
-
/** Check if a trail should be included based on
|
|
151
|
+
/** Check if a trail should be included based on meta and filters. */
|
|
152
152
|
const shouldInclude = (trail, options) => {
|
|
153
|
-
if (trail.
|
|
153
|
+
if (trail.meta?.['internal'] === true) {
|
|
154
154
|
return false;
|
|
155
155
|
}
|
|
156
156
|
if (options.includeTrails !== undefined && options.includeTrails.length > 0) {
|
|
@@ -176,37 +176,37 @@ const buildDescription = (trail) => {
|
|
|
176
176
|
return description;
|
|
177
177
|
};
|
|
178
178
|
/** Build a single MCP tool definition from a trail. */
|
|
179
|
-
const buildToolDefinition = (app, trail,
|
|
179
|
+
const buildToolDefinition = (app, trail, gates, options) => {
|
|
180
180
|
const rawAnnotations = deriveAnnotations(trail);
|
|
181
181
|
const annotations = Object.keys(rawAnnotations).length > 0 ? rawAnnotations : undefined;
|
|
182
182
|
return {
|
|
183
183
|
annotations,
|
|
184
184
|
description: buildDescription(trail),
|
|
185
|
-
handler: createHandler(trail,
|
|
185
|
+
handler: createHandler(trail, gates, options),
|
|
186
186
|
inputSchema: zodToJsonSchema(trail.input),
|
|
187
187
|
name: deriveToolName(app.name, trail.id),
|
|
188
188
|
trailId: trail.id,
|
|
189
189
|
};
|
|
190
190
|
};
|
|
191
191
|
/** Register a trail as an MCP tool, checking for name collisions. */
|
|
192
|
-
const registerTool = (app, trailItem,
|
|
192
|
+
const registerTool = (app, trailItem, gates, options, nameToTrailId, tools) => {
|
|
193
193
|
const toolName = deriveToolName(app.name, trailItem.id);
|
|
194
194
|
const existingId = nameToTrailId.get(toolName);
|
|
195
195
|
if (existingId !== undefined) {
|
|
196
196
|
return Result.err(new ValidationError(`MCP tool-name collision: trails "${existingId}" and "${trailItem.id}" both derive the tool name "${toolName}"`));
|
|
197
197
|
}
|
|
198
198
|
nameToTrailId.set(toolName, trailItem.id);
|
|
199
|
-
tools.push(buildToolDefinition(app, trailItem,
|
|
199
|
+
tools.push(buildToolDefinition(app, trailItem, gates, options));
|
|
200
200
|
return Result.ok();
|
|
201
201
|
};
|
|
202
202
|
/** Filter topo items to eligible trails. */
|
|
203
203
|
const eligibleTrails = (app, options) => app.list().filter((trail) => shouldInclude(trail, options));
|
|
204
204
|
export const buildMcpTools = (app, options = {}) => {
|
|
205
|
-
const
|
|
205
|
+
const gates = options.gates ?? [];
|
|
206
206
|
const tools = [];
|
|
207
207
|
const nameToTrailId = new Map();
|
|
208
208
|
for (const trailItem of eligibleTrails(app, options)) {
|
|
209
|
-
const registered = registerTool(app, trailItem,
|
|
209
|
+
const registered = registerTool(app, trailItem, gates, options, nameToTrailId, tools);
|
|
210
210
|
if (registered.isErr()) {
|
|
211
211
|
return registered;
|
|
212
212
|
}
|
package/dist/build.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,MAAM,EACN,
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,MAAM,EACN,aAAa,EACb,eAAe,EACf,YAAY,EACZ,SAAS,EACT,eAAe,GAChB,MAAM,gBAAgB,CAAC;AAWxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAsDhD,8EAA8E;AAC9E,wCAAwC;AACxC,8EAA8E;AAE9E,0EAA0E;AAC1E,MAAM,YAAY,GAAG,CACnB,MAAoB,EACpB,WAAmB,EACP,EAAE;IACd,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC;IAC3C,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC;IACzB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF,yDAAyD;AACzD,MAAM,aAAa,GAAG,KAAK,EACzB,MAAkC,EACb,EAAE;IACvB,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,EAAE,CAAC;IAClC,MAAM,MAAM,GAAiB,EAAE,CAAC;IAChC,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,SAAS,CAAC;QACR,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;QAC5C,IAAI,IAAI,EAAE,CAAC;YAC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d.ts
CHANGED
|
@@ -2,6 +2,6 @@ export { buildMcpTools, type BuildMcpToolsOptions, type McpToolDefinition, type
|
|
|
2
2
|
export { deriveToolName } from './tool-name.js';
|
|
3
3
|
export { deriveAnnotations, type McpAnnotations } from './annotations.js';
|
|
4
4
|
export { createMcpProgressCallback } from './progress.js';
|
|
5
|
-
export {
|
|
5
|
+
export { trailhead, type TrailheadMcpOptions } from './trailhead.js';
|
|
6
6
|
export { connectStdio } from './stdio.js';
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,QAAQ,GACd,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGhD,OAAO,EAAE,iBAAiB,EAAE,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAG1E,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAG1D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,QAAQ,GACd,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGhD,OAAO,EAAE,iBAAiB,EAAE,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAG1E,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAG1D,OAAO,EAAE,SAAS,EAAE,KAAK,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAGrE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -6,8 +6,8 @@ export { deriveToolName } from './tool-name.js';
|
|
|
6
6
|
export { deriveAnnotations } from './annotations.js';
|
|
7
7
|
// Progress
|
|
8
8
|
export { createMcpProgressCallback } from './progress.js';
|
|
9
|
-
//
|
|
10
|
-
export {
|
|
9
|
+
// Trailhead
|
|
10
|
+
export { trailhead } from './trailhead.js';
|
|
11
11
|
// Transport
|
|
12
12
|
export { connectStdio } from './stdio.js';
|
|
13
13
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,QAAQ;AACR,OAAO,EACL,aAAa,GAMd,MAAM,YAAY,CAAC;AAEpB,cAAc;AACd,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,cAAc;AACd,OAAO,EAAE,iBAAiB,EAAuB,MAAM,kBAAkB,CAAC;AAE1E,WAAW;AACX,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAE1D,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,QAAQ;AACR,OAAO,EACL,aAAa,GAMd,MAAM,YAAY,CAAC;AAEpB,cAAc;AACd,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,cAAc;AACd,OAAO,EAAE,iBAAiB,EAAuB,MAAM,kBAAkB,CAAC;AAE1E,WAAW;AACX,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAE1D,YAAY;AACZ,OAAO,EAAE,SAAS,EAA4B,MAAM,gBAAgB,CAAC;AAErE,YAAY;AACZ,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/stdio.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Thin wrapper around MCP SDK's StdioServerTransport.
|
|
3
3
|
*
|
|
4
4
|
* Exists as a separate function so it can be swapped for other transports
|
|
5
|
-
* (SSE, streamable HTTP) without changing
|
|
5
|
+
* (SSE, streamable HTTP) without changing trailhead().
|
|
6
6
|
*/
|
|
7
7
|
import type { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
8
8
|
/**
|
package/dist/stdio.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Thin wrapper around MCP SDK's StdioServerTransport.
|
|
3
3
|
*
|
|
4
4
|
* Exists as a separate function so it can be swapped for other transports
|
|
5
|
-
* (SSE, streamable HTTP) without changing
|
|
5
|
+
* (SSE, streamable HTTP) without changing trailhead().
|
|
6
6
|
*/
|
|
7
7
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
8
8
|
/**
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* trailhead() -- the one-liner MCP server launcher.
|
|
3
|
+
*
|
|
4
|
+
* Three lines to expose trails as MCP tools:
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* const app = topo("myapp", entity);
|
|
8
|
+
* await trailhead(app);
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
12
|
+
import type { Gate, ProvisionOverrideMap, Topo, TrailContextInit } from '@ontrails/core';
|
|
13
|
+
import type { McpToolDefinition } from './build.js';
|
|
14
|
+
export interface TrailheadMcpOptions {
|
|
15
|
+
/** Config values for provisions that declare a `config` schema, keyed by provision ID. */
|
|
16
|
+
readonly configValues?: Readonly<Record<string, Record<string, unknown>>> | undefined;
|
|
17
|
+
readonly createContext?: (() => TrailContextInit | Promise<TrailContextInit>) | undefined;
|
|
18
|
+
readonly excludeTrails?: readonly string[] | undefined;
|
|
19
|
+
readonly includeTrails?: readonly string[] | undefined;
|
|
20
|
+
readonly gates?: readonly Gate[] | undefined;
|
|
21
|
+
readonly provisions?: ProvisionOverrideMap | undefined;
|
|
22
|
+
readonly serverInfo?: {
|
|
23
|
+
readonly name?: string | undefined;
|
|
24
|
+
readonly version?: string | undefined;
|
|
25
|
+
} | undefined;
|
|
26
|
+
readonly transport?: 'stdio' | undefined;
|
|
27
|
+
/** Set to `false` to skip topo validation at startup. Defaults to `true`. */
|
|
28
|
+
readonly validate?: boolean | undefined;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Create an MCP Server instance and register all tools.
|
|
32
|
+
*/
|
|
33
|
+
export declare const createMcpServer: (tools: McpToolDefinition[], info: {
|
|
34
|
+
readonly name: string;
|
|
35
|
+
readonly version: string;
|
|
36
|
+
}) => Server;
|
|
37
|
+
/**
|
|
38
|
+
* Build MCP tools from an App, create a server, and connect via stdio.
|
|
39
|
+
*/
|
|
40
|
+
export declare const trailhead: (app: Topo, options?: TrailheadMcpOptions) => Promise<void>;
|
|
41
|
+
//# sourceMappingURL=trailhead.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trailhead.d.ts","sourceRoot":"","sources":["../src/trailhead.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAKnE,OAAO,KAAK,EACV,IAAI,EACJ,oBAAoB,EACpB,IAAI,EACJ,gBAAgB,EACjB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAQpD,MAAM,WAAW,mBAAmB;IAClC,0FAA0F;IAC1F,QAAQ,CAAC,YAAY,CAAC,EAClB,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,GACjD,SAAS,CAAC;IACd,QAAQ,CAAC,aAAa,CAAC,EACnB,CAAC,MAAM,gBAAgB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