@ontrails/mcp 1.0.0-beta.0

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.
Files changed (48) hide show
  1. package/.turbo/turbo-build.log +1 -0
  2. package/.turbo/turbo-lint.log +3 -0
  3. package/.turbo/turbo-typecheck.log +1 -0
  4. package/CHANGELOG.md +20 -0
  5. package/README.md +161 -0
  6. package/dist/annotations.d.ts +19 -0
  7. package/dist/annotations.d.ts.map +1 -0
  8. package/dist/annotations.js +29 -0
  9. package/dist/annotations.js.map +1 -0
  10. package/dist/blaze.d.ts +36 -0
  11. package/dist/blaze.d.ts.map +1 -0
  12. package/dist/blaze.js +96 -0
  13. package/dist/blaze.js.map +1 -0
  14. package/dist/build.d.ts +40 -0
  15. package/dist/build.d.ts.map +1 -0
  16. package/dist/build.js +190 -0
  17. package/dist/build.js.map +1 -0
  18. package/dist/index.d.ts +7 -0
  19. package/dist/index.d.ts.map +1 -0
  20. package/dist/index.js +13 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/progress.d.ts +13 -0
  23. package/dist/progress.d.ts.map +1 -0
  24. package/dist/progress.js +51 -0
  25. package/dist/progress.js.map +1 -0
  26. package/dist/stdio.d.ts +12 -0
  27. package/dist/stdio.d.ts.map +1 -0
  28. package/dist/stdio.js +15 -0
  29. package/dist/stdio.js.map +1 -0
  30. package/dist/tool-name.d.ts +15 -0
  31. package/dist/tool-name.d.ts.map +1 -0
  32. package/dist/tool-name.js +19 -0
  33. package/dist/tool-name.js.map +1 -0
  34. package/package.json +23 -0
  35. package/src/__tests__/annotations.test.ts +70 -0
  36. package/src/__tests__/blaze.test.ts +105 -0
  37. package/src/__tests__/build.test.ts +377 -0
  38. package/src/__tests__/progress.test.ts +136 -0
  39. package/src/__tests__/tool-name.test.ts +46 -0
  40. package/src/annotations.ts +51 -0
  41. package/src/blaze.ts +146 -0
  42. package/src/build.ts +321 -0
  43. package/src/index.ts +24 -0
  44. package/src/progress.ts +73 -0
  45. package/src/stdio.ts +17 -0
  46. package/src/tool-name.ts +19 -0
  47. package/tsconfig.json +9 -0
  48. package/tsconfig.tsbuildinfo +1 -0
