@ontrails/mcp 1.0.0-beta.3 → 1.0.0-beta.32

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 +371 -8
  2. package/README.md +73 -21
  3. package/package.json +11 -3
  4. package/src/annotations.ts +32 -9
  5. package/src/build.ts +1189 -137
  6. package/src/index.ts +32 -4
  7. package/src/progress.ts +22 -0
  8. package/src/resources.ts +336 -0
  9. package/src/stdio.ts +9 -1
  10. package/src/surface.ts +281 -0
  11. package/.turbo/turbo-build.log +0 -1
  12. package/.turbo/turbo-lint.log +0 -3
  13. package/.turbo/turbo-typecheck.log +0 -1
  14. package/dist/annotations.d.ts +0 -19
  15. package/dist/annotations.d.ts.map +0 -1
  16. package/dist/annotations.js +0 -29
  17. package/dist/annotations.js.map +0 -1
  18. package/dist/blaze.d.ts +0 -36
  19. package/dist/blaze.d.ts.map +0 -1
  20. package/dist/blaze.js +0 -96
  21. package/dist/blaze.js.map +0 -1
  22. package/dist/build.d.ts +0 -40
  23. package/dist/build.d.ts.map +0 -1
  24. package/dist/build.js +0 -227
  25. package/dist/build.js.map +0 -1
  26. package/dist/index.d.ts +0 -7
  27. package/dist/index.d.ts.map +0 -1
  28. package/dist/index.js +0 -13
  29. package/dist/index.js.map +0 -1
  30. package/dist/progress.d.ts +0 -13
  31. package/dist/progress.d.ts.map +0 -1
  32. package/dist/progress.js +0 -51
  33. package/dist/progress.js.map +0 -1
  34. package/dist/stdio.d.ts +0 -12
  35. package/dist/stdio.d.ts.map +0 -1
  36. package/dist/stdio.js +0 -15
  37. package/dist/stdio.js.map +0 -1
  38. package/dist/tool-name.d.ts +0 -15
  39. package/dist/tool-name.d.ts.map +0 -1
  40. package/dist/tool-name.js +0 -19
  41. package/dist/tool-name.js.map +0 -1
  42. package/src/__tests__/annotations.test.ts +0 -70
  43. package/src/__tests__/blaze.test.ts +0 -105
  44. package/src/__tests__/build.test.ts +0 -454
  45. package/src/__tests__/progress.test.ts +0 -136
  46. package/src/__tests__/tool-name.test.ts +0 -46
  47. package/src/blaze.ts +0 -146
  48. package/tsconfig.json +0 -9
  49. package/tsconfig.tsbuildinfo +0 -1
