@ontrails/mcp 1.0.0-beta.14 → 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.
- package/CHANGELOG.md +41 -0
- package/README.md +36 -17
- package/package.json +11 -3
- package/src/annotations.ts +4 -1
- package/src/build.ts +689 -127
- package/src/index.ts +14 -4
- package/src/stdio.ts +1 -1
- package/src/surface.ts +215 -0
- package/.turbo/turbo-build.log +0 -1
- package/.turbo/turbo-lint.log +0 -3
- package/.turbo/turbo-typecheck.log +0 -1
- package/dist/annotations.d.ts +0 -19
- package/dist/annotations.d.ts.map +0 -1
- package/dist/annotations.js +0 -31
- package/dist/annotations.js.map +0 -1
- package/dist/blaze.d.ts +0 -41
- package/dist/blaze.d.ts.map +0 -1
- package/dist/blaze.js +0 -108
- package/dist/blaze.js.map +0 -1
- package/dist/build.d.ts +0 -48
- package/dist/build.d.ts.map +0 -1
- package/dist/build.js +0 -229
- package/dist/build.js.map +0 -1
- package/dist/index.d.ts +0 -7
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -13
- package/dist/index.js.map +0 -1
- package/dist/progress.d.ts +0 -13
- package/dist/progress.d.ts.map +0 -1
- package/dist/progress.js +0 -51
- package/dist/progress.js.map +0 -1
- package/dist/stdio.d.ts +0 -12
- package/dist/stdio.d.ts.map +0 -1
- package/dist/stdio.js +0 -15
- package/dist/stdio.js.map +0 -1
- package/dist/tool-name.d.ts +0 -15
- package/dist/tool-name.d.ts.map +0 -1
- package/dist/tool-name.js +0 -19
- package/dist/tool-name.js.map +0 -1
- package/dist/trailhead.d.ts +0 -41
- package/dist/trailhead.d.ts.map +0 -1
- package/dist/trailhead.js +0 -109
- package/dist/trailhead.js.map +0 -1
- package/src/__tests__/annotations.test.ts +0 -63
- package/src/__tests__/build.test.ts +0 -529
- package/src/__tests__/progress.test.ts +0 -136
- package/src/__tests__/tool-name.test.ts +0 -46
- package/src/__tests__/trailhead.test.ts +0 -158
- package/src/trailhead.ts +0 -173
- package/tsconfig.json +0 -9
- package/tsconfig.tsbuildinfo +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,46 @@
|
|
|
1
1
|
# @ontrails/mcp
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.16
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 26f9ffd: Project typed-layer `input` schemas onto MCP and HTTP surfaces. Closes Phase 7. Lifts `collectAttachedTypedLayers` and `projectLayerFieldName` (collision-rename rule) into `@ontrails/core/internal/layer-projection` so all three surfaces share one source of truth. The CLI surface refactors to consume the lifted helpers (no behavior change). MCP merges layer fields into each tool's `inputSchema` and partitions inbound args at invocation time. HTTP merges layer fields into the route's request schema (query for reads, body for writes) and exposes new optional `HttpRouteDefinition.inputSchema` + `layerInputProjections` for surface adapters / OpenAPI generators. Collision rule matches TRL-473's: deterministic rename to a layer-prefixed camelCase name with the original captured in the routing table. Side fix: MCP and HTTP handlers now forward `topoLayers: graph.layers` + `surfaceLayers: layers` so topo-scope layers actually compose at runtime (previously the handlers used the deprecated `layers` alias and never read `graph.layers`).
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 6300f70: Refresh source comments and test labels for retired connector terminology as adapter guardrails become strict.
|
|
12
|
+
- 20d7a5c: Enforce the shared safe error projection policy for public error bodies, diagnostics, serialized payloads, and CLI stderr.
|
|
13
|
+
- 49c2e7d: Refresh published package README taxonomy to use adapter language instead of retired connector vocabulary.
|
|
14
|
+
- Updated dependencies [73622ae]
|
|
15
|
+
- Updated dependencies [6300f70]
|
|
16
|
+
- Updated dependencies [d172013]
|
|
17
|
+
- Updated dependencies [c3fc5c3]
|
|
18
|
+
- Updated dependencies [20d7a5c]
|
|
19
|
+
- Updated dependencies [be5fb46]
|
|
20
|
+
- Updated dependencies [e898cc4]
|
|
21
|
+
- Updated dependencies [3395234]
|
|
22
|
+
- Updated dependencies [bcdc484]
|
|
23
|
+
- Updated dependencies [331e3a9]
|
|
24
|
+
- Updated dependencies [4399fdb]
|
|
25
|
+
- Updated dependencies [4b8d13b]
|
|
26
|
+
- Updated dependencies [112b9f2]
|
|
27
|
+
- Updated dependencies [893025e]
|
|
28
|
+
- Updated dependencies [eec5e9d]
|
|
29
|
+
- Updated dependencies [ebd4434]
|
|
30
|
+
- Updated dependencies [863d473]
|
|
31
|
+
- Updated dependencies [344f2f7]
|
|
32
|
+
- Updated dependencies [26f9ffd]
|
|
33
|
+
- Updated dependencies [10eae9a]
|
|
34
|
+
- Updated dependencies [22c6c06]
|
|
35
|
+
- @ontrails/core@1.0.0-beta.16
|
|
36
|
+
|
|
37
|
+
## 1.0.0-beta.15
|
|
38
|
+
|
|
39
|
+
### Patch Changes
|
|
40
|
+
|
|
41
|
+
- Updated dependencies [4ad6b25]
|
|
42
|
+
- @ontrails/core@1.0.0-beta.15
|
|
43
|
+
|
|
3
44
|
## 1.0.0-beta.14
|
|
4
45
|
|
|
5
46
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -1,58 +1,68 @@
|
|
|
1
1
|
# @ontrails/mcp
|
|
2
2
|
|
|
3
|
-
MCP
|
|
3
|
+
MCP surface adapter. One `surface()` call turns a topo into an MCP server with tool definitions, annotations, and progress bridging -- all derived from the trail contracts.
|
|
4
4
|
|
|
5
5
|
## Usage
|
|
6
6
|
|
|
7
7
|
```typescript
|
|
8
8
|
import { trail, topo, Result } from '@ontrails/core';
|
|
9
|
-
import {
|
|
9
|
+
import { surface } from '@ontrails/mcp';
|
|
10
10
|
import { z } from 'zod';
|
|
11
11
|
|
|
12
12
|
const greet = trail('greet', {
|
|
13
13
|
input: z.object({ name: z.string().describe('Who to greet') }),
|
|
14
|
+
output: z.object({ greeting: z.string() }),
|
|
14
15
|
intent: 'read',
|
|
15
|
-
|
|
16
|
+
examples: [
|
|
17
|
+
{
|
|
18
|
+
expected: { greeting: 'Hello, Ada!' },
|
|
19
|
+
input: { name: 'Ada' },
|
|
20
|
+
name: 'Ada',
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
blaze: (input) => Result.ok({ greeting: `Hello, ${input.name}!` }),
|
|
16
24
|
});
|
|
17
25
|
|
|
18
|
-
const
|
|
19
|
-
await
|
|
26
|
+
const graph = topo('myapp', { greet });
|
|
27
|
+
await surface(graph);
|
|
20
28
|
```
|
|
21
29
|
|
|
22
|
-
This starts an MCP server over stdio with a `myapp_greet` tool. The tool gets `readOnlyHint: true
|
|
30
|
+
This starts an MCP server over stdio with a `myapp_greet` tool. The tool gets `readOnlyHint: true`, JSON Schema input, JSON Schema output, and structured examples -- all derived from the trail definition.
|
|
23
31
|
|
|
24
32
|
For more control, build the tools yourself:
|
|
25
33
|
|
|
26
34
|
```typescript
|
|
27
|
-
import {
|
|
35
|
+
import { deriveMcpTools } from '@ontrails/mcp';
|
|
28
36
|
|
|
29
|
-
const result =
|
|
37
|
+
const result = deriveMcpTools(graph);
|
|
30
38
|
if (result.isErr()) throw result.error; // ValidationError on tool-name collision
|
|
31
39
|
for (const tool of result.value) {
|
|
32
40
|
server.registerTool(tool.name, tool.handler, {
|
|
33
41
|
inputSchema: tool.inputSchema,
|
|
42
|
+
outputSchema: tool.outputSchema,
|
|
34
43
|
annotations: tool.annotations,
|
|
44
|
+
_meta: tool._meta,
|
|
35
45
|
});
|
|
36
46
|
}
|
|
37
47
|
```
|
|
38
48
|
|
|
39
|
-
`
|
|
49
|
+
`deriveMcpTools` returns `Result<McpToolDefinition[], Error>` rather than a bare array. It returns `Result.err(ValidationError)` if two trails derive the same MCP tool name. Each `McpToolDefinition` includes a `trailId` field that records which trail the tool was derived from.
|
|
40
50
|
|
|
41
51
|
## API
|
|
42
52
|
|
|
43
53
|
| Export | What it does |
|
|
44
54
|
| --- | --- |
|
|
45
|
-
| `
|
|
46
|
-
| `
|
|
55
|
+
| `surface(graph, options?)` | Start an MCP server with all trails as tools |
|
|
56
|
+
| `deriveMcpTools(graph, options?)` | Build tool definitions without starting a server |
|
|
47
57
|
| `deriveToolName(appName, trailId)` | Compute the MCP tool name from app and trail IDs |
|
|
48
|
-
| `deriveAnnotations(trail)` | Extract MCP annotations from trail intent and
|
|
58
|
+
| `deriveAnnotations(trail)` | Extract MCP annotations from trail intent, idempotency, and description |
|
|
49
59
|
| `createMcpProgressCallback(server)` | Bridge `ctx.progress` to MCP `notifications/progress` |
|
|
50
60
|
|
|
51
61
|
See the [API Reference](../../docs/api-reference.md) for the full list.
|
|
52
62
|
|
|
53
63
|
## Annotations
|
|
54
64
|
|
|
55
|
-
Trail intent and
|
|
65
|
+
Trail intent, idempotency, and description map directly to MCP annotations:
|
|
56
66
|
|
|
57
67
|
| Trail field | MCP annotation |
|
|
58
68
|
| --- | --- |
|
|
@@ -63,13 +73,19 @@ Trail intent and metadata map directly to MCP annotations:
|
|
|
63
73
|
|
|
64
74
|
No manual annotation definitions. The contract is the source of truth.
|
|
65
75
|
|
|
76
|
+
## Schemas and Examples
|
|
77
|
+
|
|
78
|
+
MCP tool definitions include the trail's input schema, and trails with an `output` schema also project that schema into MCP `outputSchema`. Non-object trail outputs are wrapped in a `{ data: ... }` object because MCP structured tool results are object-shaped.
|
|
79
|
+
|
|
80
|
+
Trail examples are projected as structured metadata under `_meta["ontrails/examples"]`. Each projected example preserves its input, expected output or error, a success/error kind, and provenance pointing back to the authored `trail.examples` field.
|
|
81
|
+
|
|
66
82
|
## Tool naming
|
|
67
83
|
|
|
68
84
|
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.
|
|
69
85
|
|
|
70
|
-
##
|
|
86
|
+
## Resource resolution
|
|
71
87
|
|
|
72
|
-
Declared
|
|
88
|
+
Declared resources on each trail are resolved into the context before the implementation runs.
|
|
73
89
|
|
|
74
90
|
## Progress bridge
|
|
75
91
|
|
|
@@ -90,10 +106,13 @@ const importTrail = trail('data.import', {
|
|
|
90
106
|
## Filtering
|
|
91
107
|
|
|
92
108
|
```typescript
|
|
93
|
-
await
|
|
94
|
-
await
|
|
109
|
+
await surface(graph, { include: ['entity.**', 'search'] });
|
|
110
|
+
await surface(graph, { exclude: ['internal.debug'] });
|
|
95
111
|
```
|
|
96
112
|
|
|
113
|
+
`*` matches one dotted segment and `**` matches any depth. Trails declared with
|
|
114
|
+
`visibility: 'internal'` stay hidden unless you include their exact trail ID.
|
|
115
|
+
|
|
97
116
|
## Installation
|
|
98
117
|
|
|
99
118
|
```bash
|
package/package.json
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ontrails/mcp",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.16",
|
|
4
|
+
"files": [
|
|
5
|
+
"src/**/*.ts",
|
|
6
|
+
"!src/**/__tests__/**",
|
|
7
|
+
"!src/**/*.test.ts",
|
|
8
|
+
"!src/**/*.test-d.ts",
|
|
9
|
+
"README.md",
|
|
10
|
+
"CHANGELOG.md"
|
|
11
|
+
],
|
|
4
12
|
"type": "module",
|
|
5
13
|
"exports": {
|
|
6
14
|
".": "./src/index.ts",
|
|
@@ -14,10 +22,10 @@
|
|
|
14
22
|
"clean": "rm -rf dist *.tsbuildinfo"
|
|
15
23
|
},
|
|
16
24
|
"dependencies": {
|
|
17
|
-
"@ontrails/core": "^1.0.0-beta.
|
|
25
|
+
"@ontrails/core": "^1.0.0-beta.15"
|
|
18
26
|
},
|
|
19
27
|
"peerDependencies": {
|
|
20
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
28
|
+
"@modelcontextprotocol/sdk": "^1.28.0",
|
|
21
29
|
"zod": "^4.3.5"
|
|
22
30
|
}
|
|
23
31
|
}
|
package/src/annotations.ts
CHANGED
|
@@ -27,7 +27,10 @@ export interface McpAnnotations {
|
|
|
27
27
|
* Omitted hints let the MCP SDK use its defaults.
|
|
28
28
|
*/
|
|
29
29
|
export const deriveAnnotations = (
|
|
30
|
-
trail: Pick<
|
|
30
|
+
trail: Pick<
|
|
31
|
+
Trail<unknown, unknown, unknown>,
|
|
32
|
+
'intent' | 'idempotent' | 'description'
|
|
33
|
+
>
|
|
31
34
|
): McpAnnotations => {
|
|
32
35
|
const annotations: Record<string, unknown> = {};
|
|
33
36
|
|