@@ -0,0 +1 @@
1
+ $ tsc -b
@@ -0,0 +1,3 @@
1
+ $ oxlint ./src
2
+ Found 0 warnings and 0 errors.
3
+ Finished in 103ms on 12 files with 93 rules using 24 threads.
@@ -0,0 +1 @@
1
+ $ tsc --noEmit
package/CHANGELOG.md ADDED
@@ -0,0 +1,20 @@
1
+ # @ontrails/mcp
2
+
3
+ ## 1.0.0-beta.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Initial v1 beta release of the Trails framework.
8
+
9
+ - **@ontrails/core** — Result type, error taxonomy, trail/hike/event/topo, validateTopo, validateInput/Output, deriveFields, patterns, redaction, branded types, resilience
10
+ - **@ontrails/cli** — CLI surface adapter, Commander integration, flag derivation, layers
11
+ - **@ontrails/mcp** — MCP surface adapter, tool generation, annotations, progress bridge
12
+ - **@ontrails/logging** — Structured logging, sinks, formatters, LogTape adapter
13
+ - **@ontrails/testing** — testAll, testExamples, testTrail, testHike, testContracts, testDetours, surface harnesses
14
+ - **@ontrails/warden** — AST-based code convention rules via oxc-parser, drift detection, CI formatters
15
+ - **@ontrails/schema** — Surface map generation, hashing, semantic diffing
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies
20
+ - @ontrails/core@1.0.0-beta.0
package/README.md ADDED
@@ -0,0 +1,161 @@
1
+ # @ontrails/mcp
2
+
3
+ MCP surface adapter for Trails. Generates MCP tools from trail definitions with auto-derived annotations, progress bridging, and a single `blaze()` call to start a server.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ bun add @ontrails/mcp
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { trail, topo, Result } from '@ontrails/core';
15
+ import { blaze } from '@ontrails/mcp';
16
+ import { z } from 'zod';
17
+
18
+ const greet = trail('greet', {
19
+ input: z.object({ name: z.string().describe('Who to greet') }),
20
+ readOnly: true,
21
+ implementation: (input) => Result.ok(`Hello, ${input.name}!`),
22
+ });
23
+
24
+ const app = topo('myapp', { greet });
25
+ await blaze(app);
26
+ ```
27
+
28
+ This starts an MCP server over stdio with a `myapp_greet` tool. The tool has `readOnlyHint: true` and a JSON Schema input derived from the Zod schema.
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
33
+
34
+ ### `blaze(app, options?)`
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.
52
+
53
+ ```typescript
54
+ import { buildMcpTools } from '@ontrails/mcp';
55
+
56
+ const tools = buildMcpTools(app, {
57
+ includeTrails: ['entity.show', 'search'],
58
+ });
59
+
60
+ for (const tool of tools) {
61
+ server.registerTool(tool.name, tool.handler, {
62
+ inputSchema: tool.inputSchema,
63
+ annotations: tool.annotations,
64
+ });
65
+ }
66
+ ```
67
+
68
+ ### Tool Name Derivation
69
+
70
+ Trail IDs map to MCP tool names with the app name prefix:
71
+
72
+ | App name | Trail ID | Tool name |
73
+ | ---------- | -------------- | ----------------------- |
74
+ | `myapp` | `entity.show` | `myapp_entity_show` |
75
+ | `myapp` | `search` | `myapp_search` |
76
+ | `dispatch` | `patch.search` | `dispatch_patch_search` |
77
+
78
+ Rules: dots become underscores, hyphens become underscores, everything lowercase. Names match MCP convention `[a-z0-9_]+`.
79
+
80
+ ```typescript
81
+ import { deriveToolName } from '@ontrails/mcp';
82
+ deriveToolName('myapp', 'entity.show'); // "myapp_entity_show"
83
+ ```
84
+
85
+ ### Annotation Auto-Generation
86
+
87
+ Trail markers map directly to MCP tool annotations:
88
+
89
+ | Trail field | MCP annotation | Effect |
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 |
95
+
96
+ ```typescript
97
+ import { deriveAnnotations } from '@ontrails/mcp';
98
+ deriveAnnotations(showTrail); // { readOnlyHint: true, title: "Show entity details" }
99
+ ```
100
+
101
+ Trails without markers produce empty annotations (MCP SDK defaults apply).
102
+
103
+ ### Progress Bridge
104
+
105
+ Trail implementations report progress via `ctx.progress`. On MCP, these bridge to `notifications/progress`:
106
+
107
+ ```typescript
108
+ const importTrail = trail('data.import', {
109
+ implementation: async (input, ctx) => {
110
+ for (let i = 0; i < items.length; i++) {
111
+ await processItem(items[i]);
112
+ ctx.progress?.({ type: 'progress', current: i + 1, total: items.length });
113
+ }
114
+ return Result.ok({ imported: items.length });
115
+ },
116
+ });
117
+ ```
118
+
119
+ Progress bridging activates only when the MCP client includes a `progressToken` in the tool call. Otherwise, `ctx.progress` calls are silently ignored.
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
130
+
131
+ ```typescript
132
+ // Whitelist
133
+ await blaze(app, { includeTrails: ['entity.show', 'entity.add', 'search'] });
134
+
135
+ // Blacklist
136
+ await blaze(app, { excludeTrails: ['internal.debug', 'admin.reset'] });
137
+ ```
138
+
139
+ `includeTrails` takes precedence over `excludeTrails`.
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
146
+
147
+ ```typescript
148
+ import {
149
+ blaze,
150
+ buildMcpTools,
151
+ deriveToolName,
152
+ deriveAnnotations,
153
+ createMcpProgressCallback,
154
+ connectStdio,
155
+ } from '@ontrails/mcp';
156
+ ```
157
+
158
+ ## Further Reading
159
+
160
+ - [MCP Surface Guide](../../docs/surfaces/mcp.md)
161
+ - [Getting Started](../../docs/getting-started.md)
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Derive MCP tool annotations from trail spec markers.
3
+ */
4
+ import type { Trail } from '@ontrails/core';
5
+ export interface McpAnnotations {
6
+ readonly readOnlyHint?: boolean | undefined;
7
+ readonly destructiveHint?: boolean | undefined;
8
+ readonly idempotentHint?: boolean | undefined;
9
+ readonly openWorldHint?: boolean | undefined;
10
+ readonly title?: string | undefined;
11
+ }
12
+ /**
13
+ * Map trail spec fields to MCP tool annotations.
14
+ *
15
+ * Only sets hints that are explicitly declared on the trail.
16
+ * Omitted hints let the MCP SDK use its defaults.
17
+ */
18
+ export declare const deriveAnnotations: (trail: Pick<Trail<unknown, unknown>, "readOnly" | "destructive" | "idempotent" | "description">) => McpAnnotations;
19
+ //# sourceMappingURL=annotations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"annotations.d.ts","sourceRoot":"","sources":["../src/annotations.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAM5C,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,CACT,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,EACvB,UAAU,GAAG,aAAa,GAAG,YAAY,GAAG,aAAa,CAC1D,KACA,cAiBF,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Derive MCP tool annotations from trail spec markers.
3
+ */
4
+ // ---------------------------------------------------------------------------
5
+ // Derivation
6
+ // ---------------------------------------------------------------------------
7
+ /**
8
+ * Map trail spec fields to MCP tool annotations.
9
+ *
10
+ * Only sets hints that are explicitly declared on the trail.
11
+ * Omitted hints let the MCP SDK use its defaults.
12
+ */
13
+ export const deriveAnnotations = (trail) => {
14
+ const annotations = {};
15
+ if (trail.readOnly === true) {
16
+ annotations['readOnlyHint'] = true;
17
+ }
18
+ if (trail.destructive === true) {
19
+ annotations['destructiveHint'] = true;
20
+ }
21
+ if (trail.idempotent === true) {
22
+ annotations['idempotentHint'] = true;
23
+ }
24
+ if (trail.description !== undefined) {
25
+ annotations['title'] = trail.description;
26
+ }
27
+ return annotations;
28
+ };
29
+ //# sourceMappingURL=annotations.js.map
@@ -0,0 +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,KAGC,EACe,EAAE;IAClB,MAAM,WAAW,GAA4B,EAAE,CAAC;IAEhD,IAAI,KAAK,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;QAC5B,WAAW,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC;IACrC,CAAC;IACD,IAAI,KAAK,CAAC,WAAW,KAAK,IAAI,EAAE,CAAC;QAC/B,WAAW,CAAC,iBAAiB,CAAC,GAAG,IAAI,CAAC;IACxC,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"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * blaze() -- 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 blaze(app);
9
+ * ```
10
+ */
11
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
12
+ import type { Layer, Topo, TrailContext } from '@ontrails/core';
13
+ import type { McpToolDefinition } from './build.js';
14
+ export interface BlazeMcpOptions {
15
+ readonly createContext?: (() => TrailContext | Promise<TrailContext>) | undefined;
16
+ readonly excludeTrails?: readonly string[] | undefined;
17
+ readonly includeTrails?: readonly string[] | undefined;
18
+ readonly layers?: readonly Layer[] | undefined;
19
+ readonly serverInfo?: {
20
+ readonly name?: string | undefined;
21
+ readonly version?: string | undefined;
22
+ } | undefined;
23
+ readonly transport?: 'stdio' | undefined;
24
+ }
25
+ /**
26
+ * Create an MCP Server instance and register all tools.
27
+ */
28
+ export declare const createMcpServer: (tools: McpToolDefinition[], info: {
29
+ readonly name: string;
30
+ readonly version: string;
31
+ }) => Server;
32
+ /**
33
+ * Build MCP tools from an App, create a server, and connect via stdio.
34
+ */
35
+ export declare const blaze: (app: Topo, options?: BlazeMcpOptions) => Promise<void>;
36
+ //# sourceMappingURL=blaze.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blaze.d.ts","sourceRoot":"","sources":["../src/blaze.ts"],"names":[],"mappings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+ *
6
+ * ```ts
7
+ * const app = topo("myapp", entity);
8
+ * await blaze(app);
9
+ * ```
10
+ */
11
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
12
+ import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
13
+ import { buildMcpTools } from './build.js';
14
+ import { connectStdio } from './stdio.js';
15
+ // ---------------------------------------------------------------------------
16
+ // Internal: create MCP server with tool handlers
17
+ // ---------------------------------------------------------------------------
18
+ /**
19
+ * Create an MCP Server instance and register all tools.
20
+ */
21
+ export const createMcpServer = (tools, info) => {
22
+ const server = new Server({ name: info.name, version: info.version }, { capabilities: { tools: {} } });
23
+ // Build a lookup map for tool dispatch
24
+ const toolMap = new Map();
25
+ for (const tool of tools) {
26
+ toolMap.set(tool.name, tool);
27
+ }
28
+ // Register tools/list handler
29
+ // oxlint-disable-next-line require-await -- MCP SDK requires async handler
30
+ server.setRequestHandler(ListToolsRequestSchema, async () => ({
31
+ tools: tools.map((t) => ({
32
+ annotations: t.annotations,
33
+ description: t.description,
34
+ inputSchema: t.inputSchema,
35
+ name: t.name,
36
+ })),
37
+ }));
38
+ // Register tools/call handler
39
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
40
+ const tool = toolMap.get(request.params.name);
41
+ if (tool === undefined) {
42
+ return {
43
+ content: [
44
+ {
45
+ text: `Unknown tool: ${request.params.name}`,
46
+ type: 'text',
47
+ },
48
+ ],
49
+ isError: true,
50
+ };
51
+ }
52
+ const args = (request.params.arguments ?? {});
53
+ const progressToken = request.params._meta?.progressToken;
54
+ const sendProgress = progressToken === undefined
55
+ ? undefined
56
+ : async (current, total) => {
57
+ await server.notification({
58
+ method: 'notifications/progress',
59
+ params: {
60
+ progress: current,
61
+ progressToken: progressToken,
62
+ total,
63
+ },
64
+ });
65
+ };
66
+ const extra = {
67
+ progressToken,
68
+ sendProgress,
69
+ signal: undefined,
70
+ };
71
+ const result = await tool.handler(args, extra);
72
+ // Spread to satisfy MCP SDK's index-signature requirement
73
+ return { ...result };
74
+ });
75
+ return server;
76
+ };
77
+ // ---------------------------------------------------------------------------
78
+ // blaze
79
+ // ---------------------------------------------------------------------------
80
+ /**
81
+ * Build MCP tools from an App, create a server, and connect via stdio.
82
+ */
83
+ export const blaze = async (app, options = {}) => {
84
+ const tools = buildMcpTools(app, {
85
+ createContext: options.createContext,
86
+ excludeTrails: options.excludeTrails,
87
+ includeTrails: options.includeTrails,
88
+ layers: options.layers,
89
+ });
90
+ const server = createMcpServer(tools, {
91
+ name: options.serverInfo?.name ?? app.name,
92
+ version: options.serverInfo?.version ?? '0.1.0',
93
+ });
94
+ await connectStdio(server);
95
+ };
96
+ //# sourceMappingURL=blaze.js.map
@@ -0,0 +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;AAI5C,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAsB1C,8EAA8E;AAC9E,iDAAiD;AACjD,8EAA8E;AAE9E;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,KAA0B,EAC1B,IAAyD,EACjD,EAAE;IACV,MAAM,MAAM,GAAG,IAAI,MAAM,CACvB,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,EAC1C,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,CAChC,CAAC;IAEF,uCAAuC;IACvC,MAAM,OAAO,GAAG,IAAI,GAAG,EAA6B,CAAC;IACrD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,OAAO,CAAC,GAAG,CAAC,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AAO;wBACjB,aAAa,EAAE,aAAa;wBAC5B,KAAK;qBACN;iBACF,CAAC,CAAC;YACL,CAAC,CAAC;QAER,MAAM,KAAK,GAAG;YACZ,aAAa;YACb,YAAY;YACZ,MAAM,EAAE,SAAoC;SAC7C,CAAC;QAEF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAC/C,0DAA0D;QAC1D,OAAO,EAAE,GAAG,MAAM,EAA6B,CAAC;IAClD,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF,8EAA8E;AAC9E,QAAQ;AACR,8EAA8E;AAE9E;;GAEG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,KAAK,EACxB,GAAS,EACT,UAA2B,EAAE,EACd,EAAE;IACjB,MAAM,KAAK,GAAG,aAAa,CAAC,GAAG,EAAE;QAC/B,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,MAAM,MAAM,GAAG,eAAe,CAAC,KAAK,EAAE;QACpC,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"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Build MCP tool definitions from a Trails App.
3
+ *
4
+ * Iterates the topo, generates McpToolDefinition[] with handlers that
5
+ * validate input, compose layers, execute the implementation, and map
6
+ * Results to MCP responses.
7
+ */
8
+ import type { Layer, Topo, TrailContext } from '@ontrails/core';
9
+ import type { McpAnnotations } from './annotations.js';
10
+ export interface BuildMcpToolsOptions {
11
+ readonly createContext?: (() => TrailContext | Promise<TrailContext>) | undefined;
12
+ readonly excludeTrails?: readonly string[] | undefined;
13
+ readonly includeTrails?: readonly string[] | undefined;
14
+ readonly layers?: readonly Layer[] | undefined;
15
+ }
16
+ export interface McpToolDefinition {
17
+ readonly annotations: McpAnnotations | undefined;
18
+ readonly description: string | undefined;
19
+ readonly handler: (args: Record<string, unknown>, extra: McpExtra) => Promise<McpToolResult>;
20
+ readonly inputSchema: Record<string, unknown>;
21
+ readonly name: string;
22
+ }
23
+ export interface McpExtra {
24
+ readonly progressToken?: string | number | undefined;
25
+ readonly sendProgress?: ((current: number, total: number) => Promise<void>) | undefined;
26
+ readonly signal?: AbortSignal | undefined;
27
+ }
28
+ export interface McpToolResult {
29
+ readonly content: readonly McpContent[];
30
+ readonly isError?: boolean | undefined;
31
+ }
32
+ export interface McpContent {
33
+ readonly data?: string | undefined;
34
+ readonly mimeType?: string | undefined;
35
+ readonly text?: string | undefined;
36
+ readonly type: 'text' | 'image' | 'resource';
37
+ readonly uri?: string | undefined;
38
+ }
39
+ export declare const buildMcpTools: (app: Topo, options?: BuildMcpToolsOptions) => McpToolDefinition[];
40
+ //# sourceMappingURL=build.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAQH,OAAO,KAAK,EAAE,KAAK,EAAE,IAAI,EAAS,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEvE,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,CAA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AM,GAAG,OAAO,GAAG,UAAU,CAAC;IAC7C,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACnC;AA4OD,eAAO,MAAM,aAAa,GACxB,KAAK,IAAI,EACT,UAAS,oBAAyB,KACjC,iBAAiB,EAiBnB,CAAC"}
package/dist/build.js ADDED
@@ -0,0 +1,190 @@
1
+ /**
2
+ * Build MCP tool definitions from a Trails App.
3
+ *
4
+ * Iterates the topo, generates McpToolDefinition[] with handlers that
5
+ * validate input, compose layers, execute the implementation, and map
6
+ * Results to MCP responses.
7
+ */
8
+ import { composeLayers, createTrailContext, validateInput, zodToJsonSchema, } from '@ontrails/core';
9
+ import { deriveAnnotations } from './annotations.js';
10
+ import { createMcpProgressCallback } from './progress.js';
11
+ import { deriveToolName } from './tool-name.js';
12
+ const isBlobRef = (value) => {
13
+ if (typeof value !== 'object' || value === null) {
14
+ return false;
15
+ }
16
+ const obj = value;
17
+ return (obj['kind'] === 'blob' &&
18
+ obj['data'] instanceof Uint8Array &&
19
+ typeof obj['mimeType'] === 'string');
20
+ };
21
+ const uint8ArrayToBase64 = (bytes) => {
22
+ // Use btoa with manual conversion for runtime-agnostic base64
23
+ let binary = '';
24
+ for (const byte of bytes) {
25
+ binary += String.fromCodePoint(byte);
26
+ }
27
+ return btoa(binary);
28
+ };
29
+ const blobToContent = (blob) => {
30
+ if (blob.mimeType.startsWith('image/')) {
31
+ return {
32
+ data: uint8ArrayToBase64(blob.data),
33
+ mimeType: blob.mimeType,
34
+ type: 'image',
35
+ };
36
+ }
37
+ return {
38
+ mimeType: blob.mimeType,
39
+ type: 'resource',
40
+ uri: `blob://${blob.name ?? 'unnamed'}`,
41
+ };
42
+ };
43
+ /** Separate blob fields from non-blob fields in an object. */
44
+ const separateBlobFields = (obj) => {
45
+ const blobContents = [];
46
+ const textFields = {};
47
+ let hasBlobFields = false;
48
+ for (const [key, val] of Object.entries(obj)) {
49
+ if (isBlobRef(val)) {
50
+ hasBlobFields = true;
51
+ blobContents.push(blobToContent(val));
52
+ }
53
+ else {
54
+ textFields[key] = val;
55
+ }
56
+ }
57
+ return { blobContents, hasBlobFields, textFields };
58
+ };
59
+ /** Serialize a mixed blob/text object to MCP content. */
60
+ const serializeMixedObject = (obj) => {
61
+ const { blobContents, hasBlobFields, textFields } = separateBlobFields(obj);
62
+ if (!hasBlobFields) {
63
+ return undefined;
64
+ }
65
+ if (Object.keys(textFields).length > 0) {
66
+ blobContents.unshift({ text: JSON.stringify(textFields), type: 'text' });
67
+ }
68
+ return blobContents;
69
+ };
70
+ const serializeOutput = (value) => {
71
+ if (isBlobRef(value)) {
72
+ return [blobToContent(value)];
73
+ }
74
+ if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
75
+ const mixed = serializeMixedObject(value);
76
+ if (mixed) {
77
+ return mixed;
78
+ }
79
+ }
80
+ return [{ text: JSON.stringify(value), type: 'text' }];
81
+ };
82
+ // ---------------------------------------------------------------------------
83
+ // Handler factory
84
+ // ---------------------------------------------------------------------------
85
+ /** Create an error result for MCP responses. */
86
+ const mcpError = (message) => ({
87
+ content: [{ text: message, type: 'text' }],
88
+ isError: true,
89
+ });
90
+ /** Build a TrailContext from options and MCP extra. */
91
+ const buildTrailContext = async (options, extra) => {
92
+ const baseContext = options.createContext !== undefined && options.createContext !== null
93
+ ? await options.createContext()
94
+ : createTrailContext();
95
+ const signal = extra.signal ?? baseContext.signal;
96
+ const progressCb = createMcpProgressCallback(extra);
97
+ return {
98
+ ...baseContext,
99
+ signal,
100
+ ...(progressCb === undefined ? {} : { progress: progressCb }),
101
+ };
102
+ };
103
+ /** Execute a trail and map the result to an MCP response. */
104
+ const executeAndMap = async (trail, validatedInput, ctx, layers) => {
105
+ const impl = composeLayers([...layers], trail, trail.implementation);
106
+ try {
107
+ const result = await impl(validatedInput, ctx);
108
+ if (result.isOk()) {
109
+ return { content: serializeOutput(result.value) };
110
+ }
111
+ return mcpError(result.error.message);
112
+ }
113
+ catch (error) {
114
+ return mcpError(error instanceof Error ? error.message : String(error));
115
+ }
116
+ };
117
+ const createHandler = (trail, layers, options) => async (args, extra) => {
118
+ const validated = validateInput(trail.input, args);
119
+ if (validated.isErr()) {
120
+ return mcpError(validated.error.message);
121
+ }
122
+ const ctx = await buildTrailContext(options, extra);
123
+ return executeAndMap(trail, validated.value, ctx, layers);
124
+ };
125
+ // ---------------------------------------------------------------------------
126
+ // Builder
127
+ // ---------------------------------------------------------------------------
128
+ /**
129
+ * Build MCP tool definitions from an App's topology.
130
+ *
131
+ * Each trail in the topo becomes an McpToolDefinition with:
132
+ * - A derived tool name (app-prefixed, underscore-delimited)
133
+ * - JSON Schema input from zodToJsonSchema
134
+ * - MCP annotations from trail markers
135
+ * - A handler that validates, composes layers, executes, and maps results
136
+ */
137
+ /** Check if a trail should be included based on markers and filters. */
138
+ const shouldInclude = (trail, options) => {
139
+ if (trail.markers?.['internal'] === true) {
140
+ return false;
141
+ }
142
+ if (options.includeTrails !== undefined && options.includeTrails.length > 0) {
143
+ return options.includeTrails.includes(trail.id);
144
+ }
145
+ if (options.excludeTrails !== undefined &&
146
+ options.excludeTrails.includes(trail.id)) {
147
+ return false;
148
+ }
149
+ return true;
150
+ };
151
+ /** Build a description with optional example input appended. */
152
+ const buildDescription = (trail) => {
153
+ let { description } = trail;
154
+ if (description !== undefined &&
155
+ trail.examples !== undefined &&
156
+ trail.examples.length > 0) {
157
+ const [firstExample] = trail.examples;
158
+ if (firstExample !== undefined) {
159
+ description = `${description}\n\nExample input: ${JSON.stringify(firstExample.input)}`;
160
+ }
161
+ }
162
+ return description;
163
+ };
164
+ /** Build a single MCP tool definition from a trail. */
165
+ const buildToolDefinition = (app, trail, layers, options) => {
166
+ const rawAnnotations = deriveAnnotations(trail);
167
+ const annotations = Object.keys(rawAnnotations).length > 0 ? rawAnnotations : undefined;
168
+ return {
169
+ annotations,
170
+ description: buildDescription(trail),
171
+ handler: createHandler(trail, layers, options),
172
+ inputSchema: zodToJsonSchema(trail.input),
173
+ name: deriveToolName(app.name, trail.id),
174
+ };
175
+ };
176
+ export const buildMcpTools = (app, options = {}) => {
177
+ const layers = options.layers ?? [];
178
+ const tools = [];
179
+ for (const item of app.list()) {
180
+ if (item.kind !== 'trail' && item.kind !== 'hike') {
181
+ continue;
182
+ }
183
+ if (!shouldInclude(item, options)) {
184
+ continue;
185
+ }
186
+ tools.push(buildToolDefinition(app, item, layers, options));
187
+ }
188
+ return tools;
189
+ };
190
+ //# sourceMappingURL=build.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.js","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,aAAa,EACb,eAAe,GAChB,MAAM,gBAAgB,CAAC;AAIxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AA0DhD,MAAM,SAAS,GAAG,CAAC,KAAc,EAAoB,EAAE;IACrD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,GAAG,GAAG,KAAgC,CAAC;IAC7C,OAAO,CACL,GAAG,CAAC,MAAM,CAAC,KAAK,MAAM;QACtB,GAAG,CAAC,MAAM,CAAC,YAAY,UAAU;QACjC,OAAO,GAAG,CAAC,UAAU,CAAC,KAAK,QAAQ,CACpC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG,CAAC,KAAiB,EAAU,EAAE;IACvD,8DAA8D;IAC9D,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,IAAI,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC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G,CAAC,IAAI,EAAE,EAAE,CAAC;QAC9B,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YAClD,SAAS;QACX,CAAC;QACD,IAAI,CAAC,aAAa,CAAC,IAA+B,EAAE,OAAO,CAAC,EAAE,CAAC;YAC7D,SAAS;QACX,CAAC;QACD,KAAK,CAAC,IAAI,CACR,mBAAmB,CAAC,GAAG,EAAE,IAA+B,EAAE,MAAM,EAAE,OAAO,CAAC,CAC3E,CAAC;IACJ,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ export { buildMcpTools, type BuildMcpToolsOptions, type McpToolDefinition, type McpToolResult, type McpContent, type McpExtra, } from './build.js';
2
+ export { deriveToolName } from './tool-name.js';
3
+ export { deriveAnnotations, type McpAnnotations } from './annotations.js';
4
+ export { createMcpProgressCallback } from './progress.js';
5
+ export { blaze, type BlazeMcpOptions } from './blaze.js';
6
+ export { connectStdio } from './stdio.js';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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,KAAK,EAAE,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAGzD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}