package/src/surface.ts ADDED
@@ -0,0 +1,281 @@
1
+ /**
2
+ * Surface helpers for exposing a topo over MCP.
3
+ */
4
+
5
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
6
+ import {
7
+ CallToolRequestSchema,
8
+ ErrorCode,
9
+ ListResourcesRequestSchema,
10
+ ListToolsRequestSchema,
11
+ McpError,
12
+ ReadResourceRequestSchema,
13
+ } from '@modelcontextprotocol/sdk/types.js';
14
+ import type {
15
+ BaseSurfaceOptions,
16
+ Layer,
17
+ ResourceOverrideMap,
18
+ Topo,
19
+ TrailContextInit,
20
+ } from '@ontrails/core';
21
+
22
+ import type {
23
+ McpSurfaceFacetMap,
24
+ McpToolDefinition,
25
+ ResolveMcpPermit,
26
+ } from './build.js';
27
+ import { deriveMcpTools } from './build.js';
28
+ import { buildMcpResources } from './resources.js';
29
+ import type { BuiltMcpResources, McpResourcesConfig } from './resources.js';
30
+ import { connectStdio } from './stdio.js';
31
+
32
+ // ---------------------------------------------------------------------------
33
+ // Options
34
+ // ---------------------------------------------------------------------------
35
+
36
+ export interface CreateServerOptions extends BaseSurfaceOptions {
37
+ readonly createContext?:
38
+ | (() => TrailContextInit | Promise<TrailContextInit>)
39
+ | undefined;
40
+ readonly description?: string | undefined;
41
+ readonly facets?: McpSurfaceFacetMap | undefined;
42
+ readonly layers?: readonly Layer[] | undefined;
43
+ readonly mcpResources?: McpResourcesConfig | false | undefined;
44
+ readonly name?: string | undefined;
45
+ readonly resources?: ResourceOverrideMap | undefined;
46
+ readonly resolvePermit?: ResolveMcpPermit | undefined;
47
+ readonly version?: string | undefined;
48
+ }
49
+
50
+ export interface SurfaceMcpResult {
51
+ readonly close: () => Promise<void>;
52
+ }
53
+
54
+ // ---------------------------------------------------------------------------
55
+ // Internal: create MCP server with tool handlers
56
+ // ---------------------------------------------------------------------------
57
+
58
+ /**
59
+ * Create an MCP Server instance and register all tools.
60
+ *
61
+ * When provided, `info.description` is forwarded to the MCP SDK as the
62
+ * server's `instructions` field — the SDK's documented channel for
63
+ * "optional instructions describing how to use the server and its features."
64
+ */
65
+ const createMcpServer = (
66
+ tools: McpToolDefinition[],
67
+ info: {
68
+ readonly name: string;
69
+ readonly version: string;
70
+ readonly description?: string | undefined;
71
+ },
72
+ mcpResources?: BuiltMcpResources | undefined
73
+ ): Server => {
74
+ const server = new Server(
75
+ { name: info.name, version: info.version },
76
+ {
77
+ capabilities: {
78
+ ...(mcpResources === undefined ? {} : { resources: {} }),
79
+ tools: {},
80
+ },
81
+ ...(info.description === undefined
82
+ ? {}
83
+ : { instructions: info.description }),
84
+ }
85
+ );
86
+
87
+ // Build a lookup map for tool dispatch
88
+ const toolMap = new Map<string, McpToolDefinition>();
89
+ for (const tool of tools) {
90
+ toolMap.set(tool.name, tool);
91
+ }
92
+
93
+ // Register tools/list handler
94
+ // oxlint-disable-next-line require-await -- MCP SDK requires async handler
95
+ server.setRequestHandler(ListToolsRequestSchema, async () => ({
96
+ tools: tools.map((t) => ({
97
+ _meta: t._meta,
98
+ annotations: t.annotations,
99
+ description: t.description,
100
+ inputSchema: t.inputSchema,
101
+ name: t.name,
102
+ outputSchema: t.outputSchema,
103
+ })),
104
+ }));
105
+
106
+ // Register tools/call handler
107
+ server.setRequestHandler(
108
+ CallToolRequestSchema,
109
+ async (request, requestExtra) => {
110
+ const tool = toolMap.get(request.params.name);
111
+ if (tool === undefined) {
112
+ return {
113
+ content: [
114
+ {
115
+ text: `Unknown tool: ${request.params.name}`,
116
+ type: 'text' as const,
117
+ },
118
+ ],
119
+ isError: true,
120
+ } as Record<string, unknown>;
121
+ }
122
+
123
+ const args = (request.params.arguments ?? {}) as Record<string, unknown>;
124
+ const progressToken = request.params._meta?.progressToken;
125
+ const { authInfo } = requestExtra as {
126
+ readonly authInfo?:
127
+ | {
128
+ readonly accessToken?: string | undefined;
129
+ readonly sessionId?: string | undefined;
130
+ readonly token?: string | undefined;
131
+ }
132
+ | undefined;
133
+ };
134
+ const authorizationToken = authInfo?.accessToken ?? authInfo?.token;
135
+
136
+ const sendProgress =
137
+ progressToken === undefined
138
+ ? undefined
139
+ : async (current: number, total: number) => {
140
+ await server.notification({
141
+ method: 'notifications/progress',
142
+ params: {
143
+ progress: current,
144
+ progressToken,
145
+ total,
146
+ },
147
+ });
148
+ };
149
+
150
+ const extra = {
151
+ abortSignal: requestExtra.signal,
152
+ ...(authorizationToken === undefined
153
+ ? {}
154
+ : { authorization: `Bearer ${authorizationToken}` }),
155
+ progressToken,
156
+ sendProgress,
157
+ ...(authInfo?.sessionId === undefined
158
+ ? {}
159
+ : { sessionId: authInfo.sessionId }),
160
+ };
161
+
162
+ const result = await tool.handler(args, extra);
163
+ // Spread to satisfy MCP SDK's index-signature requirement
164
+ return { ...result } as Record<string, unknown>;
165
+ }
166
+ );
167
+
168
+ if (mcpResources !== undefined) {
169
+ // oxlint-disable-next-line require-await -- MCP SDK requires async handler
170
+ server.setRequestHandler(ListResourcesRequestSchema, async () => ({
171
+ resources: mcpResources.list.map((resource) => ({
172
+ description: resource.description,
173
+ mimeType: resource.mimeType,
174
+ name: resource.name,
175
+ uri: resource.uri,
176
+ })),
177
+ }));
178
+
179
+ server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
180
+ const content = mcpResources.read(request.params.uri);
181
+ if (content === undefined) {
182
+ throw new McpError(
183
+ ErrorCode.InvalidParams,
184
+ `Resource ${request.params.uri} not found`
185
+ );
186
+ }
187
+ return {
188
+ contents: [content],
189
+ };
190
+ });
191
+ }
192
+
193
+ return server;
194
+ };
195
+
196
+ // ---------------------------------------------------------------------------
197
+ // createServer
198
+ // ---------------------------------------------------------------------------
199
+
200
+ /**
201
+ * Build MCP tools from a topo and create an MCP server.
202
+ *
203
+ * @remarks This is a host materialization boundary. Derivation failures are
204
+ * thrown for server bootstrap code after `deriveMcpTools` has already
205
+ * represented the framework error as a Result.
206
+ *
207
+ * @example
208
+ * ```ts
209
+ * import { connectStdio, createServer } from '@ontrails/mcp';
210
+ *
211
+ * const server = createServer(graph, { name: 'demo' });
212
+ * await connectStdio(server);
213
+ * ```
214
+ */
215
+ export const createServer = (
216
+ graph: Topo,
217
+ options: CreateServerOptions = {}
218
+ ): Server => {
219
+ const toolsResult = deriveMcpTools(graph, {
220
+ configValues: options.configValues,
221
+ createContext: options.createContext,
222
+ exclude: options.exclude,
223
+ facets: options.facets,
224
+ include: options.include,
225
+ intent: options.intent,
226
+ layers: options.layers,
227
+ resolvePermit: options.resolvePermit,
228
+ resources: options.resources,
229
+ validate: options.validate,
230
+ });
231
+
232
+ if (toolsResult.isErr()) {
233
+ throw toolsResult.error;
234
+ }
235
+
236
+ const mcpResources =
237
+ options.mcpResources === false
238
+ ? undefined
239
+ : buildMcpResources(graph, toolsResult.value, options.mcpResources);
240
+
241
+ return createMcpServer(
242
+ toolsResult.value,
243
+ {
244
+ description: options.description ?? graph.description,
245
+ name: options.name ?? graph.name,
246
+ version: options.version ?? graph.version ?? '0.1.0',
247
+ },
248
+ mcpResources
249
+ );
250
+ };
251
+
252
+ // ---------------------------------------------------------------------------
253
+ // surface
254
+ // ---------------------------------------------------------------------------
255
+
256
+ /**
257
+ * Build MCP tools from a topo, create a server, and connect via stdio.
258
+ *
259
+ * @remarks Opens the MCP server on stdio. For custom transports, use
260
+ * `createServer(graph)` with `connectStdio` or your own adapter.
261
+ *
262
+ * @example
263
+ * ```ts
264
+ * import { surface } from '@ontrails/mcp';
265
+ *
266
+ * await surface(graph, { name: 'demo' });
267
+ * ```
268
+ */
269
+ export const surface = async (
270
+ graph: Topo,
271
+ options: CreateServerOptions = {}
272
+ ): Promise<SurfaceMcpResult> => {
273
+ const server = createServer(graph, options);
274
+ await connectStdio(server);
275
+
276
+ return {
277
+ close: async () => {
278
+ await server.close();
279
+ },
280
+ };
281
+ };
@@ -1 +0,0 @@
1
- $ tsc -b
@@ -1,3 +0,0 @@
1
- $ oxlint ./src
2
- Found 0 warnings and 0 errors.
3
- Finished in 25ms 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 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
@@ -1 +0,0 @@
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"}
@@ -1,29 +0,0 @@
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
@@ -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,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"}
package/dist/blaze.d.ts DELETED
@@ -1,36 +0,0 @@
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
@@ -1 +0,0 @@
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;AAEhE,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;CAC1C;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,CAcd,CAAC"}
package/dist/blaze.js DELETED
@@ -1,96 +0,0 @@
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 { 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
package/dist/blaze.js.map DELETED
@@ -1 +0,0 @@
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,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED,8BAA8B;IAC9B,2EAA2E;IAC3E,MAAM,CAAC,iBAAiB,CAAC,sBAAsB,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;QAC5D,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACvB,WAAW,EAAE,CAAC,CAAC,WAAW;YAC1B,WAAW,EAAE,CAAC,CAAC,WAAW;YAC1B,WAAW,EAAE,CAAC,CAAC,WAAW;YAC1B,IAAI,EAAE,C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,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"}
package/dist/build.d.ts DELETED
@@ -1,40 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AASH,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,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,KAAK,EAAE,QAAQ,KACZ,OAAO,CAAC,aAAa,CAAC,CA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