@ontrails/mcp 1.0.0-beta.2 → 1.0.0-beta.21

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 +300 -5
  2. package/README.md +70 -21
  3. package/package.json +11 -3
  4. package/src/annotations.ts +32 -9
  5. package/src/build.ts +1236 -137
  6. package/src/index.ts +31 -4
  7. package/src/progress.ts +22 -0
  8. package/src/resources.ts +228 -0
  9. package/src/stdio.ts +9 -1
  10. package/src/surface.ts +279 -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 -190
  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 -377
  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/blaze.ts DELETED
@@ -1,146 +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
-
12
- import { Server } from '@modelcontextprotocol/sdk/server/index.js';
13
- import {
14
- CallToolRequestSchema,
15
- ListToolsRequestSchema,
16
- } from '@modelcontextprotocol/sdk/types.js';
17
- import type { Layer, Topo, TrailContext } from '@ontrails/core';
18
-
19
- import type { McpToolDefinition } from './build.js';
20
- import { buildMcpTools } from './build.js';
21
- import { connectStdio } from './stdio.js';
22
-
23
- // ---------------------------------------------------------------------------
24
- // Options
25
- // ---------------------------------------------------------------------------
26
-
27
- export interface BlazeMcpOptions {
28
- readonly createContext?:
29
- | (() => TrailContext | Promise<TrailContext>)
30
- | undefined;
31
- readonly excludeTrails?: readonly string[] | undefined;
32
- readonly includeTrails?: readonly string[] | undefined;
33
- readonly layers?: readonly Layer[] | undefined;
34
- readonly serverInfo?:
35
- | {
36
- readonly name?: string | undefined;
37
- readonly version?: string | undefined;
38
- }
39
- | undefined;
40
- readonly transport?: 'stdio' | undefined;
41
- }
42
-
43
- // ---------------------------------------------------------------------------
44
- // Internal: create MCP server with tool handlers
45
- // ---------------------------------------------------------------------------
46
-
47
- /**
48
- * Create an MCP Server instance and register all tools.
49
- */
50
- export const createMcpServer = (
51
- tools: McpToolDefinition[],
52
- info: { readonly name: string; readonly version: string }
53
- ): Server => {
54
- const server = new Server(
55
- { name: info.name, version: info.version },
56
- { capabilities: { tools: {} } }
57
- );
58
-
59
- // Build a lookup map for tool dispatch
60
- const toolMap = new Map<string, McpToolDefinition>();
61
- for (const tool of tools) {
62
- toolMap.set(tool.name, tool);
63
- }
64
-
65
- // Register tools/list handler
66
- // oxlint-disable-next-line require-await -- MCP SDK requires async handler
67
- server.setRequestHandler(ListToolsRequestSchema, async () => ({
68
- tools: tools.map((t) => ({
69
- annotations: t.annotations,
70
- description: t.description,
71
- inputSchema: t.inputSchema,
72
- name: t.name,
73
- })),
74
- }));
75
-
76
- // Register tools/call handler
77
- server.setRequestHandler(CallToolRequestSchema, async (request) => {
78
- const tool = toolMap.get(request.params.name);
79
- if (tool === undefined) {
80
- return {
81
- content: [
82
- {
83
- text: `Unknown tool: ${request.params.name}`,
84
- type: 'text' as const,
85
- },
86
- ],
87
- isError: true,
88
- } as Record<string, unknown>;
89
- }
90
-
91
- const args = (request.params.arguments ?? {}) as Record<string, unknown>;
92
- const progressToken = request.params._meta?.progressToken;
93
-
94
- const sendProgress =
95
- progressToken === undefined
96
- ? undefined
97
- : async (current: number, total: number) => {
98
- await server.notification({
99
- method: 'notifications/progress',
100
- params: {
101
- progress: current,
102
- progressToken: progressToken,
103
- total,
104
- },
105
- });
106
- };
107
-
108
- const extra = {
109
- progressToken,
110
- sendProgress,
111
- signal: undefined as AbortSignal | undefined,
112
- };
113
-
114
- const result = await tool.handler(args, extra);
115
- // Spread to satisfy MCP SDK's index-signature requirement
116
- return { ...result } as Record<string, unknown>;
117
- });
118
-
119
- return server;
120
- };
121
-
122
- // ---------------------------------------------------------------------------
123
- // blaze
124
- // ---------------------------------------------------------------------------
125
-
126
- /**
127
- * Build MCP tools from an App, create a server, and connect via stdio.
128
- */
129
- export const blaze = async (
130
- app: Topo,
131
- options: BlazeMcpOptions = {}
132
- ): Promise<void> => {
133
- const tools = buildMcpTools(app, {
134
- createContext: options.createContext,
135
- excludeTrails: options.excludeTrails,
136
- includeTrails: options.includeTrails,
137
- layers: options.layers,
138
- });
139
-
140
- const server = createMcpServer(tools, {
141
- name: options.serverInfo?.name ?? app.name,
142
- version: options.serverInfo?.version ?? '0.1.0',
143
- });
144
-
145
- await connectStdio(server);
146
- };
package/tsconfig.json DELETED
@@ -1,9 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "dist",
5
- "rootDir": "src"
6
- },
7
- "include": ["src"],
8
- "exclude": ["**/__tests__/**", "**/*.test.ts", "dist"]
9
- }
@@ -1 +0,0 @@
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"}