@ontrails/mcp 1.0.0-beta.0 → 1.0.0-beta.10
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/.turbo/turbo-lint.log +1 -1
- package/CHANGELOG.md +133 -0
- package/README.md +39 -103
- package/dist/annotations.d.ts +2 -2
- package/dist/annotations.d.ts.map +1 -1
- package/dist/annotations.js +8 -6
- package/dist/annotations.js.map +1 -1
- package/dist/blaze.d.ts +2 -0
- package/dist/blaze.d.ts.map +1 -1
- package/dist/blaze.js +12 -2
- package/dist/blaze.js.map +1 -1
- package/dist/build.d.ts +4 -1
- package/dist/build.d.ts.map +1 -1
- package/dist/build.js +79 -62
- package/dist/build.js.map +1 -1
- package/package.json +3 -3
- package/src/__tests__/annotations.test.ts +15 -22
- package/src/__tests__/blaze.test.ts +59 -14
- package/src/__tests__/build.test.ts +159 -61
- package/src/annotations.ts +11 -11
- package/src/blaze.ts +16 -2
- package/src/build.ts +119 -91
package/.turbo/turbo-lint.log
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,138 @@
|
|
|
1
1
|
# @ontrails/mcp
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Cleanup and hardening pass across all packages.
|
|
8
|
+
|
|
9
|
+
**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 `Surface` type, `adapters.ts`, `health.ts`, and `job.ts` proof-of-concept from published package.
|
|
10
|
+
|
|
11
|
+
**cli**: Remove vestigial `kind` checks from build. Run `validateTopo()` automatically in `blaze()` with opt-out via `validate: false`.
|
|
12
|
+
|
|
13
|
+
**http**: Remove vestigial `kind` checks from build. Run `validateTopo()` automatically in `blaze()` with opt-out.
|
|
14
|
+
|
|
15
|
+
**mcp**: Remove vestigial `kind` checks from build. Run `validateTopo()` automatically in `blaze()` with opt-out.
|
|
16
|
+
|
|
17
|
+
**warden**: Project-aware rule context preserved in trail wrappers.
|
|
18
|
+
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
- @ontrails/core@1.0.0-beta.10
|
|
21
|
+
|
|
22
|
+
## 1.0.0-beta.9
|
|
23
|
+
|
|
24
|
+
### Minor Changes
|
|
25
|
+
|
|
26
|
+
- Consolidated improvements across all surface packages.
|
|
27
|
+
|
|
28
|
+
**core**: Add `TrailResult<T>` utility type, `topo.ids()` and `topo.count` accessors, `dispatch()` for headless trail execution, and extract shared `executeTrail` pipeline used by CLI/MCP/HTTP.
|
|
29
|
+
|
|
30
|
+
**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.
|
|
31
|
+
|
|
32
|
+
**mcp**: Return `Result` from `buildMcpTools()` on collision instead of throwing.
|
|
33
|
+
|
|
34
|
+
**cli**: Verify exception catching via centralized `executeTrail`.
|
|
35
|
+
|
|
36
|
+
**testing**: Follow context awareness improvements.
|
|
37
|
+
|
|
38
|
+
**warden**: Refactor rules as composable trails with examples.
|
|
39
|
+
|
|
40
|
+
**schema**: Error code and empty body fixes.
|
|
41
|
+
|
|
42
|
+
### Patch Changes
|
|
43
|
+
|
|
44
|
+
- Updated dependencies
|
|
45
|
+
- @ontrails/core@1.0.0-beta.9
|
|
46
|
+
|
|
47
|
+
## 1.0.0-beta.8
|
|
48
|
+
|
|
49
|
+
### Patch Changes
|
|
50
|
+
|
|
51
|
+
- @ontrails/core@1.0.0-beta.8
|
|
52
|
+
|
|
53
|
+
## 1.0.0-beta.7
|
|
54
|
+
|
|
55
|
+
### Patch Changes
|
|
56
|
+
|
|
57
|
+
- @ontrails/core@1.0.0-beta.7
|
|
58
|
+
|
|
59
|
+
## 1.0.0-beta.6
|
|
60
|
+
|
|
61
|
+
### Patch Changes
|
|
62
|
+
|
|
63
|
+
- Updated dependencies
|
|
64
|
+
- @ontrails/core@1.0.0-beta.6
|
|
65
|
+
|
|
66
|
+
## 1.0.0-beta.5
|
|
67
|
+
|
|
68
|
+
### Patch Changes
|
|
69
|
+
|
|
70
|
+
- Updated dependencies
|
|
71
|
+
- @ontrails/core@1.0.0-beta.5
|
|
72
|
+
|
|
73
|
+
## 1.0.0-beta.4
|
|
74
|
+
|
|
75
|
+
### Major Changes
|
|
76
|
+
|
|
77
|
+
- API simplification: unified trail model, intent enum, run, metadata.
|
|
78
|
+
|
|
79
|
+
**BREAKING CHANGES:**
|
|
80
|
+
|
|
81
|
+
- `hike()` removed — use `trail()` with optional `follow: [...]` field
|
|
82
|
+
- `follows` renamed to `follow` (singular, matching `ctx.follow()`)
|
|
83
|
+
- `topo.hikes` removed — single `topo.trails` map
|
|
84
|
+
- `kind: 'hike'` removed — everything is `kind: 'trail'`
|
|
85
|
+
- `readOnly`/`destructive` booleans replaced by `intent: 'read' | 'write' | 'destroy'`
|
|
86
|
+
- `implementation` field renamed to `run`
|
|
87
|
+
- `markers` field renamed to `metadata`
|
|
88
|
+
- `testHike` renamed to `testFollows`, `HikeScenario` to `FollowScenario`
|
|
89
|
+
- `blaze()` now returns the surface handle (`Command` for CLI, `Server` for MCP)
|
|
90
|
+
|
|
91
|
+
### Patch Changes
|
|
92
|
+
|
|
93
|
+
- Updated dependencies
|
|
94
|
+
- @ontrails/core@1.0.0-beta.4
|
|
95
|
+
|
|
96
|
+
## 1.0.0-beta.3
|
|
97
|
+
|
|
98
|
+
### Minor Changes
|
|
99
|
+
|
|
100
|
+
- Bug fixes across all surface packages found via parallel Codex review.
|
|
101
|
+
|
|
102
|
+
**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.
|
|
103
|
+
|
|
104
|
+
**cli**: Switch blaze to parseAsync for proper async error handling, add boolean flag negation (--no-flag), and strict number parsing that rejects partial input.
|
|
105
|
+
|
|
106
|
+
**mcp**: Align BlobRef with core (including ReadableStream support) and detect tool-name collisions after normalization.
|
|
107
|
+
|
|
108
|
+
**testing**: Include hikes in testContracts validation, with follow-context awareness.
|
|
109
|
+
|
|
110
|
+
**warden**: Collect hike detour targets, validate detour refs in hike specs, and stop implementation-returns-result from walking into nested function bodies.
|
|
111
|
+
|
|
112
|
+
### Patch Changes
|
|
113
|
+
|
|
114
|
+
- Updated dependencies
|
|
115
|
+
- @ontrails/core@1.0.0-beta.3
|
|
116
|
+
|
|
117
|
+
## 1.0.0-beta.2
|
|
118
|
+
|
|
119
|
+
### Patch Changes
|
|
120
|
+
|
|
121
|
+
- Fix workspace dependency resolution in published packages. Now using bun publish
|
|
122
|
+
which correctly replaces workspace:^ with actual version numbers.
|
|
123
|
+
- Updated dependencies
|
|
124
|
+
- @ontrails/core@1.0.0-beta.2
|
|
125
|
+
|
|
126
|
+
## 1.0.0-beta.1
|
|
127
|
+
|
|
128
|
+
### Patch Changes
|
|
129
|
+
|
|
130
|
+
- Fix two blocking bugs from real-world migration:
|
|
131
|
+
- Published packages now resolve correctly (workspace:^ instead of workspace:\*)
|
|
132
|
+
- Error forwarding works across different success types (Err no longer carries phantom T)
|
|
133
|
+
- Updated dependencies
|
|
134
|
+
- @ontrails/core@1.0.0-beta.1
|
|
135
|
+
|
|
3
136
|
## 1.0.0-beta.0
|
|
4
137
|
|
|
5
138
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
# @ontrails/mcp
|
|
2
2
|
|
|
3
|
-
MCP surface adapter
|
|
3
|
+
MCP surface adapter. One `blaze()` call turns a topo into an MCP server with tool definitions, annotations, and progress bridging -- all derived from the trail contracts.
|
|
4
4
|
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
bun add @ontrails/mcp
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Quick Start
|
|
5
|
+
## Usage
|
|
12
6
|
|
|
13
7
|
```typescript
|
|
14
8
|
import { trail, topo, Result } from '@ontrails/core';
|
|
@@ -17,47 +11,24 @@ import { z } from 'zod';
|
|
|
17
11
|
|
|
18
12
|
const greet = trail('greet', {
|
|
19
13
|
input: z.object({ name: z.string().describe('Who to greet') }),
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
intent: 'read',
|
|
15
|
+
run: (input) => Result.ok(`Hello, ${input.name}!`),
|
|
22
16
|
});
|
|
23
17
|
|
|
24
18
|
const app = topo('myapp', { greet });
|
|
25
19
|
await blaze(app);
|
|
26
20
|
```
|
|
27
21
|
|
|
28
|
-
This starts an MCP server over stdio with a `myapp_greet` tool. The tool
|
|
29
|
-
|
|
30
|
-
Pure trails can return `Result` directly. The MCP surface still executes the normalized awaitable implementation shape under the hood.
|
|
31
|
-
|
|
32
|
-
## API Overview
|
|
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.
|
|
33
23
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
Start an MCP server with all trails registered as tools.
|
|
37
|
-
|
|
38
|
-
```typescript
|
|
39
|
-
await blaze(app, {
|
|
40
|
-
serverInfo: { name: 'myapp', version: '1.0.0' },
|
|
41
|
-
transport: 'stdio',
|
|
42
|
-
includeTrails: ['entity.show', 'search'],
|
|
43
|
-
excludeTrails: ['internal.debug'],
|
|
44
|
-
layers: [myAuthLayer],
|
|
45
|
-
createContext: () => createTrailContext({ logger: myLogger }),
|
|
46
|
-
});
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
### `buildMcpTools(app, options?)`
|
|
50
|
-
|
|
51
|
-
Build tool definitions without starting a server. For advanced use cases where you manage the MCP server instance directly.
|
|
24
|
+
For more control, build the tools yourself:
|
|
52
25
|
|
|
53
26
|
```typescript
|
|
54
27
|
import { buildMcpTools } from '@ontrails/mcp';
|
|
55
28
|
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
for (const tool of tools) {
|
|
29
|
+
const result = buildMcpTools(app);
|
|
30
|
+
if (result.isErr()) throw result.error; // ValidationError on tool-name collision
|
|
31
|
+
for (const tool of result.value) {
|
|
61
32
|
server.registerTool(tool.name, tool.handler, {
|
|
62
33
|
inputSchema: tool.inputSchema,
|
|
63
34
|
annotations: tool.annotations,
|
|
@@ -65,48 +36,44 @@ for (const tool of tools) {
|
|
|
65
36
|
}
|
|
66
37
|
```
|
|
67
38
|
|
|
68
|
-
|
|
39
|
+
`buildMcpTools` 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.
|
|
69
40
|
|
|
70
|
-
|
|
41
|
+
## API
|
|
71
42
|
|
|
72
|
-
|
|
|
73
|
-
|
|
|
74
|
-
| `
|
|
75
|
-
| `
|
|
76
|
-
| `
|
|
43
|
+
| Export | What it does |
|
|
44
|
+
| --- | --- |
|
|
45
|
+
| `blaze(app, options?)` | Start an MCP server with all trails as tools |
|
|
46
|
+
| `buildMcpTools(app, options?)` | Build tool definitions without starting a server |
|
|
47
|
+
| `deriveToolName(appName, trailId)` | Compute the MCP tool name from app and trail IDs |
|
|
48
|
+
| `deriveAnnotations(trail)` | Extract MCP annotations from trail intent and metadata |
|
|
49
|
+
| `createMcpProgressCallback(server)` | Bridge `ctx.progress` to MCP `notifications/progress` |
|
|
77
50
|
|
|
78
|
-
|
|
51
|
+
See the [API Reference](../../docs/api-reference.md) for the full list.
|
|
79
52
|
|
|
80
|
-
|
|
81
|
-
import { deriveToolName } from '@ontrails/mcp';
|
|
82
|
-
deriveToolName('myapp', 'entity.show'); // "myapp_entity_show"
|
|
83
|
-
```
|
|
53
|
+
## Annotations
|
|
84
54
|
|
|
85
|
-
|
|
55
|
+
Trail intent and metadata map directly to MCP annotations:
|
|
86
56
|
|
|
87
|
-
Trail
|
|
57
|
+
| Trail field | MCP annotation |
|
|
58
|
+
| --- | --- |
|
|
59
|
+
| `intent: 'read'` | `readOnlyHint: true` |
|
|
60
|
+
| `intent: 'destroy'` | `destructiveHint: true` |
|
|
61
|
+
| `idempotent: true` | `idempotentHint: true` |
|
|
62
|
+
| `description` | `title` |
|
|
88
63
|
|
|
89
|
-
|
|
90
|
-
| --- | --- | --- |
|
|
91
|
-
| `readOnly: true` | `readOnlyHint: true` | Tool does not modify state |
|
|
92
|
-
| `destructive: true` | `destructiveHint: true` | Tool has destructive side effects |
|
|
93
|
-
| `idempotent: true` | `idempotentHint: true` | Repeated calls are safe |
|
|
94
|
-
| `description` | `title` | Human-readable tool title |
|
|
64
|
+
No manual annotation definitions. The contract is the source of truth.
|
|
95
65
|
|
|
96
|
-
|
|
97
|
-
import { deriveAnnotations } from '@ontrails/mcp';
|
|
98
|
-
deriveAnnotations(showTrail); // { readOnlyHint: true, title: "Show entity details" }
|
|
99
|
-
```
|
|
66
|
+
## Tool naming
|
|
100
67
|
|
|
101
|
-
|
|
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.
|
|
102
69
|
|
|
103
|
-
|
|
70
|
+
## Progress bridge
|
|
104
71
|
|
|
105
|
-
|
|
72
|
+
Implementations report progress through `ctx.progress`. On MCP, these bridge to `notifications/progress` when the client sends a `progressToken`:
|
|
106
73
|
|
|
107
74
|
```typescript
|
|
108
75
|
const importTrail = trail('data.import', {
|
|
109
|
-
|
|
76
|
+
run: async (input, ctx) => {
|
|
110
77
|
for (let i = 0; i < items.length; i++) {
|
|
111
78
|
await processItem(items[i]);
|
|
112
79
|
ctx.progress?.({ type: 'progress', current: i + 1, total: items.length });
|
|
@@ -116,46 +83,15 @@ const importTrail = trail('data.import', {
|
|
|
116
83
|
});
|
|
117
84
|
```
|
|
118
85
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
### Result Mapping
|
|
122
|
-
|
|
123
|
-
| Trail Result | MCP Response |
|
|
124
|
-
| --- | --- |
|
|
125
|
-
| `Result.ok(value)` | `{ content: [{ type: "text", text: JSON.stringify(value) }] }` |
|
|
126
|
-
| `Result.err(error)` | `{ content: [{ type: "text", text: error.message }], isError: true }` |
|
|
127
|
-
| `BlobRef` with image MIME type | `{ content: [{ type: "image", data: "<base64>", mimeType: "..." }] }` |
|
|
128
|
-
|
|
129
|
-
### Trail Filtering
|
|
86
|
+
## Filtering
|
|
130
87
|
|
|
131
88
|
```typescript
|
|
132
|
-
|
|
133
|
-
await blaze(app, {
|
|
134
|
-
|
|
135
|
-
// Blacklist
|
|
136
|
-
await blaze(app, { excludeTrails: ['internal.debug', 'admin.reset'] });
|
|
89
|
+
await blaze(app, { includeTrails: ['entity.show', 'search'] });
|
|
90
|
+
await blaze(app, { excludeTrails: ['internal.debug'] });
|
|
137
91
|
```
|
|
138
92
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
### AbortSignal Propagation
|
|
142
|
-
|
|
143
|
-
The MCP client's abort signal propagates to `TrailContext.signal`. If the client cancels a tool call, the implementation's signal is aborted.
|
|
144
|
-
|
|
145
|
-
## Exports
|
|
93
|
+
## Installation
|
|
146
94
|
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
blaze,
|
|
150
|
-
buildMcpTools,
|
|
151
|
-
deriveToolName,
|
|
152
|
-
deriveAnnotations,
|
|
153
|
-
createMcpProgressCallback,
|
|
154
|
-
connectStdio,
|
|
155
|
-
} from '@ontrails/mcp';
|
|
95
|
+
```bash
|
|
96
|
+
bun add @ontrails/mcp
|
|
156
97
|
```
|
|
157
|
-
|
|
158
|
-
## Further Reading
|
|
159
|
-
|
|
160
|
-
- [MCP Surface Guide](../../docs/surfaces/mcp.md)
|
|
161
|
-
- [Getting Started](../../docs/getting-started.md)
|
package/dist/annotations.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Derive MCP tool annotations from trail spec
|
|
2
|
+
* Derive MCP tool annotations from trail spec fields.
|
|
3
3
|
*/
|
|
4
4
|
import type { Trail } from '@ontrails/core';
|
|
5
5
|
export interface McpAnnotations {
|
|
@@ -15,5 +15,5 @@ export interface McpAnnotations {
|
|
|
15
15
|
* Only sets hints that are explicitly declared on the trail.
|
|
16
16
|
* Omitted hints let the MCP SDK use its defaults.
|
|
17
17
|
*/
|
|
18
|
-
export declare const deriveAnnotations: (trail: Pick<Trail<unknown, unknown>, "
|
|
18
|
+
export declare const deriveAnnotations: (trail: Pick<Trail<unknown, unknown>, "intent" | "idempotent" | "description">) => McpAnnotations;
|
|
19
19
|
//# sourceMappingURL=annotations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotations.d.ts","sourceRoot":"","sources":["../src/annotations.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"annotations.d.ts","sourceRoot":"","sources":["../src/annotations.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAU,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAMpD,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC5C,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC/C,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9C,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC7C,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACrC;AAMD;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAC5B,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,QAAQ,GAAG,YAAY,GAAG,aAAa,CAAC,KAC5E,cAoBF,CAAC"}
|
package/dist/annotations.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Derive MCP tool annotations from trail spec
|
|
2
|
+
* Derive MCP tool annotations from trail spec fields.
|
|
3
3
|
*/
|
|
4
4
|
// ---------------------------------------------------------------------------
|
|
5
5
|
// Derivation
|
|
@@ -12,11 +12,13 @@
|
|
|
12
12
|
*/
|
|
13
13
|
export const deriveAnnotations = (trail) => {
|
|
14
14
|
const annotations = {};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
const intentToHint = {
|
|
16
|
+
destroy: 'destructiveHint',
|
|
17
|
+
read: 'readOnlyHint',
|
|
18
|
+
};
|
|
19
|
+
const hint = intentToHint[trail.intent];
|
|
20
|
+
if (hint) {
|
|
21
|
+
annotations[hint] = true;
|
|
20
22
|
}
|
|
21
23
|
if (trail.idempotent === true) {
|
|
22
24
|
annotations['idempotentHint'] = true;
|
package/dist/annotations.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotations.js","sourceRoot":"","sources":["../src/annotations.ts"],"names":[],"mappings":"AAAA;;GAEG;AAgBH,8EAA8E;AAC9E,aAAa;AACb,8EAA8E;AAE9E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,
|
|
1
|
+
{"version":3,"file":"annotations.js","sourceRoot":"","sources":["../src/annotations.ts"],"names":[],"mappings":"AAAA;;GAEG;AAgBH,8EAA8E;AAC9E,aAAa;AACb,8EAA8E;AAE9E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,KAA6E,EAC7D,EAAE;IAClB,MAAM,WAAW,GAA4B,EAAE,CAAC;IAEhD,MAAM,YAAY,GAAoC;QACpD,OAAO,EAAE,iBAAiB;QAC1B,IAAI,EAAE,cAAc;KACrB,CAAC;IAEF,MAAM,IAAI,GAAG,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACxC,IAAI,IAAI,EAAE,CAAC;QACT,WAAW,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAC3B,CAAC;IACD,IAAI,KAAK,CAAC,UAAU,KAAK,IAAI,EAAE,CAAC;QAC9B,WAAW,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAC;IACvC,CAAC;IACD,IAAI,KAAK,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QACpC,WAAW,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC,WAAW,CAAC;IAC3C,CAAC;IAED,OAAO,WAA6B,CAAC;AACvC,CAAC,CAAC"}
|
package/dist/blaze.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ export interface BlazeMcpOptions {
|
|
|
21
21
|
readonly version?: string | undefined;
|
|
22
22
|
} | undefined;
|
|
23
23
|
readonly transport?: 'stdio' | undefined;
|
|
24
|
+
/** Set to `false` to skip topo validation at startup. Defaults to `true`. */
|
|
25
|
+
readonly validate?: boolean | undefined;
|
|
24
26
|
}
|
|
25
27
|
/**
|
|
26
28
|
* Create an MCP Server instance and register all tools.
|
package/dist/blaze.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blaze.d.ts","sourceRoot":"","sources":["../src/blaze.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAKnE,OAAO,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"blaze.d.ts","sourceRoot":"","sources":["../src/blaze.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAKnE,OAAO,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAGhE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAQpD,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,aAAa,CAAC,EACnB,CAAC,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,GAC5C,SAAS,CAAC;IACd,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;IACvD,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;IACvD,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,KAAK,EAAE,GAAG,SAAS,CAAC;IAC/C,QAAQ,CAAC,UAAU,CAAC,EAChB;QACE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QACnC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;KACvC,GACD,SAAS,CAAC;IACd,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACzC,6EAA6E;IAC7E,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACzC;AAMD;;GAEG;AACH,eAAO,MAAM,eAAe,GAC1B,OAAO,iBAAiB,EAAE,EAC1B,MAAM;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,KACxD,MAmEF,CAAC;AAMF;;GAEG;AACH,eAAO,MAAM,KAAK,GAChB,KAAK,IAAI,EACT,UAAS,eAAoB,KAC5B,OAAO,CAAC,IAAI,CAyBd,CAAC"}
|
package/dist/blaze.js
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
12
12
|
import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
13
|
+
import { validateTopo } from '@ontrails/core';
|
|
13
14
|
import { buildMcpTools } from './build.js';
|
|
14
15
|
import { connectStdio } from './stdio.js';
|
|
15
16
|
// ---------------------------------------------------------------------------
|
|
@@ -81,13 +82,22 @@ export const createMcpServer = (tools, info) => {
|
|
|
81
82
|
* Build MCP tools from an App, create a server, and connect via stdio.
|
|
82
83
|
*/
|
|
83
84
|
export const blaze = async (app, options = {}) => {
|
|
84
|
-
|
|
85
|
+
if (options.validate !== false) {
|
|
86
|
+
const validated = validateTopo(app);
|
|
87
|
+
if (validated.isErr()) {
|
|
88
|
+
throw validated.error;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const toolsResult = buildMcpTools(app, {
|
|
85
92
|
createContext: options.createContext,
|
|
86
93
|
excludeTrails: options.excludeTrails,
|
|
87
94
|
includeTrails: options.includeTrails,
|
|
88
95
|
layers: options.layers,
|
|
89
96
|
});
|
|
90
|
-
|
|
97
|
+
if (toolsResult.isErr()) {
|
|
98
|
+
throw toolsResult.error;
|
|
99
|
+
}
|
|
100
|
+
const server = createMcpServer(toolsResult.value, {
|
|
91
101
|
name: options.serverInfo?.name ?? app.name,
|
|
92
102
|
version: options.serverInfo?.version ?? '0.1.0',
|
|
93
103
|
});
|
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;
|
|
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;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,OAAO,EAA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ACtB,MAAM,SAAS,CAAC,KAAK,CAAC;QACxB,CAAC;IACH,CAAC;IAED,MAAM,WAAW,GAAG,aAAa,CAAC,GAAG,EAAE;QACrC,aAAa,EAAE,OAAO,CAAC,aAAa;QACpC,aAAa,EAAE,OAAO,CAAC,aAAa;QACpC,aAAa,EAAE,OAAO,CAAC,aAAa;QACpC,MAAM,EAAE,OAAO,CAAC,MAAM;KACvB,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
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* validate input, compose layers, execute the implementation, and map
|
|
6
6
|
* Results to MCP responses.
|
|
7
7
|
*/
|
|
8
|
+
import { Result } from '@ontrails/core';
|
|
8
9
|
import type { Layer, Topo, TrailContext } from '@ontrails/core';
|
|
9
10
|
import type { McpAnnotations } from './annotations.js';
|
|
10
11
|
export interface BuildMcpToolsOptions {
|
|
@@ -19,6 +20,8 @@ export interface McpToolDefinition {
|
|
|
19
20
|
readonly handler: (args: Record<string, unknown>, extra: McpExtra) => Promise<McpToolResult>;
|
|
20
21
|
readonly inputSchema: Record<string, unknown>;
|
|
21
22
|
readonly name: string;
|
|
23
|
+
/** The trail ID this tool was derived from. */
|
|
24
|
+
readonly trailId: string;
|
|
22
25
|
}
|
|
23
26
|
export interface McpExtra {
|
|
24
27
|
readonly progressToken?: string | number | undefined;
|
|
@@ -36,5 +39,5 @@ export interface McpContent {
|
|
|
36
39
|
readonly type: 'text' | 'image' | 'resource';
|
|
37
40
|
readonly uri?: string | undefined;
|
|
38
41
|
}
|
|
39
|
-
export declare const buildMcpTools: (app: Topo, options?: BuildMcpToolsOptions) => McpToolDefinition[]
|
|
42
|
+
export declare const buildMcpTools: (app: Topo, options?: BuildMcpToolsOptions) => Result<McpToolDefinition[], Error>;
|
|
40
43
|
//# sourceMappingURL=build.d.ts.map
|
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;
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,MAAM,EAKP,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAW,KAAK,EAAE,IAAI,EAAS,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEhF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AASvD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,aAAa,CAAC,EACnB,CAAC,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,GAC5C,SAAS,CAAC;IACd,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;IACvD,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;IACvD,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,KAAK,EAAE,GAAG,SAAS,CAAC;CAChD;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,WAAW,EAAE,cAAc,GAAG,SAAS,CAAC;IACjD,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,QAAQ,CAAC,OAAO,EAAE,CAChB,IAAI,EAAE,M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