@ontrails/mcp 1.0.0-beta.1 → 1.0.0-beta.11
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/.turbo/turbo-lint.log +1 -1
- package/CHANGELOG.md +146 -0
- package/README.md +16 -9
- package/dist/annotations.d.ts +2 -2
- package/dist/annotations.d.ts.map +1 -1
- package/dist/annotations.js +8 -6
- package/dist/annotations.js.map +1 -1
- package/dist/blaze.d.ts +5 -2
- package/dist/blaze.d.ts.map +1 -1
- package/dist/blaze.js +13 -2
- package/dist/blaze.js.map +1 -1
- package/dist/build.d.ts +7 -3
- package/dist/build.d.ts.map +1 -1
- package/dist/build.js +80 -62
- package/dist/build.js.map +1 -1
- package/package.json +3 -3
- package/src/__tests__/annotations.test.ts +15 -22
- package/src/__tests__/blaze.test.ts +67 -14
- package/src/__tests__/build.test.ts +188 -61
- package/src/annotations.ts +11 -11
- package/src/blaze.ts +25 -4
- package/src/build.ts +129 -92
package/dist/build.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,MAAM,EACN,eAAe,EACf,YAAY,EACZ,SAAS,EACT,eAAe,GAChB,MAAM,gBAAgB,CAAC;AAWxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAkDhD,8EAA8E;AAC9E,wCAAwC;AACxC,8EAA8E;AAE9E,0EAA0E;AAC1E,MAAM,YAAY,GAAG,CACnB,MAAoB,EACpB,WAAmB,EACP,EAAE;IACd,MAAM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AG,EAAkB,CAAC;IAEhD,KAAK,MAAM,SAAS,IAAI,cAAc,CAAC,GAAG,EAAE,OAAO,CAAC,EAAE,CAAC;QACrD,MAAM,UAAU,GAAG,YAAY,CAC7B,GAAG,EACH,SAAS,EACT,MAAM,EACN,OAAO,EACP,aAAa,EACb,KAAK,CACN,CAAC;QACF,IAAI,UAAU,CAAC,KAAK,EAAE,EAAE,CAAC;YACvB,OAAO,UAAU,CAAC;QACpB,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;AAC1B,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ontrails/mcp",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./src/index.ts",
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
"clean": "rm -rf dist *.tsbuildinfo"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@ontrails/core": "
|
|
17
|
+
"@ontrails/core": "^1.0.0-beta.8"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
20
|
"@modelcontextprotocol/sdk": "^1.12.0",
|
|
21
|
-
"zod": "
|
|
21
|
+
"zod": "^4.3.5"
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -3,36 +3,39 @@ import { describe, expect, test } from 'bun:test';
|
|
|
3
3
|
import { deriveAnnotations } from '../annotations.js';
|
|
4
4
|
|
|
5
5
|
describe('deriveAnnotations', () => {
|
|
6
|
-
test('
|
|
7
|
-
const annotations = deriveAnnotations({
|
|
6
|
+
test('read intent produces readOnlyHint', () => {
|
|
7
|
+
const annotations = deriveAnnotations({ intent: 'read' });
|
|
8
8
|
expect(annotations.readOnlyHint).toBe(true);
|
|
9
9
|
expect(annotations.destructiveHint).toBeUndefined();
|
|
10
10
|
expect(annotations.idempotentHint).toBeUndefined();
|
|
11
11
|
});
|
|
12
12
|
|
|
13
|
-
test('
|
|
14
|
-
const annotations = deriveAnnotations({
|
|
13
|
+
test('destroy intent produces destructiveHint', () => {
|
|
14
|
+
const annotations = deriveAnnotations({ intent: 'destroy' });
|
|
15
15
|
expect(annotations.destructiveHint).toBe(true);
|
|
16
16
|
expect(annotations.readOnlyHint).toBeUndefined();
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
test('idempotent trail produces idempotentHint', () => {
|
|
20
|
-
const annotations = deriveAnnotations({
|
|
20
|
+
const annotations = deriveAnnotations({
|
|
21
|
+
idempotent: true,
|
|
22
|
+
intent: 'write',
|
|
23
|
+
});
|
|
21
24
|
expect(annotations.idempotentHint).toBe(true);
|
|
22
25
|
});
|
|
23
26
|
|
|
24
|
-
test('
|
|
27
|
+
test('read intent with idempotent combines correctly', () => {
|
|
25
28
|
const annotations = deriveAnnotations({
|
|
26
29
|
idempotent: true,
|
|
27
|
-
|
|
30
|
+
intent: 'read',
|
|
28
31
|
});
|
|
29
32
|
expect(annotations.readOnlyHint).toBe(true);
|
|
30
33
|
expect(annotations.idempotentHint).toBe(true);
|
|
31
34
|
expect(annotations.destructiveHint).toBeUndefined();
|
|
32
35
|
});
|
|
33
36
|
|
|
34
|
-
test('
|
|
35
|
-
const annotations = deriveAnnotations({});
|
|
37
|
+
test('write intent produces empty annotations', () => {
|
|
38
|
+
const annotations = deriveAnnotations({ intent: 'write' });
|
|
36
39
|
expect(annotations.readOnlyHint).toBeUndefined();
|
|
37
40
|
expect(annotations.destructiveHint).toBeUndefined();
|
|
38
41
|
expect(annotations.idempotentHint).toBeUndefined();
|
|
@@ -42,29 +45,19 @@ describe('deriveAnnotations', () => {
|
|
|
42
45
|
test('description maps to title', () => {
|
|
43
46
|
const annotations = deriveAnnotations({
|
|
44
47
|
description: 'Show entity details',
|
|
48
|
+
intent: 'write',
|
|
45
49
|
});
|
|
46
50
|
expect(annotations.title).toBe('Show entity details');
|
|
47
51
|
});
|
|
48
52
|
|
|
49
|
-
test('all
|
|
53
|
+
test('all hints plus description', () => {
|
|
50
54
|
const annotations = deriveAnnotations({
|
|
51
55
|
description: 'A trail',
|
|
52
|
-
destructive: true,
|
|
53
56
|
idempotent: true,
|
|
54
|
-
|
|
57
|
+
intent: 'destroy',
|
|
55
58
|
});
|
|
56
|
-
expect(annotations.readOnlyHint).toBe(true);
|
|
57
59
|
expect(annotations.destructiveHint).toBe(true);
|
|
58
60
|
expect(annotations.idempotentHint).toBe(true);
|
|
59
61
|
expect(annotations.title).toBe('A trail');
|
|
60
62
|
});
|
|
61
|
-
|
|
62
|
-
test('false values are not included', () => {
|
|
63
|
-
const annotations = deriveAnnotations({
|
|
64
|
-
destructive: false,
|
|
65
|
-
readOnly: false,
|
|
66
|
-
});
|
|
67
|
-
expect(annotations.readOnlyHint).toBeUndefined();
|
|
68
|
-
expect(annotations.destructiveHint).toBeUndefined();
|
|
69
|
-
});
|
|
70
63
|
});
|
|
@@ -3,14 +3,15 @@ import { describe, expect, test } from 'bun:test';
|
|
|
3
3
|
import { Result, trail, topo } from '@ontrails/core';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
|
|
6
|
-
import { createMcpServer } from '../blaze.js';
|
|
6
|
+
import { blaze, createMcpServer } from '../blaze.js';
|
|
7
7
|
import { buildMcpTools } from '../build.js';
|
|
8
|
+
import type { McpToolDefinition } from '../build.js';
|
|
8
9
|
|
|
9
10
|
// ---------------------------------------------------------------------------
|
|
10
11
|
// Tests
|
|
11
12
|
// ---------------------------------------------------------------------------
|
|
12
13
|
|
|
13
|
-
const requireTool = (tools:
|
|
14
|
+
const requireTool = (tools: McpToolDefinition[], name: string) => {
|
|
14
15
|
const tool = tools.find((entry) => entry.name === name);
|
|
15
16
|
expect(tool).toBeDefined();
|
|
16
17
|
if (!tool) {
|
|
@@ -19,35 +20,87 @@ const requireTool = (tools: ReturnType<typeof buildMcpTools>, name: string) => {
|
|
|
19
20
|
return tool;
|
|
20
21
|
};
|
|
21
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Unwrap buildMcpTools result, throwing on error so test failures surface clearly.
|
|
25
|
+
*/
|
|
26
|
+
const buildTools = (
|
|
27
|
+
...args: Parameters<typeof buildMcpTools>
|
|
28
|
+
): McpToolDefinition[] => {
|
|
29
|
+
const result = buildMcpTools(...args);
|
|
30
|
+
if (result.isErr()) {
|
|
31
|
+
throw result.error;
|
|
32
|
+
}
|
|
33
|
+
return result.value;
|
|
34
|
+
};
|
|
35
|
+
|
|
22
36
|
const createIntegrationTools = () => {
|
|
23
37
|
const greetTrail = trail('greet', {
|
|
24
38
|
description: 'Greet someone',
|
|
25
|
-
implementation: (input) => Result.ok({ greeting: `Hello, ${input.name}!` }),
|
|
26
39
|
input: z.object({ name: z.string() }),
|
|
27
|
-
|
|
40
|
+
intent: 'read',
|
|
41
|
+
run: (input) => Result.ok({ greeting: `Hello, ${input.name}!` }),
|
|
28
42
|
});
|
|
29
43
|
|
|
30
44
|
const deleteTrail = trail('item.delete', {
|
|
31
45
|
description: 'Delete an item',
|
|
32
|
-
destructive: true,
|
|
33
|
-
implementation: (_input) => Result.ok({ deleted: true }),
|
|
34
46
|
input: z.object({ id: z.string() }),
|
|
47
|
+
intent: 'destroy',
|
|
48
|
+
run: (_input) => Result.ok({ deleted: true }),
|
|
35
49
|
});
|
|
36
50
|
|
|
37
|
-
return
|
|
51
|
+
return buildTools(topo('myapp', { deleteTrail, greetTrail }));
|
|
38
52
|
};
|
|
39
53
|
|
|
40
54
|
describe('blaze', () => {
|
|
55
|
+
test('blaze throws on invalid topo', async () => {
|
|
56
|
+
const t = trail('broken', {
|
|
57
|
+
follow: ['nonexistent.trail'],
|
|
58
|
+
input: z.object({}),
|
|
59
|
+
output: z.object({}),
|
|
60
|
+
run: () => Result.ok({}),
|
|
61
|
+
});
|
|
62
|
+
const app = topo('test', { t });
|
|
63
|
+
await expect(blaze(app)).rejects.toThrow(/validation/i);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test('blaze skips validation when validate: false', async () => {
|
|
67
|
+
const t = trail('broken', {
|
|
68
|
+
follow: ['nonexistent.trail'],
|
|
69
|
+
input: z.object({}),
|
|
70
|
+
output: z.object({}),
|
|
71
|
+
run: () => Result.ok({}),
|
|
72
|
+
});
|
|
73
|
+
const app = topo('test', { t });
|
|
74
|
+
const result = await Promise.race([
|
|
75
|
+
blaze(app, { validate: false }).then(() => 'resolved' as const),
|
|
76
|
+
// oxlint-disable-next-line avoid-new -- Promise constructor needed for setTimeout-based timeout
|
|
77
|
+
new Promise<'timeout'>((resolve) => {
|
|
78
|
+
setTimeout(() => {
|
|
79
|
+
resolve('timeout');
|
|
80
|
+
}, 50);
|
|
81
|
+
}),
|
|
82
|
+
]);
|
|
83
|
+
expect(['resolved', 'timeout']).toContain(result);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test('BlazeMcpOptions accepts service overrides', () => {
|
|
87
|
+
const opts: Parameters<typeof blaze>[1] = {
|
|
88
|
+
services: {},
|
|
89
|
+
validate: false,
|
|
90
|
+
};
|
|
91
|
+
expect(opts.services).toEqual({});
|
|
92
|
+
});
|
|
93
|
+
|
|
41
94
|
test('createMcpServer registers tools that can be listed', () => {
|
|
42
95
|
const echoTrail = trail('echo', {
|
|
43
96
|
description: 'Echo',
|
|
44
|
-
implementation: (input) => Result.ok({ reply: input.message }),
|
|
45
97
|
input: z.object({ message: z.string() }),
|
|
46
|
-
|
|
98
|
+
intent: 'read',
|
|
99
|
+
run: (input) => Result.ok({ reply: input.message }),
|
|
47
100
|
});
|
|
48
101
|
|
|
49
102
|
const app = topo('testapp', { echoTrail });
|
|
50
|
-
const tools =
|
|
103
|
+
const tools = buildTools(app);
|
|
51
104
|
const server = createMcpServer(tools, {
|
|
52
105
|
name: 'testapp',
|
|
53
106
|
version: '0.1.0',
|
|
@@ -60,19 +113,19 @@ describe('blaze', () => {
|
|
|
60
113
|
test('createMcpServer handles multiple tools', () => {
|
|
61
114
|
const echoTrail = trail('echo', {
|
|
62
115
|
description: 'Echo',
|
|
63
|
-
implementation: (input) => Result.ok({ reply: input.message }),
|
|
64
116
|
input: z.object({ message: z.string() }),
|
|
117
|
+
run: (input) => Result.ok({ reply: input.message }),
|
|
65
118
|
});
|
|
66
119
|
|
|
67
120
|
const searchTrail = trail('search', {
|
|
68
121
|
description: 'Search',
|
|
69
|
-
implementation: (input) => Result.ok({ results: [input.query] }),
|
|
70
122
|
input: z.object({ query: z.string() }),
|
|
71
|
-
|
|
123
|
+
intent: 'read',
|
|
124
|
+
run: (input) => Result.ok({ results: [input.query] }),
|
|
72
125
|
});
|
|
73
126
|
|
|
74
127
|
const app = topo('testapp', { echoTrail, searchTrail });
|
|
75
|
-
const tools =
|
|
128
|
+
const tools = buildTools(app);
|
|
76
129
|
|
|
77
130
|
expect(tools).toHaveLength(2);
|
|
78
131
|
|