@ontrails/mcp 1.0.0-beta.0 → 1.0.0-beta.1

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.
@@ -1,3 +1,3 @@
1
1
  $ oxlint ./src
2
2
  Found 0 warnings and 0 errors.
3
- Finished in 103ms on 12 files with 93 rules using 24 threads.
3
+ Finished in 54ms on 12 files with 93 rules using 24 threads.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @ontrails/mcp
2
2
 
3
+ ## 1.0.0-beta.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Fix two blocking bugs from real-world migration:
8
+ - Published packages now resolve correctly (workspace:^ instead of workspace:\*)
9
+ - Error forwarding works across different success types (Err no longer carries phantom T)
10
+ - Updated dependencies
11
+ - @ontrails/core@1.0.0-beta.1
12
+
3
13
  ## 1.0.0-beta.0
4
14
 
5
15
  ### Minor Changes
package/README.md CHANGED
@@ -1,14 +1,8 @@
1
1
  # @ontrails/mcp
2
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.
3
+ MCP surface adapter. One `blaze()` call turns a topo into an MCP server with tool definitions, annotations, and progress bridging -- all derived from the trail contracts.
4
4
 
5
- ## Installation
6
-
7
- ```bash
8
- bun add @ontrails/mcp
9
- ```
10
-
11
- ## Quick Start
5
+ ## Usage
12
6
 
13
7
  ```typescript
14
8
  import { trail, topo, Result } from '@ontrails/core';
@@ -25,38 +19,14 @@ const app = topo('myapp', { greet });
25
19
  await blaze(app);
26
20
  ```
27
21
 
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
22
+ This starts an MCP server over stdio with a `myapp_greet` tool. The tool gets `readOnlyHint: true` and a JSON Schema input -- both derived from the trail definition.
33
23
 
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.
24
+ For more control, build the tools yourself:
52
25
 
53
26
  ```typescript
54
27
  import { buildMcpTools } from '@ontrails/mcp';
55
28
 
56
- const tools = buildMcpTools(app, {
57
- includeTrails: ['entity.show', 'search'],
58
- });
59
-
29
+ const tools = buildMcpTools(app);
60
30
  for (const tool of tools) {
61
31
  server.registerTool(tool.name, tool.handler, {
62
32
  inputSchema: tool.inputSchema,
@@ -65,44 +35,38 @@ for (const tool of tools) {
65
35
  }
66
36
  ```
67
37
 
68
- ### Tool Name Derivation
38
+ ## API
69
39
 
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` |
40
+ | Export | What it does |
41
+ | --- | --- |
42
+ | `blaze(app, options?)` | Start an MCP server with all trails as tools |
43
+ | `buildMcpTools(app, options?)` | Build tool definitions without starting a server |
44
+ | `deriveToolName(appName, trailId)` | Compute the MCP tool name from app and trail IDs |
45
+ | `deriveAnnotations(trail)` | Extract MCP annotations from trail markers |
46
+ | `createMcpProgressCallback(server)` | Bridge `ctx.progress` to MCP `notifications/progress` |
77
47
 
78
- Rules: dots become underscores, hyphens become underscores, everything lowercase. Names match MCP convention `[a-z0-9_]+`.
48
+ See the [API Reference](../../docs/api-reference.md) for the full list.
79
49
 
80
- ```typescript
81
- import { deriveToolName } from '@ontrails/mcp';
82
- deriveToolName('myapp', 'entity.show'); // "myapp_entity_show"
83
- ```
50
+ ## Annotations
84
51
 
85
- ### Annotation Auto-Generation
52
+ Trail markers map directly to MCP annotations:
86
53
 
87
- Trail markers map directly to MCP tool annotations:
54
+ | Trail field | MCP annotation |
55
+ | --- | --- |
56
+ | `readOnly: true` | `readOnlyHint: true` |
57
+ | `destructive: true` | `destructiveHint: true` |
58
+ | `idempotent: true` | `idempotentHint: true` |
59
+ | `description` | `title` |
88
60
 
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 |
61
+ No manual annotation definitions. The contract is the source of truth.
95
62
 
96
- ```typescript
97
- import { deriveAnnotations } from '@ontrails/mcp';
98
- deriveAnnotations(showTrail); // { readOnlyHint: true, title: "Show entity details" }
99
- ```
63
+ ## Tool naming
100
64
 
101
- Trails without markers produce empty annotations (MCP SDK defaults apply).
65
+ Trail IDs become MCP tool names with the app prefix: `entity.show` in app `myapp` becomes `myapp_entity_show`. Dots and hyphens become underscores, everything lowercase.
102
66
 
103
- ### Progress Bridge
67
+ ## Progress bridge
104
68
 
105
- Trail implementations report progress via `ctx.progress`. On MCP, these bridge to `notifications/progress`:
69
+ Implementations report progress through `ctx.progress`. On MCP, these bridge to `notifications/progress` when the client sends a `progressToken`:
106
70
 
107
71
  ```typescript
108
72
  const importTrail = trail('data.import', {
@@ -116,46 +80,15 @@ const importTrail = trail('data.import', {
116
80
  });
117
81
  ```
118
82
 
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
83
+ ## Filtering
130
84
 
131
85
  ```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'] });
86
+ await blaze(app, { includeTrails: ['entity.show', 'search'] });
87
+ await blaze(app, { excludeTrails: ['internal.debug'] });
137
88
  ```
138
89
 
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
90
+ ## Installation
146
91
 
147
- ```typescript
148
- import {
149
- blaze,
150
- buildMcpTools,
151
- deriveToolName,
152
- deriveAnnotations,
153
- createMcpProgressCallback,
154
- connectStdio,
155
- } from '@ontrails/mcp';
92
+ ```bash
93
+ bun add @ontrails/mcp
156
94
  ```
157
-
158
- ## Further Reading
159
-
160
- - [MCP Surface Guide](../../docs/surfaces/mcp.md)
161
- - [Getting Started](../../docs/getting-started.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ontrails/mcp",
3
- "version": "1.0.0-beta.0",
3
+ "version": "1.0.0-beta.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./src/index.ts",
@@ -14,7 +14,7 @@
14
14
  "clean": "rm -rf dist *.tsbuildinfo"
15
15
  },
16
16
  "dependencies": {
17
- "@ontrails/core": "workspace:*"
17
+ "@ontrails/core": "workspace:^"
18
18
  },
19
19
  "peerDependencies": {
20
20
  "@modelcontextprotocol/sdk": "^1.12.0",