@ontrails/mcp 1.0.0-beta.15 → 1.0.0-beta.16

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 (49) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +19 -3
  3. package/package.json +11 -3
  4. package/src/build.ts +642 -70
  5. package/src/index.ts +5 -0
  6. package/src/surface.ts +71 -53
  7. package/.turbo/turbo-build.log +0 -1
  8. package/.turbo/turbo-lint.log +0 -3
  9. package/.turbo/turbo-typecheck.log +0 -1
  10. package/dist/annotations.d.ts +0 -19
  11. package/dist/annotations.d.ts.map +0 -1
  12. package/dist/annotations.js +0 -31
  13. package/dist/annotations.js.map +0 -1
  14. package/dist/build.d.ts +0 -49
  15. package/dist/build.d.ts.map +0 -1
  16. package/dist/build.js +0 -220
  17. package/dist/build.js.map +0 -1
  18. package/dist/index.d.ts +0 -7
  19. package/dist/index.d.ts.map +0 -1
  20. package/dist/index.js +0 -13
  21. package/dist/index.js.map +0 -1
  22. package/dist/progress.d.ts +0 -13
  23. package/dist/progress.d.ts.map +0 -1
  24. package/dist/progress.js +0 -51
  25. package/dist/progress.js.map +0 -1
  26. package/dist/stdio.d.ts +0 -12
  27. package/dist/stdio.d.ts.map +0 -1
  28. package/dist/stdio.js +0 -15
  29. package/dist/stdio.js.map +0 -1
  30. package/dist/surface.d.ts +0 -35
  31. package/dist/surface.d.ts.map +0 -1
  32. package/dist/surface.js +0 -123
  33. package/dist/surface.js.map +0 -1
  34. package/dist/tool-name.d.ts +0 -15
  35. package/dist/tool-name.d.ts.map +0 -1
  36. package/dist/tool-name.js +0 -19
  37. package/dist/tool-name.js.map +0 -1
  38. package/dist/trailhead.d.ts +0 -57
  39. package/dist/trailhead.d.ts.map +0 -1
  40. package/dist/trailhead.js +0 -136
  41. package/dist/trailhead.js.map +0 -1
  42. package/src/__tests__/annotations.test.ts +0 -63
  43. package/src/__tests__/build.test.ts +0 -648
  44. package/src/__tests__/progress.test.ts +0 -136
  45. package/src/__tests__/surface.test.ts +0 -191
  46. package/src/__tests__/tool-name.test.ts +0 -46
  47. package/tsconfig.json +0 -9
  48. package/tsconfig.tests.json +0 -10
  49. package/tsconfig.tsbuildinfo +0 -1
package/src/index.ts CHANGED
@@ -1,11 +1,16 @@
1
1
  // Build
2
2
  export {
3
+ MCP_TOOL_ERROR_META_KEY,
4
+ MCP_TOOL_EXAMPLES_META_KEY,
3
5
  deriveMcpTools,
4
6
  type DeriveMcpToolsOptions,
5
7
  type McpToolDefinition,
6
8
  type McpToolResult,
9
+ type McpToolErrorMeta,
7
10
  type McpContent,
8
11
  type McpExtra,
12
+ type ResolveMcpPermit,
13
+ type ResolveMcpPermitInput,
9
14
  } from './build.js';
10
15
 
11
16
  // Tool naming
package/src/surface.ts CHANGED
@@ -8,14 +8,14 @@ import {
8
8
  ListToolsRequestSchema,
9
9
  } from '@modelcontextprotocol/sdk/types.js';
10
10
  import type {
11
- Intent,
11
+ BaseSurfaceOptions,
12
12
  Layer,
13
13
  ResourceOverrideMap,
14
14
  Topo,
15
15
  TrailContextInit,
16
16
  } from '@ontrails/core';
17
17
 
18
- import type { McpToolDefinition } from './build.js';
18
+ import type { McpToolDefinition, ResolveMcpPermit } from './build.js';
19
19
  import { deriveMcpTools } from './build.js';
