@ouispec/agent-mcp 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Closure Studio
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,14 @@
1
+ # @ouispec/agent-mcp
2
+
3
+ A Model Context Protocol server for a product's agent tools.
4
+
5
+ ```sh
6
+ npm install @ouispec/agent-mcp
7
+ ```
8
+
9
+ - `createMCPApiToolServer` serves the tools `@ouispec/agent-worker` generates from the product's OpenAPI document. Each call runs as the MCP client's own principal, with that user's permissions, and an operation's declared effect decides whether it is offered as a read or a write.
10
+ - `handleMCPRequest` answers one MCP request over HTTP, for a product that hosts the server behind its own API.
11
+ - `createMCPToolServer` and `registerOUISurfaces` serve a product's own tools and its OUI surfaces.
12
+ - `createMCPServer` serves agent SDK intents.
13
+
14
+ The server names itself from what the product passes; nothing defaults to another product's name. It releases with the rest of the agent SDK, under one version: see [VERSIONING.md](https://github.com/wesreid/oui/blob/main/VERSIONING.md).
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Test fixtures for MCP server tests.
3
+ *
4
+ * Provides mock implementations of SchemaRegistry, AgentApiSurface, and
5
+ * UISurfaceSchema that carry realistic data for integration testing.
6
+ */
7
+ import type { SchemaRegistry, AgentApiSurface, IntentResult, UISurfaceSchema } from '@ouispec/agent-core';
8
+ export declare function createMockRegistry(): SchemaRegistry;
9
+ export interface MockApiOptions {
10
+ executeResult?: IntentResult;
11
+ executeError?: Error;
12
+ }
13
+ export declare function createMockApi(options?: MockApiOptions): AgentApiSurface;
14
+ export declare function createMockSurface(): UISurfaceSchema;
15
+ //# sourceMappingURL=fixtures.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../../src/__tests__/fixtures.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EAOf,YAAY,EAIZ,eAAe,EAChB,MAAM,qBAAqB,CAAC;AAwI7B,wBAAgB,kBAAkB,IAAI,cAAc,CAcnD;AAMD,MAAM,WAAW,cAAc;IAC7B,aAAa,CAAC,EAAE,YAAY,CAAC;IAC7B,YAAY,CAAC,EAAE,KAAK,CAAC;CACtB;AAED,wBAAgB,aAAa,CAAC,OAAO,GAAE,cAAmB,GAAG,eAAe,CA4B3E;AAMD,wBAAgB,iBAAiB,IAAI,eAAe,CAmGnD"}
@@ -0,0 +1,250 @@
1
+ /**
2
+ * Test fixtures for MCP server tests.
3
+ *
4
+ * Provides mock implementations of SchemaRegistry, AgentApiSurface, and
5
+ * UISurfaceSchema that carry realistic data for integration testing.
6
+ */
7
+ // ---------------------------------------------------------------------------
8
+ // Domain + Entities + Intents
9
+ // ---------------------------------------------------------------------------
10
+ const mockDomain = {
11
+ id: 'video',
12
+ name: 'Video Production',
13
+ description: 'Video production domain',
14
+ entities: [],
15
+ intents: [],
16
+ relationships: [],
17
+ entityIds: ['clip', 'project'],
18
+ intentIds: ['create_clip', 'list_clips', 'delete_clip'],
19
+ };
20
+ const mockClipEntity = {
21
+ id: 'clip',
22
+ domain: 'video',
23
+ description: 'A video clip',
24
+ properties: {
25
+ title: { type: 'string', description: 'Clip title', required: true, searchable: true },
26
+ duration: { type: 'number', description: 'Duration in seconds' },
27
+ },
28
+ display: { title: 'title' },
29
+ indexable: true,
30
+ domainRef: mockDomain,
31
+ incomingRelations: [],
32
+ outgoingRelations: [],
33
+ applicableIntents: ['create_clip', 'list_clips', 'delete_clip'],
34
+ };
35
+ const mockProjectEntity = {
36
+ id: 'project',
37
+ domain: 'video',
38
+ description: 'A video project',
39
+ properties: {
40
+ name: { type: 'string', description: 'Project name', required: true, searchable: true },
41
+ },
42
+ display: { title: 'name' },
43
+ indexable: true,
44
+ domainRef: mockDomain,
45
+ incomingRelations: [],
46
+ outgoingRelations: [],
47
+ applicableIntents: [],
48
+ };
49
+ function createMockIntent(id, description, params, outcome = {}) {
50
+ return {
51
+ id,
52
+ domain: 'video',
53
+ description,
54
+ parameters: Object.fromEntries(Object.entries(params).map(([key, val]) => [
55
+ key,
56
+ { type: val.type, description: val.description, required: true },
57
+ ])),
58
+ outcome,
59
+ domainRef: mockDomain,
60
+ resolvedPreconditions: [],
61
+ compositionChain: [],
62
+ toolDefinition: {
63
+ type: 'function',
64
+ function: {
65
+ name: id,
66
+ description,
67
+ parameters: {
68
+ type: 'object',
69
+ properties: Object.fromEntries(Object.entries(params).map(([key, val]) => [key, { type: val.type, description: val.description }])),
70
+ required: Object.keys(params),
71
+ },
72
+ },
73
+ },
74
+ };
75
+ }
76
+ const createClipIntent = createMockIntent('create_clip', 'Create a new video clip', { title: { type: 'string', description: 'The clip title' }, duration: { type: 'number', description: 'Duration in seconds' } }, { produces: 'clip' });
77
+ const listClipsIntent = createMockIntent('list_clips', 'List all video clips', {});
78
+ const deleteClipIntent = createMockIntent('delete_clip', 'Delete a video clip', { clipId: { type: 'string', description: 'The ID of the clip to delete' } }, { deletes: 'clip' });
79
+ // ---------------------------------------------------------------------------
80
+ // SchemaRegistry
81
+ // ---------------------------------------------------------------------------
82
+ const intentsMap = new Map([
83
+ ['create_clip', createClipIntent],
84
+ ['list_clips', listClipsIntent],
85
+ ['delete_clip', deleteClipIntent],
86
+ ]);
87
+ const entitiesMap = new Map([
88
+ ['clip', mockClipEntity],
89
+ ['project', mockProjectEntity],
90
+ ]);
91
+ const domainsMap = new Map([
92
+ ['video', mockDomain],
93
+ ]);
94
+ const mockEntityGraph = {
95
+ nodes: new Map([
96
+ ['clip', { entityId: 'clip', entity: mockClipEntity, depth: 0 }],
97
+ ['project', { entityId: 'project', entity: mockProjectEntity, depth: 0 }],
98
+ ]),
99
+ edges: [],
100
+ getNode: (id) => mockEntityGraph.nodes.get(id),
101
+ getEdgesFrom: () => [],
102
+ getEdgesTo: () => [],
103
+ getShortestPath: () => [],
104
+ };
105
+ export function createMockRegistry() {
106
+ return {
107
+ domains: domainsMap,
108
+ entities: entitiesMap,
109
+ intents: intentsMap,
110
+ entityGraph: mockEntityGraph,
111
+ getDomain: (id) => domainsMap.get(id),
112
+ getEntity: (id) => entitiesMap.get(id),
113
+ getIntent: (id) => intentsMap.get(id),
114
+ getIntentsForEntity: (entityId) => [...intentsMap.values()].filter(i => i.outcome.produces === entityId || i.outcome.deletes === entityId),
115
+ getRelatedEntities: () => [],
116
+ getIntentChain: () => [],
117
+ };
118
+ }
119
+ export function createMockApi(options = {}) {
120
+ const defaultResult = {
121
+ success: true,
122
+ data: { id: 'clip-001', title: 'Test Clip', duration: 30 },
123
+ };
124
+ return {
125
+ queryEntities: async () => [],
126
+ getEntity: async (_type, id) => ({
127
+ id,
128
+ type: _type,
129
+ properties: {},
130
+ }),
131
+ mutateEntity: async (_type, id) => ({
132
+ id,
133
+ type: _type,
134
+ properties: {},
135
+ }),
136
+ executeIntent: async (_intentId, _params) => {
137
+ if (options.executeError) {
138
+ throw options.executeError;
139
+ }
140
+ return options.executeResult ?? defaultResult;
141
+ },
142
+ getVisibleAnnotations: () => [],
143
+ getNavigationState: () => ({ route: '/dashboard' }),
144
+ navigate: async () => { },
145
+ };
146
+ }
147
+ // ---------------------------------------------------------------------------
148
+ // UISurfaceSchema
149
+ // ---------------------------------------------------------------------------
150
+ export function createMockSurface() {
151
+ return {
152
+ pages: [
153
+ {
154
+ id: 'clip_editor',
155
+ route: '/clips/:clipId/edit',
156
+ title: 'Clip Editor',
157
+ description: 'Edit a video clip: trim, add effects, adjust audio',
158
+ entities: ['clip'],
159
+ actions: [
160
+ {
161
+ id: 'save_clip',
162
+ label: 'Save',
163
+ description: 'Save the current clip edits',
164
+ },
165
+ {
166
+ id: 'render_clip',
167
+ label: 'Render',
168
+ description: 'Start rendering the clip for export',
169
+ confirmRequired: true,
170
+ },
171
+ ],
172
+ forms: [
173
+ {
174
+ id: 'clip_metadata',
175
+ title: 'Clip Metadata',
176
+ fields: [
177
+ { id: 'title', label: 'Title', type: 'text', required: true },
178
+ { id: 'description', label: 'Description', type: 'textarea' },
179
+ ],
180
+ submitAction: 'save_clip',
181
+ },
182
+ ],
183
+ players: [
184
+ {
185
+ id: 'preview_player',
186
+ type: 'video',
187
+ commands: ['play', 'pause', 'seek', 'loop'],
188
+ seekable: true,
189
+ },
190
+ ],
191
+ },
192
+ {
193
+ id: 'project_dashboard',
194
+ route: '/projects/:projectId',
195
+ title: 'Project Dashboard',
196
+ description: 'Overview of all clips and assets in a project',
197
+ entities: ['project', 'clip'],
198
+ actions: [
199
+ {
200
+ id: 'new_clip',
201
+ label: 'New Clip',
202
+ description: 'Create a new clip in this project',
203
+ },
204
+ ],
205
+ selectable: {
206
+ entityType: 'clip',
207
+ multi: true,
208
+ bulkActions: ['delete_clip'],
209
+ },
210
+ },
211
+ ],
212
+ modals: [
213
+ {
214
+ id: 'confirm_delete',
215
+ title: 'Confirm Delete',
216
+ description: 'Confirmation dialog before deleting a clip',
217
+ actions: [
218
+ {
219
+ id: 'confirm',
220
+ label: 'Delete',
221
+ description: 'Confirm the deletion',
222
+ destructive: true,
223
+ },
224
+ {
225
+ id: 'cancel',
226
+ label: 'Cancel',
227
+ description: 'Cancel the deletion',
228
+ },
229
+ ],
230
+ },
231
+ ],
232
+ globalActions: [
233
+ {
234
+ id: 'open_search',
235
+ label: 'Search',
236
+ description: 'Open the global search dialog',
237
+ },
238
+ {
239
+ id: 'toggle_theme',
240
+ label: 'Toggle Theme',
241
+ description: 'Switch between light and dark mode',
242
+ },
243
+ ],
244
+ entityRoutes: {
245
+ clip: '/clips/:id/edit',
246
+ project: '/projects/:id',
247
+ },
248
+ };
249
+ }
250
+ //# sourceMappingURL=fixtures.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixtures.js","sourceRoot":"","sources":["../../src/__tests__/fixtures.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAkBH,8EAA8E;AAC9E,8BAA8B;AAC9B,8EAA8E;AAE9E,MAAM,UAAU,GAAmB;IACjC,EAAE,EAAE,OAAO;IACX,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE,yBAAyB;IACtC,QAAQ,EAAE,EAAE;IACZ,OAAO,EAAE,EAAE;IACX,aAAa,EAAE,EAAE;IACjB,SAAS,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC;IAC9B,SAAS,EAAE,CAAC,aAAa,EAAE,YAAY,EAAE,aAAa,CAAC;CACxD,CAAC;AAEF,MAAM,cAAc,GAAmB;IACrC,EAAE,EAAE,MAAM;IACV,MAAM,EAAE,OAAO;IACf,WAAW,EAAE,cAAc;IAC3B,UAAU,EAAE;QACV,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE;QACtF,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAA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oBACP;wBACE,EAAE,EAAE,UAAU;wBACd,KAAK,EAAE,UAAU;wBACjB,WAAW,EAAE,mCAAmC;qBACjD;iBACF;gBACD,UAAU,EAAE;oBACV,UAAU,EAAE,MAAM;oBAClB,KAAK,EAAE,IAAI;oBACX,WAAW,EAAE,CAAC,aAAa,CAAC;iBAC7B;aACF;SACF;QACD,MAAM,EAAE;YACN;gBACE,EAAE,EAAE,gBAAgB;gBACpB,KAAK,EAAE,gBAAgB;gBACvB,WAAW,EAAE,4CAA4C;gBACzD,OAAO,EAAE;oBACP;wBACE,EAAE,EAAE,SAAS;wBACb,KAAK,EAAE,QAAQ;wBACf,WAAW,EAAE,sBAAsB;wBACnC,WAAW,EAAE,IAAI;qBAClB;oBACD;wBACE,EAAE,EAAE,QAAQ;wBACZ,KAAK,EAAE,QAAQ;wBACf,WAAW,EAAE,qBAAqB;qBACnC;iBACF;aACF;SACF;QACD,aAAa,EAAE;YACb;gBACE,EAAE,EAAE,aAAa;gBACjB,KAAK,EAAE,QAAQ;gBACf,WAAW,EAAE,+BAA+B;aAC7C;YACD;gBACE,EAAE,EAAE,cAAc;gBAClB,KAAK,EAAE,cAAc;gBACrB,WAAW,EAAE,oCAAoC;aAClD;SACF;QACD,YAAY,EAAE;YACZ,IAAI,EAAE,iBAAiB;YACvB,OAAO,EAAE,eAAe;SACzB;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,8 @@
1
+ export { createMCPServer } from './server/adapter.js';
2
+ export type { MCPServerConfig } from './server/adapter.js';
3
+ export { createMCPToolServer, registerOUISurfaces } from './server/tool-server.js';
4
+ export type { MCPToolServerConfig, MCPToolServerResult, RegisterOUISurfacesConfig, RegisterOUISurfacesResult, } from './server/tool-server.js';
5
+ export { createMCPApiToolServer } from './server/api-tool-server.js';
6
+ export type { MCPApiToolServerConfig, MCPApiToolServerResult, MCPPrincipal } from './server/api-tool-server.js';
7
+ export { handleMCPRequest } from './server/http.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,YAAY,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACnF,YAAY,EACV,mBAAmB,EACnB,mBAAmB,EACnB,yBAAyB,EACzB,yBAAyB,GAC1B,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,YAAY,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChH,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ export { createMCPServer } from './server/adapter.js';
2
+ export { createMCPToolServer, registerOUISurfaces } from './server/tool-server.js';
3
+ // Generated API tools (ADR-0181 §2), each call as the MCP client's own principal
4
+ export { createMCPApiToolServer } from './server/api-tool-server.js';
5
+ export { handleMCPRequest } from './server/http.js';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGtD,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAQnF,iFAAiF;AACjF,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,50 @@
1
+ import type { SchemaRegistry, AgentApiSurface } from '@ouispec/agent-core';
2
+ export interface MCPServerConfig {
3
+ registry: SchemaRegistry;
4
+ api: AgentApiSurface;
5
+ serverInfo?: {
6
+ name: string;
7
+ version: string;
8
+ };
9
+ }
10
+ interface MCPTool {
11
+ name: string;
12
+ description: string;
13
+ inputSchema: Record<string, unknown>;
14
+ }
15
+ interface MCPResource {
16
+ uri: string;
17
+ name: string;
18
+ description: string;
19
+ mimeType: string;
20
+ }
21
+ interface MCPToolCallResult {
22
+ content: Array<{
23
+ type: 'text';
24
+ text: string;
25
+ }>;
26
+ isError?: boolean;
27
+ }
28
+ /**
29
+ * Creates an MCP-compatible server from an Agent SDK schema registry.
30
+ * Maps: intents → MCP tools, entities → MCP resources.
31
+ */
32
+ export declare function createMCPServer(config: MCPServerConfig): {
33
+ serverInfo: {
34
+ name: string;
35
+ version: string;
36
+ };
37
+ listTools: () => MCPTool[];
38
+ listResources: () => MCPResource[];
39
+ callTool: (name: string, args: Record<string, unknown>) => Promise<MCPToolCallResult>;
40
+ readResource: (uri: string) => Promise<{
41
+ contents: Array<{
42
+ uri: string;
43
+ mimeType: string;
44
+ text: string;
45
+ }>;
46
+ }>;
47
+ handleRequest(method: string, params?: Record<string, unknown>): Promise<unknown>;
48
+ };
49
+ export {};
50
+ //# sourceMappingURL=adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/server/adapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAkC,MAAM,qBAAqB,CAAC;AAG3G,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,cAAc,CAAC;IACzB,GAAG,EAAE,eAAe,CAAC;IACrB,UAAU,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAChD;AAED,UAAU,OAAO;IACf,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC;AAED,UAAU,WAAW;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,UAAU,iBAAiB;IACzB,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/C,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,eAAe;;;;;qBAI/B,OAAO,EAAE;yBAQL,WAAW,EAAE;qBAQT,MAAM,QAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,OAAO,CAAC,iBAAiB,CAAC;wBAiB/D,MAAM,KAAG,OAAO,CAAC;QAAE,QAAQ,EAAE,KAAK,CAAC;YAAE,GAAG,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,CAAC;0BAyBzF,MAAM,WAAW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;EAiB1F"}
@@ -0,0 +1,92 @@
1
+ import { toCallToolResult } from './results.js';
2
+ import { DEFAULT_SERVER_INFO } from './server-info.js';
3
+ /**
4
+ * Creates an MCP-compatible server from an Agent SDK schema registry.
5
+ * Maps: intents → MCP tools, entities → MCP resources.
6
+ */
7
+ export function createMCPServer(config) {
8
+ const { registry, api } = config;
9
+ const serverInfo = config.serverInfo ?? DEFAULT_SERVER_INFO;
10
+ function listTools() {
11
+ const tools = [];
12
+ for (const intent of registry.intents.values()) {
13
+ tools.push(intentToMCPTool(intent));
14
+ }
15
+ return tools;
16
+ }
17
+ function listResources() {
18
+ const resources = [];
19
+ for (const entity of registry.entities.values()) {
20
+ resources.push(entityToMCPResource(entity));
21
+ }
22
+ return resources;
23
+ }
24
+ async function callTool(name, args) {
25
+ const intent = registry.getIntent(name);
26
+ if (!intent) {
27
+ return toCallToolResult({ success: false, error: `Unknown tool: ${name}` }, { bare: true });
28
+ }
29
+ try {
30
+ const result = await api.executeIntent(name, args);
31
+ return toCallToolResult(result.success ? { success: true, data: result.data } : { success: false, error: result.error?.message ?? 'Unknown error' });
32
+ }
33
+ catch (error) {
34
+ const message = error instanceof Error ? error.message : 'Unknown error';
35
+ return toCallToolResult({ success: false, error: `Execution error: ${message}` }, { bare: true });
36
+ }
37
+ }
38
+ async function readResource(uri) {
39
+ const match = uri.match(/^entity:\/\/(\w+)$/);
40
+ if (!match) {
41
+ throw new Error(`Invalid resource URI: ${uri}`);
42
+ }
43
+ const entityType = match[1];
44
+ const entities = await api.queryEntities(entityType, { limit: 50 });
45
+ return {
46
+ contents: [{
47
+ uri,
48
+ mimeType: 'application/json',
49
+ text: JSON.stringify(entities, null, 2),
50
+ }],
51
+ };
52
+ }
53
+ return {
54
+ serverInfo,
55
+ listTools,
56
+ listResources,
57
+ callTool,
58
+ readResource,
59
+ async handleRequest(method, params) {
60
+ switch (method) {
61
+ case 'initialize':
62
+ return { protocolVersion: '2024-11-05', capabilities: { tools: {}, resources: {} }, serverInfo };
63
+ case 'tools/list':
64
+ return { tools: listTools() };
65
+ case 'resources/list':
66
+ return { resources: listResources() };
67
+ case 'tools/call':
68
+ return callTool(params?.name, params?.arguments ?? {});
69
+ case 'resources/read':
70
+ return readResource(params?.uri);
71
+ default:
72
+ throw new Error(`Unknown method: ${method}`);
73
+ }
74
+ },
75
+ };
76
+ }
77
+ function intentToMCPTool(intent) {
78
+ return {
79
+ name: intent.id,
80
+ description: intent.description,
81
+ inputSchema: intent.toolDefinition.function.parameters,
82
+ };
83
+ }
84
+ function entityToMCPResource(entity) {
85
+ return {
86
+ uri: `entity://${entity.id}`,
87
+ name: `${entity.id} collection`,
88
+ description: entity.description ?? `All ${entity.id} entities`,
89
+ mimeType: 'application/json',
90
+ };
91
+ }
92
+ //# s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CP API Tool Server — serves an agent SDK's generated API tools
3
+ * (`loadOpenApiTools`, ADR-0181 §2) over MCP, with the same exposure the worker has.
4
+ *
5
+ * Each MCP client acts as its own principal (ADR-0181 §4): the host resolves the
6
+ * credential the transport authenticated to a caller, and the tools call the API as
7
+ * that caller through their `actAs` seam. The API decides access, so a permission
8
+ * the caller lacks comes back as the route's own refusal. A call is validated
9
+ * against the tool's input schema before it runs, as the worker does.
10
+ */
11
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
12
+ import type { AuthInfo } from '@modelcontextprotocol/sdk/server/auth/types.js';
13
+ import { type RegisteredTool } from '@ouispec/agent-worker/openapi';
14
+ /** The caller an MCP client authenticated as. Other fields reach the tools' `actAs` in its context. */
15
+ export interface MCPPrincipal {
16
+ userId: string;
17
+ accountId: string;
18
+ [key: string]: unknown;
19
+ }
20
+ export interface MCPApiToolServerConfig {
21
+ /** The generated API tools, loaded with an `actAs` that calls the API as the MCP client's principal. */
22
+ tools: RegisteredTool[];
23
+ /**
24
+ * Who the client is, from the credential its transport authenticated (for example
25
+ * the bearer token an HTTP transport verified). Return null to refuse the call.
26
+ * Required; there is no default.
27
+ */
28
+ principal: (auth: AuthInfo | undefined) => MCPPrincipal | null | Promise<MCPPrincipal | null>;
29
+ serverInfo?: {
30
+ name: string;
31
+ version: string;
32
+ };
33
+ }
34
+ export interface MCPApiToolServerResult {
35
+ /** The configured Server, ready for `server.connect(transport)`. */
36
+ server: Server;
37
+ toolCount: number;
38
+ }
39
+ /**
40
+ * Create an MCP server that lists and runs the given tools. It is not yet connected:
41
+ * call `server.connect(transport)`.
42
+ */
43
+ export declare function createMCPApiToolServer(config: MCPApiToolServerConfig): MCPApiToolServerResult;
44
+ //# sourceMappingURL=api-tool-server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-tool-server.d.ts","sourceRoot":"","sources":["../../src/server/api-tool-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAGnE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gDAAgD,CAAC;AAC/E,OAAO,EAEL,KAAK,cAAc,EAGpB,MAAM,+BAA+B,CAAC;AAIvC,uGAAuG;AACvG,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,sBAAsB;IACrC,wGAAwG;IACxG,KAAK,EAAE,cAAc,EAAE,CAAC;IACxB;;;;OAIG;IACH,SAAS,EAAE,CAAC,IAAI,EAAE,QAAQ,GAAG,SAAS,KAAK,YAAY,GAAG,IAAI,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;IAC9F,UAAU,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAChD;AAED,MAAM,WAAW,sBAAsB;IACrC,oEAAoE;IACpE,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB;AAiCD;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,sBAAsB,GAAG,sBAAsB,CAoD7F"}
@@ -0,0 +1,93 @@
1
+ /**
2
+ * MCP API Tool Server — serves an agent SDK's generated API tools
3
+ * (`loadOpenApiTools`, ADR-0181 §2) over MCP, with the same exposure the worker has.
4
+ *
5
+ * Each MCP client acts as its own principal (ADR-0181 §4): the host resolves the
6
+ * credential the transport authenticated to a caller, and the tools call the API as
7
+ * that caller through their `actAs` seam. The API decides access, so a permission
8
+ * the caller lacks comes back as the route's own refusal. A call is validated
9
+ * against the tool's input schema before it runs, as the worker does.
10
+ */
11
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
12
+ import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
13
+ import { createToolInputValidator, } from '@ouispec/agent-worker/openapi';
14
+ import { effectAccess, effectKind } from '@ouispec/bindings';
15
+ import { toCallToolResult } from './results.js';
16
+ const NOT_AUTHENTICATED = 'Not authenticated: this server runs a tool only as the principal its client authenticated as';
17
+ function annotationsOf(tool) {
18
+ const readOnly = effectAccess(tool.effect) === 'read';
19
+ const irreversible = tool.effect !== undefined && effectKind(tool.effect) === 'transaction';
20
+ const title = tool.operation?.title;
21
+ return {
22
+ ...(typeof title === 'string' ? { title } : {}),
23
+ readOnlyHint: readOnly,
24
+ // MCP assumes a write is destructive unless told otherwise.
25
+ destructiveHint: !readOnly && (tool.destructive === true || irreversible),
26
+ };
27
+ }
28
+ function listedTool(tool) {
29
+ // `sideEffects` is the worker's own flag, not JSON Schema.
30
+ const { sideEffects: _sideEffects, ...inputSchema } = tool.inputSchema;
31
+ return {
32
+ name: tool.name,
33
+ description: tool.description,
34
+ inputSchema: inputSchema,
35
+ annotations: annotationsOf(tool),
36
+ };
37
+ }
38
+ /**
39
+ * Create an MCP server that lists and runs the given tools. It is not yet connected:
40
+ * call `server.connect(transport)`.
41
+ */
42
+ export function createMCPApiToolServer(config) {
43
+ if (typeof config.principal !== 'function') {
44
+ throw new Error('createMCPApiToolServer: principal is required: it names who each call runs as, and has no default');
45
+ }
46
+ const info = config.serverInfo ?? { name: 'agent-sdk-api-tools', version: '1.0.0' };
47
+ const served = new Map();
48
+ for (const tool of config.tools) {
49
+ if (served.has(tool.name))
50
+ throw new Error(`createMCPApiToolServer: two tools are named "${tool.name}"`);
51
+ served.set(tool.name, { tool, listed: listedTool(tool), validate: createToolInputValidator(tool.inputSchema) });
52
+ }
53
+ const server = new Server({ name: info.name, version: info.version }, { capabilities: { tools: {} } });
54
+ server.setRequestHandler(ListToolsRequestSchema, () => ({
55
+ tools: [...served.values()].map((entry) => entry.listed),
56
+ }));
57
+ server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {
58
+ const { name, arguments: args } = request.params;
59
+ const entry = served.get(name);
60
+ if (!entry)
61
+ return toCallToolResult({ success: false, error: `Unknown tool: ${name}` }, { bare: true });
62
+ let principal;
63
+ try {
64
+ principal = await config.principal(extra.authInfo);
65
+ }
66
+ catch {
67
+ principal = null;
68
+ }
69
+ if (!principal)
70
+ return toCallToolResult({ success: false, error: NOT_AUTHENTICATED }, { bare: true });
71
+ const validation = entry.validate(args ?? {});
72
+ if (!validation.ok) {
73
+ return toCallToolResult({ success: false, error: `Invalid input for "${name}": ${validation.errors.join('; ')}` });
74
+ }
75
+ const ctx = {
76
+ ...principal,
77
+ userId: principal.userId,
78
+ accountId: principal.accountId,
79
+ turnId: `mcp-${String(extra.requestId)}`,
80
+ conversationId: `mcp-${extra.sessionId ?? 'session'}`,
81
+ abortSignal: extra.signal,
82
+ toolCallId: String(extra.requestId),
83
+ };
84
+ try {
85
+ return toCallToolResult(await entry.tool.execute(validation.value, ctx));
86
+ }
87
+ catch (err) {
88
+ return toCallToolResult({ success: false, error: `Execution error: ${err instanceof Error ? err.message : String(err)}` }, { bare: true });
89
+ }
90
+ });
91
+ return { server, toolCount: served.size };
92
+ }
93
+ //# sourceMappingURL=api-tool-server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-tool-server.js","sourceRoot":"","sources":["../../src/server/api-tool-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAGnG,OAAO,EACL,wBAAwB,GAIzB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAiChD,MAAM,iBAAiB,GAAG,8FAA8F,CAAC;AAEzH,SAAS,aAAa,CAAC,IAAoB;IACzC,MAAM,QAAQ,GAAG,YAAY,CAAC,IAA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AG,CAAC,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAC7I,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * MCP's Streamable HTTP, stateless: each HTTP request gets its own server and
3
+ * transport, and is answered with JSON. This suits a host that keeps no state
4
+ * between requests, such as a Lambda behind an API gateway.
5
+ *
6
+ * The host authenticates the request itself and passes what it verified as
7
+ * `authInfo`; tools reach it as their principal (`createMCPApiToolServer`).
8
+ * There is no session and no server-sent stream: a GET is refused.
9
+ */
10
+ import type { Server } from '@modelcontextprotocol/sdk/server/index.js';
11
+ import type { AuthInfo } from '@modelcontextprotocol/sdk/server/auth/types.js';
12
+ /**
13
+ * Answer one MCP HTTP request. `createServer` builds a fresh server for it, so no
14
+ * state is shared between requests or callers.
15
+ */
16
+ export declare function handleMCPRequest(createServer: () => Server, request: Request, authInfo?: AuthInfo): Promise<Response>;
17
+ //# sourceMappingURL=http.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/server/http.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACxE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gDAAgD,CAAC;AAG/E;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,YAAY,EAAE,MAAM,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAkB3H"}
@@ -0,0 +1,26 @@
1
+ import { WebStandardStreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js';
2
+ /**
3
+ * Answer one MCP HTTP request. `createServer` builds a fresh server for it, so no
4
+ * state is shared between requests or callers.
5
+ */
6
+ export async function handleMCPRequest(createServer, request, authInfo) {
7
+ // No session to resume or end, and no stream a stateless host could hold open:
8
+ // MCP allows 405 for both.
9
+ if (request.method !== 'POST') {
10
+ return new Response(JSON.stringify({ jsonrpc: '2.0', error: { code: -32000, message: 'Method not allowed: this server answers POST only' }, id: null }), {
11
+ status: 405,
12
+ headers: { allow: 'POST', 'content-type': 'application/json' },
13
+ });
14
+ }
15
+ const server = createServer();
16
+ const transport = new WebStandardStreamableHTTPServerTransport({ sessionIdGenerator: undefined, enableJsonResponse: true });
17
+ try {
18
+ await server.connect(transport);
19
+ return await transport.handleRequest(request, authInfo ? { authInfo } : undefined);
20
+ }
21
+ finally {
22
+ await transport.close();
23
+ await server.close();
24
+ }
25
+ }
26
+ //# sourceMappingURL=http.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/server/http.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,wCAAwC,EAAE,MAAM,+DAA+D,CAAC;AAEzH;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,YAA0B,EAAE,OAAgB,EAAE,QAAmB;IACtG,+EAA+E;IAC/E,2BAA2B;IAC3B,IAAI,OAAO,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;QAC9B,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,mDAAmD,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;YACvJ,MAAM,EAAE,GAAG;YACX,OAAO,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,kBAAkB,EAAE;SAC/D,CAAC,CAAC;IACL,CAAC;IACD,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;IAC9B,MAAM,SAAS,GAAG,IAAI,wCAAwC,CAAC,EAAE,kBAAkB,EAAE,SAAS,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5H,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAChC,OAAO,MAAM,SAAS,CAAC,aAAa,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IACrF,CAAC;YAAS,CAAC;QACT,MAAM,SAAS,CAAC,KAAK,EAAE,CAAC;QACxB,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;AACH,CAAC"}
@@ -0,0 +1,24 @@
1
+ /** A tool's outcome, as every tool server reports it. */
2
+ export interface ToolOutcome {
3
+ success: boolean;
4
+ data?: unknown;
5
+ error?: string;
6
+ }
7
+ /** An MCP tool result made of text, as every tool server here returns. */
8
+ export type TextToolResult = {
9
+ content: Array<{
10
+ type: 'text';
11
+ text: string;
12
+ }>;
13
+ isError?: boolean;
14
+ };
15
+ /**
16
+ * An MCP tool result from a tool's outcome: its data as JSON on success; on failure
17
+ * `Error: <message>`, followed by any data the failure carries (a refused call's
18
+ * status and body). `bare` reports the message as it is, for refusals the server
19
+ * itself makes.
20
+ */
21
+ export declare function toCallToolResult(outcome: ToolOutcome, options?: {
22
+ bare?: boolean;
23
+ }): TextToolResult;
24
+ //# sourceMappingURL=results.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"results.d.ts","sourceRoot":"","sources":["../../src/server/results.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,0EAA0E;AAC1E,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/C,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,GAAE;IAAE,IAAI,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,cAAc,CAQvG"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * An MCP tool result from a tool's outcome: its data as JSON on success; on failure
3
+ * `Error: <message>`, followed by any data the failure carries (a refused call's
4
+ * status and body). `bare` reports the message as it is, for refusals the server
5
+ * itself makes.
6
+ */
7
+ export function toCallToolResult(outcome, options = {}) {
8
+ if (outcome.success) {
9
+ return { content: [{ type: 'text', text: JSON.stringify(outcome.data ?? null, null, 2) }] };
10
+ }
11
+ const message = outcome.error ?? 'Unknown error';
12
+ const lines = [options.bare ? message : `Error: ${message}`];
13
+ if (outcome.data !== undefined)
14
+ lines.push(JSON.stringify(outcome.data, null, 2));
15
+ return { content: [{ type: 'text', text: lines.join('\n') }], isError: true };
16
+ }
17
+ //# sourceMappingURL=results.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"results.js","sourceRoot":"","sources":["../../src/server/results.ts"],"names":[],"mappings":"AAaA;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAoB,EAAE,UAA8B,EAAE;IACrF,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,IAAI,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;IACvG,CAAC;IACD,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,eAAe,CAAC;IACjD,MAAM,KAAK,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,OAAO,EAAE,CAAC,CAAC;IAC7D,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS;QAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAClF,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AACzF,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * How an MCP server introduces itself when the product names nothing. The
3
+ * product's own name belongs in `serverInfo`; the platform has no default
4
+ * that names any one product (ADR-0227 §2.2).
5
+ */
6
+ export declare const DEFAULT_SERVER_INFO: {
7
+ name: string;
8
+ version: string;
9
+ };
10
+ //# sourceMappingURL=server-info.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-info.d.ts","sourceRoot":"","sources":["../../src/server/server-info.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAgD,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * How an MCP server introduces itself when the product names nothing. The
3
+ * product's own name belongs in `serverInfo`; the platform has no default
4
+ * that names any one product (ADR-0227 §2.2).
5
+ */
6
+ export const DEFAULT_SERVER_INFO = { name: 'agent-sdk-mcp', version: '1.0.0' };
7
+ //# sourceMappingURL=server-info.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-info.js","sourceRoot":"","sources":["../../src/server/server-info.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAsC,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * MCP Tool Server — exposes Agent SDK CompiledIntents as MCP tools via @modelcontextprotocol/sdk.
3
+ *
4
+ * Each CompiledIntent in the SchemaRegistry becomes an MCP tool whose input schema
5
+ * comes from the intent's toolDefinition.function.parameters (JSON Schema).
6
+ * When a client calls the tool, execution is delegated to AgentApiSurface.executeIntent().
7
+ *
8
+ * Uses the low-level Server class (not McpServer) because our intent schemas are
9
+ * JSON Schema objects, not Zod shapes. The low-level API gives us full control over
10
+ * the tools/list and tools/call protocol handlers.
11
+ */
12
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
13
+ import type { SchemaRegistry, AgentApiSurface, UISurfaceSchema } from '@ouispec/agent-core';
14
+ export interface MCPToolServerConfig {
15
+ /** The compiled schema registry containing intents to expose as MCP tools. */
16
+ registry: SchemaRegistry;
17
+ /** The API surface used to execute intents when tools are called. */
18
+ api: AgentApiSurface;
19
+ /** Server identification metadata. */
20
+ serverInfo?: {
21
+ name: string;
22
+ version: string;
23
+ };
24
+ }
25
+ export interface MCPToolServerResult {
26
+ /** The configured Server instance, ready for transport connection. */
27
+ server: Server;
28
+ /** Count of tools registered from the intent registry. */
29
+ toolCount: number;
30
+ }
31
+ /**
32
+ * Creates an MCP server with every CompiledIntent from the registry exposed as a tool.
33
+ *
34
+ * The returned server is not yet connected to any transport — call
35
+ * `server.connect(transport)` to start serving.
36
+ */
37
+ export declare function createMCPToolServer(config: MCPToolServerConfig): MCPToolServerResult;
38
+ export interface RegisterOUISurfacesConfig {
39
+ /** An already-instantiated Server (e.g. from createMCPToolServer). */
40
+ server: Server;
41
+ /** The UI surface schema describing the application's pages, modals, and actions. */
42
+ surface: UISurfaceSchema;
43
+ }
44
+ export interface RegisterOUISurfacesResult {
45
+ /** Total number of MCP resources registered. */
46
+ resourceCount: number;
47
+ }
48
+ /**
49
+ * Registers ListResources and ReadResource handlers on the given Server that
50
+ * expose every declarative element of a UISurfaceSchema as an MCP resource.
51
+ *
52
+ * Resource URI scheme:
53
+ * surface://pages/{pageId} — a single page declaration
54
+ * surface://modals/{modalId} — a single modal declaration
55
+ * surface://global-actions — the global actions list
56
+ * surface://manifest — the full surface manifest
57
+ *
58
+ * Call this after `createMCPToolServer` but before `server.connect(transport)`.
59
+ */
60
+ export declare function registerOUISurfaces(config: RegisterOUISurfacesConfig): RegisterOUISurfacesResult;
61
+ //# sourceMappingURL=tool-server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-server.d.ts","sourceRoot":"","sources":["../../src/server/tool-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAcnE,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EAEf,eAAe,EAGhB,MAAM,qBAAqB,CAAC;AAM7B,MAAM,WAAW,mBAAmB;IAClC,8EAA8E;IAC9E,QAAQ,EAAE,cAAc,CAAC;IACzB,qEAAqE;IACrE,GAAG,EAAE,eAAe,CAAC;IACrB,sCAAsC;IACtC,UAAU,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAChD;AAED,MAAM,WAAW,mBAAmB;IAClC,sEAAsE;IACtE,MAAM,EAAE,MAAM,CAAC;IACf,0DAA0D;IAC1D,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,mBAAmB,GAAG,mBAAmB,CAuBpF;AAMD,MAAM,WAAW,yBAAyB;IACxC,sEAAsE;IACtE,MAAM,EAAE,MAAM,CAAC;IACf,qFAAqF;IACrF,OAAO,EAAE,eAAe,CAAC;CAC1B;AAED,MAAM,WAAW,yBAAyB;IACxC,gDAAgD;IAChD,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,yBAAyB,GAAG,yBAAyB,CA6BhG"}
@@ -0,0 +1,170 @@
1
+ /**
2
+ * MCP Tool Server — exposes Agent SDK CompiledIntents as MCP tools via @modelcontextprotocol/sdk.
3
+ *
4
+ * Each CompiledIntent in the SchemaRegistry becomes an MCP tool whose input schema
5
+ * comes from the intent's toolDefinition.function.parameters (JSON Schema).
6
+ * When a client calls the tool, execution is delegated to AgentApiSurface.executeIntent().
7
+ *
8
+ * Uses the low-level Server class (not McpServer) because our intent schemas are
9
+ * JSON Schema objects, not Zod shapes. The low-level API gives us full control over
10
+ * the tools/list and tools/call protocol handlers.
11
+ */
12
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
13
+ import { ListToolsRequestSchema, CallToolRequestSchema, ListResourcesRequestSchema, ReadResourceRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
14
+ import { toCallToolResult } from './results.js';
15
+ import { DEFAULT_SERVER_INFO } from './server-info.js';
16
+ /**
17
+ * Creates an MCP server with every CompiledIntent from the registry exposed as a tool.
18
+ *
19
+ * The returned server is not yet connected to any transport — call
20
+ * `server.connect(transport)` to start serving.
21
+ */
22
+ export function createMCPToolServer(config) {
23
+ const { registry, api } = config;
24
+ const info = config.serverInfo ?? DEFAULT_SERVER_INFO;
25
+ const toolIndex = buildToolIndex(registry);
26
+ const server = new Server({ name: info.name, version: info.version }, { capabilities: { tools: {}, resources: {} } });
27
+ // tools/list — return the full tool catalogue built from intents
28
+ server.setRequestHandler(ListToolsRequestSchema, () => ({
29
+ tools: [...toolIndex.values()].map(entry => entry.tool),
30
+ }));
31
+ // tools/call — look up the intent and execute via the API surface
32
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
33
+ const { name, arguments: args } = request.params;
34
+ return executeIntentForMCP(api, name, args ?? {}, toolIndex);
35
+ });
36
+ return { server, toolCount: toolIndex.size };
37
+ }
38
+ /**
39
+ * Registers ListResources and ReadResource handlers on the given Server that
40
+ * expose every declarative element of a UISurfaceSchema as an MCP resource.
41
+ *
42
+ * Resource URI scheme:
43
+ * surface://pages/{pageId} — a single page declaration
44
+ * surface://modals/{modalId} — a single modal declaration
45
+ * surface://global-actions — the global actions list
46
+ * surface://manifest — the full surface manifest
47
+ *
48
+ * Call this after `createMCPToolServer` but before `server.connect(transport)`.
49
+ */
50
+ export function registerOUISurfaces(config) {
51
+ const { server, surface } = config;
52
+ const resourceIndex = buildResourceIndex(surface);
53
+ server.setRequestHandler(ListResourcesRequestSchema, () => ({
54
+ resources: [...resourceIndex.values()].map(entry => ({
55
+ uri: entry.uri,
56
+ name: entry.name,
57
+ description: entry.description,
58
+ mimeType: 'application/json',
59
+ })),
60
+ }));
61
+ server.setRequestHandler(ReadResourceRequestSchema, (request) => {
62
+ const { uri } = request.params;
63
+ const entry = resourceIndex.get(uri);
64
+ if (!entry) {
65
+ throw new Error(`Unknown resource URI: ${uri}`);
66
+ }
67
+ return {
68
+ contents: [{
69
+ uri,
70
+ mimeType: 'application/json',
71
+ text: JSON.stringify(entry.data, null, 2),
72
+ }],
73
+ };
74
+ });
75
+ return { resourceCount: resourceIndex.size };
76
+ }
77
+ function buildToolIndex(registry) {
78
+ const index = new Map();
79
+ for (const intent of registry.intents.values()) {
80
+ index.set(intent.id, {
81
+ intent,
82
+ tool: intentToMCPTool(intent),
83
+ });
84
+ }
85
+ return index;
86
+ }
87
+ function intentToMCPTool(intent) {
88
+ return {
89
+ name: intent.id,
90
+ description: intent.description,
91
+ inputSchema: intent.toolDefinition.function.parameters,
92
+ annotations: buildToolAnnotations(intent),
93
+ };
94
+ }
95
+ /**
96
+ * Derives MCP ToolAnnotations from intent metadata.
97
+ * Marks destructive intents (those that delete entities) as such.
98
+ */
99
+ function buildToolAnnotations(intent) {
100
+ const isDestructive = intent.outcome.deletes !== undefined;
101
+ const isReadOnly = intent.outcome.produces === undefined &&
102
+ intent.outcome.mutates === undefined &&
103
+ intent.outcome.deletes === undefined;
104
+ return {
105
+ title: intent.id,
106
+ ...(isDestructive ? { destructiveHint: true } : {}),
107
+ ...(isReadOnly ? { readOnlyHint: true } : {}),
108
+ };
109
+ }
110
+ // ---------------------------------------------------------------------------
111
+ // Internal: Intent Execution
112
+ // ---------------------------------------------------------------------------
113
+ async function executeIntentForMCP(api, intentId, args, toolIndex) {
114
+ if (!toolIndex.has(intentId)) {
115
+ return toCallToolResult({ success: false, error: `Unknown tool: ${intentId}` }, { bare: true });
116
+ }
117
+ try {
118
+ const result = await api.executeIntent(intentId, args);
119
+ return toCallToolResult(result.success ? { success: true, data: result.data } : { success: false, error: result.error?.message ?? 'Unknown error' });
120
+ }
121
+ catch (error) {
122
+ const message = error instanceof Error ? error.message : 'Unknown execution error';
123
+ return toCallToolResult({ success: false, error: `Execution error: ${message}` }, { bare: true });
124
+ }
125
+ }
126
+ function buildResourceIndex(surface) {
127
+ const index = new Map();
128
+ for (const page of surface.pages) {
129
+ const uri = pageURI(page);
130
+ index.set(uri, {
131
+ uri,
132
+ name: `page:${page.id}`,
133
+ description: page.description,
134
+ data: page,
135
+ });
136
+ }
137
+ for (const modal of surface.modals) {
138
+ const uri = modalURI(modal);
139
+ index.set(uri, {
140
+ uri,
141
+ name: `modal:${modal.id}`,
142
+ description: modal.description,
143
+ data: modal,
144
+ });
145
+ }
146
+ if (surface.globalActions.length > 0) {
147
+ const uri = 'surface://global-actions';
148
+ index.set(uri, {
149
+ uri,
150
+ name: 'global-actions',
151
+ description: 'Global actions available regardless of current page',
152
+ data: surface.globalActions,
153
+ });
154
+ }
155
+ const manifestURI = 'surface://manifest';
156
+ index.set(manifestURI, {
157
+ uri: manifestURI,
158
+ name: 'surface-manifest',
159
+ description: 'Complete OUI surface manifest: pages, modals, global actions, and entity routes',
160
+ data: surface,
161
+ });
162
+ return index;
163
+ }
164
+ function pageURI(page) {
165
+ return `surface://pages/${page.id}`;
166
+ }
167
+ function modalURI(modal) {
168
+ return `surface://modals/${modal.id}`;
169
+ }
170
+ //# sourceMappingURL=tool-server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-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ec/agent-mcp",
3
+ "version": "0.1.0",
4
+ "description": "MCP server adapter — serves generated OpenAPI tools, each call as the client's own principal, and Agent SDK intents as MCP tools",
5
+ "homepage": "https://github.com/wesreid/oui/tree/main/packages/agent-mcp#readme",
6
+ "bugs": {
7
+ "url": "https://github.com/wesreid/oui/issues"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/wesreid/oui.git",
12
+ "directory": "packages/agent-mcp"
13
+ },
14
+ "license": "MIT",
15
+ "type": "module",
16
+ "main": "./dist/index.js",
17
+ "types": "./dist/index.d.ts",
18
+ "exports": {
19
+ ".": {
20
+ "types": "./dist/index.d.ts",
21
+ "import": "./dist/index.js"
22
+ }
23
+ },
24
+ "files": [
25
+ "dist",
26
+ "README.md"
27
+ ],
28
+ "dependencies": {
29
+ "@modelcontextprotocol/sdk": "^1.12.0",
30
+ "@ouispec/agent-core": "^0.1.0",
31
+ "@ouispec/agent-worker": "^0.1.0",
32
+ "@ouispec/bindings": "^0.1.0"
33
+ },
34
+ "devDependencies": {
35
+ "@types/node": "^22.0.0",
36
+ "typescript": "^5.8.0",
37
+ "vitest": "^3.2.0"
38
+ },
39
+ "publishConfig": {
40
+ "access": "public",
41
+ "provenance": true
42
+ },
43
+ "scripts": {
44
+ "build": "tsc -p tsconfig.build.json",
45
+ "typecheck": "tsc --noEmit",
46
+ "test": "vitest run --passWithNoTests",
47
+ "clean": "rm -rf dist"
48
+ }
49
+ }