@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/src/build.ts CHANGED
@@ -2,13 +2,13 @@
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 layers, execute the implementation, and map
5
+ * validate input, compose gates, execute the implementation, and map
6
6
  * Results to MCP responses.
7
7
  */
8
8
 
9
9
  import {
10
10
  Result,
11
- SURFACE_KEY,
11
+ TRAILHEAD_KEY,
12
12
  ValidationError,
13
13
  executeTrail,
14
14
  isBlobRef,
@@ -16,8 +16,8 @@ import {
16
16
  } from '@ontrails/core';
17
17
  import type {
18
18
  BlobRef,
19
- Layer,
20
- ServiceOverrideMap,
19
+ Gate,
20
+ ProvisionOverrideMap,
21
21
  Topo,
22
22
  Trail,
23
23
  TrailContextInit,
@@ -33,7 +33,7 @@ import { deriveToolName } from './tool-name.js';
33
33
  // ---------------------------------------------------------------------------
34
34
 
35
35
  export interface BuildMcpToolsOptions {
36
- /** Config values for services that declare a `config` schema, keyed by service ID. */
36
+ /** Config values for provisions that declare a `config` schema, keyed by provision ID. */
37
37
  readonly configValues?:
38
38
  | Readonly<Record<string, Record<string, unknown>>>
39
39
  | undefined;
@@ -42,8 +42,8 @@ export interface BuildMcpToolsOptions {
42
42
  | undefined;
43
43
  readonly excludeTrails?: readonly string[] | undefined;
44
44
  readonly includeTrails?: readonly string[] | undefined;
45
- readonly layers?: readonly Layer[] | undefined;
46
- readonly services?: ServiceOverrideMap | undefined;
45
+ readonly gates?: readonly Gate[] | undefined;
46
+ readonly provisions?: ProvisionOverrideMap | undefined;
47
47
  }
48
48
 
49
49
  export interface McpToolDefinition {
@@ -64,7 +64,7 @@ export interface McpExtra {
64
64
  readonly sendProgress?:
65
65
  | ((current: number, total: number) => Promise<void>)
66
66
  | undefined;
67
- readonly signal?: AbortSignal | undefined;
67
+ readonly abortSignal?: AbortSignal | undefined;
68
68
  }
69
69
 
70
70
  export interface McpToolResult {
@@ -212,20 +212,20 @@ const mcpError = (message: string): McpToolResult => ({
212
212
  isError: true,
213
213
  });
214
214
 
215
- /** Add the MCP surface marker while preserving any existing context extras. */
216
- const withMcpSurface = (
215
+ /** Add the MCP trailhead marker while preserving any existing context extras. */
216
+ const withMcpTrailhead = (
217
217
  progressCb: TrailContextInit['progress']
218
218
  ): Partial<TrailContextInit> => ({
219
219
  ...(progressCb === undefined ? {} : { progress: progressCb }),
220
220
  extensions: {
221
- [SURFACE_KEY]: 'mcp' as const,
221
+ [TRAILHEAD_KEY]: 'mcp' as const,
222
222
  },
223
223
  });
224
224
 
225
225
  const createHandler =
226
226
  (
227
227
  t: Trail<unknown, unknown>,
228
- layers: readonly Layer[],
228
+ gates: readonly Gate[],
229
229
  options: BuildMcpToolsOptions
230
230
  ): ((
231
231
  args: Record<string, unknown>,
@@ -234,12 +234,12 @@ const createHandler =
234
234
  async (args, extra): Promise<McpToolResult> => {
235
235
  const progressCb = createMcpProgressCallback(extra);
236
236
  const result = await executeTrail(t, args, {
237
+ abortSignal: extra.abortSignal,
237
238
  configValues: options.configValues,
238
239
  createContext: options.createContext,
239
- ctx: withMcpSurface(progressCb),
240
- layers,
241
- services: options.services,
242
- signal: extra.signal,
240
+ ctx: withMcpTrailhead(progressCb),
241
+ gates,
242
+ provisions: options.provisions,
243
243
  });
244
244
  if (result.isOk()) {
245
245
  return { content: await serializeOutput(result.value) };
@@ -257,15 +257,15 @@ const createHandler =
257
257
  * Each trail in the topo becomes an McpToolDefinition with:
258
258
  * - A derived tool name (app-prefixed, underscore-delimited)
259
259
  * - JSON Schema input from zodToJsonSchema
260
- * - MCP annotations from trail metadata
261
- * - A handler that validates, composes layers, executes, and maps results
260
+ * - MCP annotations from trail meta
261
+ * - A handler that validates, composes gates, executes, and maps results
262
262
  */
263
- /** Check if a trail should be included based on metadata and filters. */
263
+ /** Check if a trail should be included based on meta and filters. */
264
264
  const shouldInclude = (
265
265
  trail: Trail<unknown, unknown>,
266
266
  options: BuildMcpToolsOptions
267
267
  ): boolean => {
268
- if (trail.metadata?.['internal'] === true) {
268
+ if (trail.meta?.['internal'] === true) {
269
269
  return false;
270
270
  }
271
271
  if (options.includeTrails !== undefined && options.includeTrails.length > 0) {
@@ -302,7 +302,7 @@ const buildDescription = (
302
302
  const buildToolDefinition = (
303
303
  app: Topo,
304
304
  trail: Trail<unknown, unknown>,
305
- layers: readonly Layer[],
305
+ gates: readonly Gate[],
306
306
  options: BuildMcpToolsOptions
307
307
  ): McpToolDefinition => {
308
308
  const rawAnnotations = deriveAnnotations(trail);
@@ -311,7 +311,7 @@ const buildToolDefinition = (
311
311
  return {
312
312
  annotations,
313
313
  description: buildDescription(trail),
314
- handler: createHandler(trail, layers, options),
314
+ handler: createHandler(trail, gates, options),
315
315
  inputSchema: zodToJsonSchema(trail.input),
316
316
  name: deriveToolName(app.name, trail.id),
317
317
  trailId: trail.id,
@@ -322,7 +322,7 @@ const buildToolDefinition = (
322
322
  const registerTool = (
323
323
  app: Topo,
324
324
  trailItem: Trail<unknown, unknown>,
325
- layers: readonly Layer[],
325
+ gates: readonly Gate[],
326
326
  options: BuildMcpToolsOptions,
327
327
  nameToTrailId: Map<string, string>,
328
328
  tools: McpToolDefinition[]
@@ -337,7 +337,7 @@ const registerTool = (
337
337
  );
338
338
  }
339
339
  nameToTrailId.set(toolName, trailItem.id);
340
- tools.push(buildToolDefinition(app, trailItem, layers, options));
340
+ tools.push(buildToolDefinition(app, trailItem, gates, options));
341
341
  return Result.ok();
342
342
  };
343
343
 
@@ -352,7 +352,7 @@ export const buildMcpTools = (
352
352
  app: Topo,
353
353
  options: BuildMcpToolsOptions = {}
354
354
  ): Result<McpToolDefinition[], Error> => {
355
- const layers = options.layers ?? [];
355
+ const gates = options.gates ?? [];
356
356
  const tools: McpToolDefinition[] = [];
357
357
  const nameToTrailId = new Map<string, string>();
358
358
 
@@ -360,7 +360,7 @@ export const buildMcpTools = (
360
360
  const registered = registerTool(
361
361
  app,
362
362
  trailItem,
363
- layers,
363
+ gates,
364
364
  options,
365
365
  nameToTrailId,
366
366
  tools
package/src/index.ts CHANGED
@@ -17,8 +17,8 @@ export { deriveAnnotations, type McpAnnotations } from './annotations.js';
17
17
  // Progress
18
18
  export { createMcpProgressCallback } from './progress.js';
19
19
 
20
- // Blaze
21
- export { blaze, type BlazeMcpOptions } from './blaze.js';
20
+ // Trailhead
21
+ export { trailhead, type TrailheadMcpOptions } from './trailhead.js';
22
22
 
23
23
  // Transport
24
24
  export { connectStdio } from './stdio.js';
package/src/stdio.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 blaze().
5
+ * (SSE, streamable HTTP) without changing trailhead().
6
6
  */
7
7
 
8
8
  import type { Server } from '@modelcontextprotocol/sdk/server/index.js';
@@ -1,11 +1,11 @@
1
1
  /**
2
- * blaze() -- the one-liner MCP server launcher.
2
+ * trailhead() -- the one-liner MCP server launcher.
3
3
  *
4
4
  * Three lines to expose trails as MCP tools:
5
5
  *
6
6
  * ```ts
7
7
  * const app = topo("myapp", entity);
8
- * await blaze(app);
8
+ * await trailhead(app);
9
9
  * ```
10
10
  */
11
11
 
@@ -15,8 +15,8 @@ import {
15
15
  ListToolsRequestSchema,
16
16
  } from '@modelcontextprotocol/sdk/types.js';
17
17
  import type {
18
- Layer,
19
- ServiceOverrideMap,
18
+ Gate,
19
+ ProvisionOverrideMap,
20
20
  Topo,
21
21
  TrailContextInit,
22
22
  } from '@ontrails/core';
@@ -30,8 +30,8 @@ import { connectStdio } from './stdio.js';
30
30
  // Options
31
31
  // ---------------------------------------------------------------------------
32
32
 
33
- export interface BlazeMcpOptions {
34
- /** Config values for services that declare a `config` schema, keyed by service ID. */
33
+ export interface TrailheadMcpOptions {
34
+ /** Config values for provisions that declare a `config` schema, keyed by provision ID. */
35
35
  readonly configValues?:
36
36
  | Readonly<Record<string, Record<string, unknown>>>
37
37
  | undefined;
@@ -40,7 +40,8 @@ export interface BlazeMcpOptions {
40
40
  | undefined;
41
41
  readonly excludeTrails?: readonly string[] | undefined;
42
42
  readonly includeTrails?: readonly string[] | undefined;
43
- readonly layers?: readonly Layer[] | undefined;
43
+ readonly gates?: readonly Gate[] | undefined;
44
+ readonly provisions?: ProvisionOverrideMap | undefined;
44
45
  readonly serverInfo?:
45
46
  | {
46
47
  readonly name?: string | undefined;
@@ -48,7 +49,6 @@ export interface BlazeMcpOptions {
48
49
  }
49
50
  | undefined;
50
51
  readonly transport?: 'stdio' | undefined;
51
- readonly services?: ServiceOverrideMap | undefined;
52
52
  /** Set to `false` to skip topo validation at startup. Defaults to `true`. */
53
53
  readonly validate?: boolean | undefined;
54
54
  }
@@ -119,9 +119,9 @@ export const createMcpServer = (
119
119
  };
120
120
 
121
121
  const extra = {
122
+ abortSignal: undefined as AbortSignal | undefined,
122
123
  progressToken,
123
124
  sendProgress,
124
- signal: undefined as AbortSignal | undefined,
125
125
  };
126
126
 
127
127
  const result = await tool.handler(args, extra);
@@ -133,15 +133,15 @@ export const createMcpServer = (
133
133
  };
134
134
 
135
135
  // ---------------------------------------------------------------------------
136
- // blaze
136
+ // trailhead
137
137
  // ---------------------------------------------------------------------------
138
138
 
139
139
  /**
140
140
  * Build MCP tools from an App, create a server, and connect via stdio.
141
141
  */
142
- export const blaze = async (
142
+ export const trailhead = async (
143
143
  app: Topo,
144
- options: BlazeMcpOptions = {}
144
+ options: TrailheadMcpOptions = {}
145
145
  ): Promise<void> => {
146
146
  if (options.validate !== false) {
147
147
  const validated = validateTopo(app);
@@ -154,9 +154,9 @@ export const blaze = async (
154
154
  configValues: options.configValues,
155
155
  createContext: options.createContext,
156
156
  excludeTrails: options.excludeTrails,
157
+ gates: options.gates,
157
158
  includeTrails: options.includeTrails,
158
- layers: options.layers,
159
- services: options.services,
159
+ provisions: options.provisions,
160
160
  });
161
161
 
162
162
  if (toolsResult.isErr()) {
@@ -1 +1 @@
1
- {"root":["./src/annotations.ts","./src/blaze.ts","./src/build.ts","./src/index.ts","./src/progress.ts","./src/stdio.ts","./src/tool-name.ts"],"version":"5.9.3"}
1
+ {"root":["./src/annotations.ts","./src/build.ts","./src/index.ts","./src/progress.ts","./src/stdio.ts","./src/tool-name.ts","./src/trailhead.ts"],"version":"5.9.3"}