20
20
  import { connectStdio } from './stdio.js';
21
21
 
@@ -23,23 +23,15 @@ import { connectStdio } from './stdio.js';
23
23
  // Options
24
24
  // ---------------------------------------------------------------------------
25
25
 
26
- export interface CreateServerOptions {
27
- /** Config values for resources that declare a `config` schema, keyed by resource ID. */
28
- readonly configValues?:
29
- | Readonly<Record<string, Record<string, unknown>>>
30
- | undefined;
26
+ export interface CreateServerOptions extends BaseSurfaceOptions {
31
27
  readonly createContext?:
32
28
  | (() => TrailContextInit | Promise<TrailContextInit>)
33
29
  | undefined;
34
30
  readonly description?: string | undefined;
35
- readonly exclude?: readonly string[] | undefined;
36
- readonly include?: readonly string[] | undefined;
37
- readonly intent?: readonly Intent[] | undefined;
38
31
  readonly layers?: readonly Layer[] | undefined;
39
32
  readonly name?: string | undefined;
40
33
  readonly resources?: ResourceOverrideMap | undefined;
41
- /** Set to `false` to skip topo validation at startup. Defaults to `true`. */
42
- readonly validate?: boolean | undefined;
34
+ readonly resolvePermit?: ResolveMcpPermit | undefined;
43
35
  readonly version?: string | undefined;
44
36
  }
45
37
 
@@ -86,55 +78,76 @@ const createMcpServer = (
86
78
  // oxlint-disable-next-line require-await -- MCP SDK requires async handler
87
79
  server.setRequestHandler(ListToolsRequestSchema, async () => ({
88
80
  tools: tools.map((t) => ({
81
+ _meta: t._meta,
89
82
  annotations: t.annotations,
90
83
  description: t.description,
91
84
  inputSchema: t.inputSchema,
92
85
  name: t.name,
86
+ outputSchema: t.outputSchema,
93
87
  })),
94
88
  }));
95
89
 
96
90
  // Register tools/call handler
97
- server.setRequestHandler(CallToolRequestSchema, async (request) => {
98
- const tool = toolMap.get(request.params.name);
99
- if (tool === undefined) {
100
- return {
101
- content: [
102
- {
103
- text: `Unknown tool: ${request.params.name}`,
104
- type: 'text' as const,
105
- },
106
- ],
107
- isError: true,
108
- } as Record<string, unknown>;
91
+ server.setRequestHandler(
92
+ CallToolRequestSchema,
93
+ async (request, requestExtra) => {
94
+ const tool = toolMap.get(request.params.name);
95
+ if (tool === undefined) {
96
+ return {
97
+ content: [
98
+ {
99
+ text: `Unknown tool: ${request.params.name}`,
100
+ type: 'text' as const,
101
+ },
102
+ ],
103
+ isError: true,
104
+ } as Record<string, unknown>;
105
+ }
106
+
107
+ const args = (request.params.arguments ?? {}) as Record<string, unknown>;
108
+ const progressToken = request.params._meta?.progressToken;
109
+ const { authInfo } = requestExtra as {
110
+ readonly authInfo?:
111
+ | {
112
+ readonly accessToken?: string | undefined;
113
+ readonly sessionId?: string | undefined;
114
+ readonly token?: string | undefined;
115
+ }
116
+ | undefined;
117
+ };
118
+ const authorizationToken = authInfo?.accessToken ?? authInfo?.token;
119
+
120
+ const sendProgress =
121
+ progressToken === undefined
122
+ ? undefined
123
+ : async (current: number, total: number) => {
124
+ await server.notification({
125
+ method: 'notifications/progress',
126
+ params: {
127
+ progress: current,
128
+ progressToken,
129
+ total,
130
+ },
131
+ });
132
+ };
133
+
134
+ const extra = {
135
+ abortSignal: requestExtra.signal,
136
+ ...(authorizationToken === undefined
137
+ ? {}
138
+ : { authorization: `Bearer ${authorizationToken}` }),
139
+ progressToken,
140
+ sendProgress,
141
+ ...(authInfo?.sessionId === undefined
142
+ ? {}
143
+ : { sessionId: authInfo.sessionId }),
144
+ };
145
+
146
+ const result = await tool.handler(args, extra);
147
+ // Spread to satisfy MCP SDK's index-signature requirement
148
+ return { ...result } as Record<string, unknown>;
109
149
  }
110
-
111
- const args = (request.params.arguments ?? {}) as Record<string, unknown>;
112
- const progressToken = request.params._meta?.progressToken;
113
-
114
- const sendProgress =
115
- progressToken === undefined
116
- ? undefined
117
- : async (current: number, total: number) => {
118
- await server.notification({
119
- method: 'notifications/progress',
120
- params: {
121
- progress: current,
122
- progressToken: progressToken,
123
- total,
124
- },
125
- });
126
- };
127
-
128
- const extra = {
129
- abortSignal: undefined as AbortSignal | undefined,
130
- progressToken,
131
- sendProgress,
132
- };
133
-
134
- const result = await tool.handler(args, extra);
135
- // Spread to satisfy MCP SDK's index-signature requirement
136
- return { ...result } as Record<string, unknown>;
137
- });
150
+ );
138
151
 
139
152
  return server;
140
153
  };
@@ -145,6 +158,10 @@ const createMcpServer = (
145
158
 
146
159
  /**
147
160
  * Build MCP tools from a topo and create an MCP server.
161
+ *
162
+ * @remarks This is a host materialization boundary. Derivation failures are
163
+ * thrown for server bootstrap code after `deriveMcpTools` has already
164
+ * represented the framework error as a Result.
148
165
  */
149
166
  export const createServer = (
150
167
  graph: Topo,
@@ -157,6 +174,7 @@ export const createServer = (
157
174
  include: options.include,
158
175
  intent: options.intent,
159
176
  layers: options.layers,
177
+ resolvePermit: options.resolvePermit,
160
178
  resources: options.resources,
161
179
  validate: options.validate,
162
180
  });
@@ -180,7 +198,7 @@ export const createServer = (
180
198
  * Build MCP tools from a topo, create a server, and connect via stdio.
181
199
  *
182
200
  * @remarks Opens the MCP server on stdio. For custom transports, use
183
- * `createServer(graph)` with `connectStdio` or your own connector.
201
+ * `createServer(graph)` with `connectStdio` or your own adapter.
184
202
  */
185
203
  export const surface = async (
186
204
  graph: Topo,
@@ -1 +0,0 @@
1
- $ tsc -b
@@ -1,3 +0,0 @@
1
- $ oxlint ./src
2
- Found 0 warnings and 0 errors.
3
- Finished in 68ms on 12 files with 93 rules using 24 threads.
@@ -1 +0,0 @@
1
- $ tsc --noEmit
@@ -1,19 +0,0 @@
1
- /**
2
- * Derive MCP tool annotations from trail spec fields.
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, unknown>, "intent" | "idempotent" | "description">) => McpAnnotations;
19
- //# sourceMappingURL=annotations.d.ts.map
@@ -1 +0,0 @@
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,CACT,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAChC,QAAQ,GAAG,YAAY,GAAG,aAAa,CACxC,KACA,cAoBF,CAAC"}
@@ -1,31 +0,0 @@
1
- /**
2
- * Derive MCP tool annotations from trail spec fields.
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
- const intentToHint = {
16
- destroy: 'destructiveHint',
17
- read: 'readOnlyHint',
18
- };
19
- const hint = intentToHint[trail.intent];
20
- if (hint) {
21
- annotations[hint] = true;
22
- }
23
- if (trail.idempotent === true) {
24
- annotations['idempotentHint'] = true;
25
- }
26
- if (trail.description !== undefined) {
27
- annotations['title'] = trail.description;
28
- }
29
- return annotations;
30
- };
31
- //# sourceMappingURL=annotations.js.map
@@ -1 +0,0 @@
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,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/build.d.ts DELETED
@@ -1,49 +0,0 @@
1
- /**
2
- * Build MCP tool definitions from a Trails graph.
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 { Result } from '@ontrails/core';
9
- import type { Intent, Layer, ResourceOverrideMap, Topo, TrailContextInit } from '@ontrails/core';
10
- import type { McpAnnotations } from './annotations.js';
11
- export interface DeriveMcpToolsOptions {
12
- /** Config values for resources that declare a `config` schema, keyed by resource ID. */
13
- readonly configValues?: Readonly<Record<string, Record<string, unknown>>> | undefined;
14
- readonly createContext?: (() => TrailContextInit | Promise<TrailContextInit>) | undefined;
15
- readonly exclude?: readonly string[] | undefined;
16
- readonly include?: readonly string[] | undefined;
17
- readonly intent?: readonly Intent[] | undefined;
18
- readonly layers?: readonly Layer[] | undefined;
19
- readonly resources?: ResourceOverrideMap | undefined;
20
- /** Set to `false` to skip topo validation while building tools. */
21
- readonly validate?: boolean | undefined;
22
- }
23
- export interface McpToolDefinition {
24
- readonly annotations: McpAnnotations | undefined;
25
- readonly description: string | undefined;
26
- readonly handler: (args: Record<string, unknown>, extra: McpExtra) => Promise<McpToolResult>;
27
- readonly inputSchema: Record<string, unknown>;
28
- readonly name: string;
29
- /** The trail ID this tool was derived from. */
30
- readonly trailId: string;
31
- }
32
- export interface McpExtra {
33
- readonly progressToken?: string | number | undefined;
34
- readonly sendProgress?: ((current: number, total: number) => Promise<void>) | undefined;
35
- readonly abortSignal?: AbortSignal | undefined;
36
- }
37
- export interface McpToolResult {
38
- readonly content: readonly McpContent[];
39
- readonly isError?: boolean | undefined;
40
- }
41
- export interface McpContent {
42
- readonly data?: string | undefined;
43
- readonly mimeType?: string | undefined;
44
- readonly text?: string | undefined;
45
- readonly type: 'text' | 'image' | 'resource';
46
- readonly uri?: string | undefined;
47
- }
48
- export declare const deriveMcpTools: (graph: Topo, options?: DeriveMcpToolsOptions) => Result<McpToolDefinition[], Error>;
49
- //# sourceMappingURL=build.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,MAAM,EAQP,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAEV,MAAM,EACN,KAAK,EACL,mBAAmB,EACnB,IAAI,EAEJ,gBAAgB,EACjB,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AASvD,MAAM,WAAW,qBAAqB;IACpC,wFAAwF;IACxF,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;IACd,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;IACjD,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;IACjD,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;IAChD,QAAQ,CAAC,MAAM,C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AAC,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;AAsSD,eAAO,MAAM,cAAc,GACzB,OAAO,IAAI,EACX,UAAS,qBAA0B,KAClC,MAAM,CAAC,iBAAiB,EAAE,EAAE,KAAK,CAOnC,CAAC"}
package/dist/build.js DELETED
@@ -1,220 +0,0 @@
1
- /**
2
- * Build MCP tool definitions from a Trails graph.
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 { Result, TRAILHEAD_KEY, ValidationError, executeTrail, filterSurfaceTrails, isBlobRef, validateEstablishedTopo, zodToJsonSchema, } from '@ontrails/core';
9
- import { deriveAnnotations } from './annotations.js';
10
- import { createMcpProgressCallback } from './progress.js';
11
- import { deriveToolName } from './tool-name.js';
12
- // ---------------------------------------------------------------------------
13
- // Internal helpers (defined before use)
14
- // ---------------------------------------------------------------------------
15
- /** Concatenate an array of Uint8Array chunks into a single Uint8Array. */
16
- const concatChunks = (chunks, totalLength) => {
17
- const result = new Uint8Array(totalLength);
18
- let offset = 0;
19
- for (const chunk of chunks) {
20
- result.set(chunk, offset);
21
- offset += chunk.length;
22
- }
23
- return result;
24
- };
25
- /** Collect a ReadableStream into a single Uint8Array. */
26
- const collectStream = async (stream) => {
27
- const reader = stream.getReader();
28
- const chunks = [];
29
- let totalLength = 0;
30
- for (;;) {
31
- const { done, value } = await reader.read();
32
- if (done) {
33
- break;
34
- }
35
- chunks.push(value);
36
- totalLength += value.length;
37
- }
38
- return concatChunks(chunks, totalLength);
39
- };
40
- /** Resolve BlobRef data to Uint8Array (handles ReadableStream). */
41
- const resolveBlobData = (blob) => {
42
- if (blob.data instanceof ReadableStream) {
43
- return collectStream(blob.data);
44
- }
45
- return blob.data;
46
- };
47
- const uint8ArrayToBase64 = (bytes) => {
48
- // Use btoa with manual conversion for runtime-agnostic base64
49
- let binary = '';
50
- for (const byte of bytes) {
51
- binary += String.fromCodePoint(byte);
52
- }
53
- return btoa(binary);
54
- };
55
- const blobToContent = async (blob) => {
56
- const bytes = await resolveBlobData(blob);
57
- if (blob.mimeType.startsWith('image/')) {
58
- return {
59
- data: uint8ArrayToBase64(bytes),
60
- mimeType: blob.mimeType,
61
- type: 'image',
62
- };
63
- }
64
- return {
65
- mimeType: blob.mimeType,
66
- type: 'resource',
67
- uri: `blob://${blob.name}`,
68
- };
69
- };
70
- /** Separate blob fields from non-blob fields in an object. */
71
- const separateBlobFields = async (obj) => {
72
- const blobContents = [];
73
- const textFields = {};
74
- let hasBlobFields = false;
75
- for (const [key, val] of Object.entries(obj)) {
76
- if (isBlobRef(val)) {
77
- hasBlobFields = true;
78
- blobContents.push(await blobToContent(val));
79
- }
80
- else {
81
- textFields[key] = val;
82
- }
83
- }
84
- return { blobContents, hasBlobFields, textFields };
85
- };
86
- /** Serialize a mixed blob/text object to MCP content. */
87
- const serializeMixedObject = async (obj) => {
88
- const { blobContents, hasBlobFields, textFields } = await separateBlobFields(obj);
89
- if (!hasBlobFields) {
90
- return undefined;
91
- }
92
- if (Object.keys(textFields).length > 0) {
93
- blobContents.unshift({ text: JSON.stringify(textFields), type: 'text' });
94
- }
95
- return blobContents;
96
- };
97
- const serializeOutput = async (value) => {
98
- if (isBlobRef(value)) {
99
- return [await blobToContent(value)];
100
- }
101
- if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
102
- const mixed = await serializeMixedObject(value);
103
- if (mixed) {
104
- return mixed;
105
- }
106
- }
107
- return [{ text: JSON.stringify(value), type: 'text' }];
108
- };
109
- // ---------------------------------------------------------------------------
110
- // Handler factory
111
- // ---------------------------------------------------------------------------
112
- /** Create an error result for MCP responses. */
113
- const mcpError = (message) => ({
114
- content: [{ text: message, type: 'text' }],
115
- isError: true,
116
- });
117
- /** Add the MCP trailhead marker while preserving any existing context extras. */
118
- const withMcpTrailhead = (progressCb) => ({
119
- ...(progressCb === undefined ? {} : { progress: progressCb }),
120
- extensions: {
121
- [TRAILHEAD_KEY]: 'mcp',
122
- },
123
- });
124
- const createHandler = (graph, t, layers, options) => async (args, extra) => {
125
- const progressCb = createMcpProgressCallback(extra);
126
- const result = await executeTrail(t, args, {
127
- abortSignal: extra.abortSignal,
128
- configValues: options.configValues,
129
- createContext: options.createContext,
130
- ctx: withMcpTrailhead(progressCb),
131
- layers,
132
- resources: options.resources,
133
- topo: graph,
134
- });
135
- if (result.isOk()) {
136
- return { content: await serializeOutput(result.value) };
137
- }
138
- return mcpError(result.error.message);
139
- };
140
- // ---------------------------------------------------------------------------
141
- // Builder
142
- // ---------------------------------------------------------------------------
143
- /**
144
- * Build MCP tool definitions from a graph's topology.
145
- *
146
- * Each trail in the topo becomes an McpToolDefinition with:
147
- * - A derived tool name (topo-name-prefixed, underscore-delimited)
148
- * - JSON Schema input from zodToJsonSchema
149
- * - MCP annotations from trail meta
150
- * - A handler that validates, composes layers, executes, and maps results
151
- */
152
- /** Build a description with optional example input appended. */
153
- const buildDescription = (trail) => {
154
- let { description } = trail;
155
- if (description !== undefined &&
156
- trail.examples !== undefined &&
157
- trail.examples.length > 0) {
158
- const [firstExample] = trail.examples;
159
- if (firstExample !== undefined) {
160
- description = `${description}\n\nExample input: ${JSON.stringify(firstExample.input)}`;
161
- }
162
- }
163
- return description;
164
- };
165
- /** Build a single MCP tool definition from a trail. */
166
- const buildToolDefinition = (graph, trail, layers, options) => {
167
- const rawAnnotations = deriveAnnotations(trail);
168
- const annotations = Object.keys(rawAnnotations).length > 0 ? rawAnnotations : undefined;
169
- return {
170
- annotations,
171
- description: buildDescription(trail),
172
- handler: createHandler(graph, trail, layers, options),
173
- inputSchema: zodToJsonSchema(trail.input),
174
- name: deriveToolName(graph.name, trail.id),
175
- trailId: trail.id,
176
- };
177
- };
178
- /** Register a trail as an MCP tool, checking for name collisions. */
179
- const registerTool = (graph, trailItem, layers, options, nameToTrailId, tools) => {
180
- const toolName = deriveToolName(graph.name, trailItem.id);
181
- const existingId = nameToTrailId.get(toolName);
182
- if (existingId !== undefined) {
183
- return Result.err(new ValidationError(`MCP tool-name collision: trails "${existingId}" and "${trailItem.id}" both derive the tool name "${toolName}"`));
184
- }
185
- nameToTrailId.set(toolName, trailItem.id);
186
- tools.push(buildToolDefinition(graph, trailItem, layers, options));
187
- return Result.ok();
188
- };
189
- /** Filter topo items to eligible trails. */
190
- const eligibleTrails = (graph, options) => filterSurfaceTrails(graph.list(), {
191
- exclude: options.exclude,
192
- include: options.include,
193
- intent: options.intent,
194
- });
195
- const validateToolBuild = (graph, options) => {
196
- if (options.validate === false) {
197
- return Result.ok();
198
- }
199
- const validated = validateEstablishedTopo(graph);
200
- return validated.isErr() ? Result.err(validated.error) : Result.ok();
201
- };
202
- const registerTools = (graph, options, layers) => {
203
- const tools = [];
204
- const nameToTrailId = new Map();
205
- for (const trailItem of eligibleTrails(graph, options)) {
206
- const registered = registerTool(graph, trailItem, layers, options, nameToTrailId, tools);
207
- if (registered.isErr()) {
208
- return registered;
209
- }
210
- }
211
- return Result.ok(tools);
212
- };
213
- export const deriveMcpTools = (graph, options = {}) => {
214
- const validation = validateToolBuild(graph, options);
215
- if (validation.isErr()) {
216
- return validation;
217
- }
218
- return registerTools(graph, options, options.layers ?? []);
219
- };
220
- //# sourceMappingURL=build.js.map
package/dist/build.js.map DELETED
@@ -1 +0,0 @@
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,mBAAmB,EACnB,SAAS,EACT,uBAAuB,EACvB,eAAe,GAChB,MAAM,gBAAgB,CAAC;AAYxB,OAAO,EAAE,iBAAiB,E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S,GAAG,uBAAuB,CAAC,KAAK,CAAC,CAAC;IACjD,OAAO,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;AACvE,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,CACpB,KAAW,EACX,OAA8B,EAC9B,MAAwB,EACY,EAAE;IACtC,MAAM,KAAK,GAAwB,EAAE,CAAC;IACtC,MAAM,aAAa,GAAG,IAAI,GAAG,EAAkB,CAAC;IAEhD,KAAK,MAAM,SAAS,IAAI,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,CAAC;QACvD,MAAM,UAAU,GAAG,YAAY,CAC7B,KAAK,EACL,SAAS,EACT,MAAM,EACN,OAAO,EACP,aAAa,EACb,KAAK,CACN,CAAC;QACF,IAAI,UAAU,CAAC,KAAK,EAAE,EAAE,CAAC;YACvB,OAAO,UAAU,CAAC;QACpB,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;AAC1B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,KAAW,EACX,UAAiC,EAAE,EACC,EAAE;IACtC,MAAM,UAAU,GAAG,iBAAiB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACrD,IAAI,UAAU,CAAC,KAAK,EAAE,EAAE,CAAC;QACvB,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,OAAO,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC;AAC7D,CAAC,CAAC"}
package/dist/index.d.ts DELETED
@@ -1,7 +0,0 @@
1
- export { deriveMcpTools, type DeriveMcpToolsOptions, 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 { createServer, surface, type CreateServerOptions, type SurfaceMcpResult, } from './surface.js';
6
- export { connectStdio } from './stdio.js';
7
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,cAAc,EACd,KAAK,qBAAqB,EAC1B,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,EACL,YAAY,EACZ,OAAO,EACP,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,GACtB,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
package/dist/index.js DELETED
@@ -1,13 +0,0 @@
1
- // Build
2
- export { deriveMcpTools, } from './build.js';
3
- // Tool naming
4
- export { deriveToolName } from './tool-name.js';
5
- // Annotations
6
- export { deriveAnnotations } from './annotations.js';
7
- // Progress
8
- export { createMcpProgressCallback } from './progress.js';
9
- // Surface
10
- export { createServer, surface, } from './surface.js';
11
- // Transport
12
- export { connectStdio } from './stdio.js';
13
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,QAAQ;AACR,OAAO,EACL,cAAc,GAMf,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,UAAU;AACV,OAAO,EACL,YAAY,EACZ,OAAO,GAGR,MAAM,cAAc,CAAC;AAEtB,YAAY;AACZ,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
@@ -1,13 +0,0 @@
1
- /**
2
- * Bridge Trails ProgressCallback to MCP sendProgress notifications.
3
- */
4
- import type { ProgressCallback } from '@ontrails/core';
5
- import type { McpExtra } from './build.js';
6
- /**
7
- * Create a ProgressCallback that bridges to MCP's sendProgress.
8
- *
9
- * Returns `undefined` if the MCP client did not provide a progressToken
10
- * (meaning no progress reporting was requested).
11
- */
12
- export declare const createMcpProgressCallback: (extra: McpExtra) => ProgressCallback | undefined;
13
- //# sourceMappingURL=progress.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../src/progress.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAiB,MAAM,gBAAgB,CAAC;AAEtE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AA6C3C;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,GACpC,OAAO,QAAQ,KACd,gBAAgB,GAAG,SAarB,CAAC"}