@webda/mcp 0.0.0-stage → 4.0.0-beta.3

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/lib/invoke.js ADDED
@@ -0,0 +1,177 @@
1
+ import { callOperation, SimpleOperationContext, WebdaError } from "@webda/core";
2
+ import { useLog } from "@webda/workout";
3
+ /**
4
+ * Raised when an MCP client cancels a running operation
5
+ */
6
+ export class CancelledError extends Error {
7
+ /**
8
+ * Build the cancellation error
9
+ */
10
+ constructor() {
11
+ super("Cancelled");
12
+ this.name = "CancelledError";
13
+ }
14
+ }
15
+ /**
16
+ * Operation context used for MCP calls: collects AsyncGenerator chunks
17
+ * instead of concatenating them into the output, and stops on cancellation.
18
+ */
19
+ export class McpOperationContext extends SimpleOperationContext {
20
+ /**
21
+ * Chunks yielded by a streaming operation
22
+ */
23
+ chunks = [];
24
+ /**
25
+ * Abort signal of the MCP request
26
+ */
27
+ signal;
28
+ /**
29
+ * Called for every streamed chunk with its 1-based index
30
+ */
31
+ onChunk;
32
+ /**
33
+ * @param output - chunk or result
34
+ * @param encoding - unused for chunks
35
+ * @param cb - unused for chunks
36
+ * @returns true
37
+ */
38
+ write(output, encoding, cb) {
39
+ if (!this.getExtension("operationStreaming")) {
40
+ return super.write(output, encoding, cb);
41
+ }
42
+ if (this.signal?.aborted) {
43
+ // Throwing ends callOperation's for-await loop, which calls the generator's return()
44
+ throw new CancelledError();
45
+ }
46
+ this.chunks.push(output);
47
+ try {
48
+ this.onChunk?.(output, this.chunks.length);
49
+ }
50
+ catch (err) {
51
+ useLog("WARN", "MCP progress notification failed", err);
52
+ }
53
+ return true;
54
+ }
55
+ }
56
+ /**
57
+ * Build a context holding a session, for permission checks
58
+ * @param session - caller session
59
+ * @returns a context with that session
60
+ */
61
+ export function sessionContext(session) {
62
+ const ctx = new SimpleOperationContext();
63
+ ctx.setSession(session);
64
+ return ctx;
65
+ }
66
+ /**
67
+ * Run an operation as the caller through core `callOperation`
68
+ * (permission, validation, events, audit and dispatch all apply)
69
+ * @param operationId - operation id
70
+ * @param options - session, input, cancellation and streaming hooks
71
+ * @returns the parsed result, or the chunks when the operation streamed
72
+ */
73
+ export async function runOperation(operationId, options) {
74
+ if (options.signal?.aborted) {
75
+ throw new CancelledError();
76
+ }
77
+ const ctx = new McpOperationContext();
78
+ await ctx.init();
79
+ ctx.setSession(options.session);
80
+ ctx.setInput(Buffer.from(JSON.stringify(options.input ?? {})));
81
+ ctx.signal = options.signal;
82
+ ctx.onChunk = options.onChunk;
83
+ await callOperation(ctx, operationId);
84
+ if (ctx.getExtension("operationStreaming")) {
85
+ return { value: ctx.chunks, streamed: true };
86
+ }
87
+ const output = ctx.getOutput();
88
+ if (output === undefined || output === null || output === "") {
89
+ return { value: undefined, streamed: false };
90
+ }
91
+ try {
92
+ return { value: JSON.parse(output), streamed: false };
93
+ }
94
+ catch {
95
+ return { value: output, streamed: false };
96
+ }
97
+ }
98
+ /**
99
+ * Truncate a string to at most `maxBytes` UTF-8 bytes without cutting a character
100
+ * @param text - the text
101
+ * @param maxBytes - maximum number of bytes kept
102
+ * @returns the (possibly) truncated text, whether it was truncated and the original byte length
103
+ */
104
+ export function truncateUtf8(text, maxBytes) {
105
+ const bytes = Buffer.from(text);
106
+ if (bytes.length <= maxBytes) {
107
+ return { text, truncated: false, bytes: bytes.length };
108
+ }
109
+ // Back off to a valid UTF-8 boundary so a cut multibyte character is dropped, not replaced
110
+ let end = Math.max(0, maxBytes);
111
+ while (end > 0 && (bytes[end] & 0xc0) === 0x80) {
112
+ end--;
113
+ }
114
+ return { text: bytes.subarray(0, end).toString(), truncated: true, bytes: bytes.length };
115
+ }
116
+ /**
117
+ * Convert an operation result into an MCP tool result.
118
+ *
119
+ * Tools declare no outputSchema (serialized models rarely match their schema exactly),
120
+ * so structuredContent is informative only: the object itself, `{ value }` for scalars
121
+ * and arrays, `{ items }` for streamed chunks, and nothing for void.
122
+ * @param _entry - the tool
123
+ * @param value - operation result
124
+ * @param streamed - whether value is the list of streamed chunks
125
+ * @param maxOutputBytes - truncation threshold for the text content
126
+ * @returns the tool result
127
+ */
128
+ export function toToolResult(_entry, value, streamed, maxOutputBytes) {
129
+ let structured;
130
+ if (streamed) {
131
+ structured = { items: value };
132
+ }
133
+ else if (value !== null && typeof value === "object" && !Array.isArray(value)) {
134
+ structured = value;
135
+ }
136
+ else if (value !== undefined) {
137
+ structured = { value };
138
+ }
139
+ if (structured === undefined) {
140
+ return { content: [{ type: "text", text: "" }] };
141
+ }
142
+ const json = JSON.stringify(structured);
143
+ const cut = truncateUtf8(json, maxOutputBytes);
144
+ if (cut.truncated) {
145
+ return {
146
+ isError: true,
147
+ content: [
148
+ {
149
+ type: "text",
150
+ text: `${cut.text}\n[output truncated: ${cut.bytes} bytes exceeds maxOutputBytes ${maxOutputBytes}]`
151
+ }
152
+ ]
153
+ };
154
+ }
155
+ return { content: [{ type: "text", text: json }], structuredContent: structured };
156
+ }
157
+ /**
158
+ * Convert an error into an MCP tool error result.
159
+ * Client errors (4xx) are returned so the agent can correct its input;
160
+ * anything else is logged and masked.
161
+ * @param err - the error
162
+ * @returns the tool error result
163
+ */
164
+ export function errorToToolResult(err) {
165
+ if (err instanceof CancelledError) {
166
+ return { isError: true, content: [{ type: "text", text: "Cancelled" }] };
167
+ }
168
+ if (err instanceof WebdaError.CodeError) {
169
+ const code = err.getResponseCode();
170
+ if (code >= 400 && code < 500) {
171
+ return { isError: true, content: [{ type: "text", text: `${err.getCode()}: ${err.message}` }] };
172
+ }
173
+ }
174
+ useLog("ERROR", "MCP tool call failed", err);
175
+ return { isError: true, content: [{ type: "text", text: "Internal error" }] };
176
+ }
177
+ //# sourceMappingURL=invoke.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invoke.js","sourceRoot":"","sources":["../src/invoke.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAW,sBAAsB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzF,OAAO,EAAE,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GAAG,CAAC,OAAO,EAAE,EAAE,CAAC,EAAE,CAAC;QAClG,CAAC;IACH,CAAC;IACD,MAAM,CAAC,OAAO,EAAE,sBAAsB,EAAE,GAAG,CAAC,CAAC;IAC7C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC,EAAE,CAAC;AAChF,CAAC"}
@@ -0,0 +1,194 @@
1
+ import { OperationsTransport, OperationsTransportParameters, OperationDefinition, Session, WebContext } from "@webda/core";
2
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
3
+ import type { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
4
+ import type { AuthInfo } from "@modelcontextprotocol/sdk/server/auth/types.js";
5
+ import { Writable } from "node:stream";
6
+ import { McpAuthenticator } from "./auth.js";
7
+ import { ResourceRegistry } from "./resources.js";
8
+ import { McpSessionEntry, McpSessionManager } from "./sessions.js";
9
+ import { ToolRegistry } from "./tools.js";
10
+ /**
11
+ * Parameters for the MCP transport
12
+ */
13
+ export declare class McpServiceParameters extends OperationsTransportParameters {
14
+ /**
15
+ * HTTP endpoint; false disables HTTP (stdio only)
16
+ * @default "/mcp"
17
+ */
18
+ url?: string | false;
19
+ /**
20
+ * Models exposed as resources (short ids or "*"); false disables resources
21
+ * @default {"models":["*"]}
22
+ */
23
+ resources?: false | {
24
+ models?: string[];
25
+ };
26
+ /**
27
+ * Seconds of inactivity before an MCP session is evicted
28
+ * @default 1800
29
+ */
30
+ sessionTimeout?: number;
31
+ /**
32
+ * Extra Origin values accepted besides the request's own origin
33
+ * @default []
34
+ */
35
+ allowedOrigins?: string[];
36
+ /**
37
+ * Hostnames (any port) accepted in the request Host, against DNS rebinding;
38
+ * "*" disables the check
39
+ * @default ["localhost","127.0.0.1","::1"]
40
+ */
41
+ allowedHosts?: string[];
42
+ /**
43
+ * Maximum number of concurrent MCP HTTP sessions; at the limit the least
44
+ * recently used session is closed to make room for a new one
45
+ * @default 1000
46
+ */
47
+ maxSessions?: number;
48
+ /**
49
+ * Larger tool/resource outputs are truncated
50
+ * @default 1048576
51
+ */
52
+ maxOutputBytes?: number;
53
+ /**
54
+ * Server name announced to clients (defaults to the application package name)
55
+ */
56
+ serverName?: string;
57
+ /**
58
+ * Server version announced to clients (defaults to the application package version)
59
+ */
60
+ serverVersion?: string;
61
+ /**
62
+ * stdio defaults
63
+ */
64
+ stdio?: {
65
+ /**
66
+ * Default user for `webda mcp`
67
+ */
68
+ user?: string;
69
+ };
70
+ /**
71
+ * Name of a service implementing McpAuthenticator; default uses the Webda session
72
+ */
73
+ authenticator?: string;
74
+ /**
75
+ * @param params - raw parameters
76
+ * @returns this with defaults applied
77
+ */
78
+ load(params?: any): this;
79
+ }
80
+ /**
81
+ * Reserve stdout for the MCP protocol: every other write to `stdout` (log lines,
82
+ * whatever `--log-stream` says, unpatched console calls, third-party output) is
83
+ * sent to `stderr`, and the returned stream writes to the real stdout.
84
+ * @param stdout - stream carrying protocol frames
85
+ * @param stderr - stream receiving everything else
86
+ * @returns the protocol stream and a function restoring stdout
87
+ */
88
+ export declare function reserveStdout(stdout?: NodeJS.WritableStream, stderr?: NodeJS.WritableStream): {
89
+ protocol: Writable;
90
+ restore: () => void;
91
+ };
92
+ /**
93
+ * MCP transport: exposes operations as Model Context Protocol tools and
94
+ * models as resources, over Streamable HTTP (a Webda route) and stdio (`webda mcp`).
95
+ *
96
+ * @WebdaModda
97
+ */
98
+ export declare class McpService<T extends McpServiceParameters = McpServiceParameters> extends OperationsTransport<T> {
99
+ protected tools: ToolRegistry;
100
+ protected resourceRegistry?: ResourceRegistry;
101
+ protected sessions: McpSessionManager;
102
+ protected fingerprint: string;
103
+ protected authenticator: McpAuthenticator;
104
+ protected evictTimer?: NodeJS.Timeout;
105
+ protected stdioServers: Server[];
106
+ /**
107
+ * Build typed parameters with defaults. Application replaces this with the
108
+ * webda.module.json `Configuration` class (the same McpServiceParameters);
109
+ * it is defined here so the service also works when registered by hand.
110
+ * @param params - raw parameters
111
+ * @returns typed parameters
112
+ */
113
+ static createConfiguration(params?: any): McpServiceParameters;
114
+ /**
115
+ * Tools are built in bulk by refreshRegistries
116
+ * @param _operationId - unused
117
+ * @param _definition - unused
118
+ */
119
+ exposeOperation(_operationId: string, _definition: OperationDefinition): void;
120
+ /**
121
+ * @returns this once the authenticator is resolved
122
+ */
123
+ resolve(): this;
124
+ /**
125
+ * Build registries, mount the HTTP route and start session eviction
126
+ * @returns this
127
+ */
128
+ init(): Promise<this>;
129
+ /**
130
+ * Rebuild tool and resource registries when operations changed
131
+ * @returns true when they were rebuilt
132
+ */
133
+ refreshRegistries(): boolean;
134
+ /**
135
+ * Detect runtime operation registration and notify open sessions
136
+ */
137
+ checkForChanges(): void;
138
+ /**
139
+ * @param getSession - caller session resolution
140
+ * @returns a new SDK server over this service's registries
141
+ */
142
+ createServer(getSession: (extra: {
143
+ authInfo?: AuthInfo;
144
+ }) => Session): Server;
145
+ /**
146
+ * Origin (protocol + host[:port]) of a request, from the `x-forwarded-host` header
147
+ * when present (HttpServer rejects forwarded headers from untrusted sources) or
148
+ * the `host` header. Parsed here rather than via HttpContext.getAbsoluteUrl,
149
+ * which cannot represent IPv6 literals like `[::1]:18080`.
150
+ * @param ctx - the request context
151
+ * @returns the parsed origin, or undefined when the host is missing or invalid
152
+ */
153
+ protected requestOrigin(ctx: WebContext): URL | undefined;
154
+ /**
155
+ * DNS-rebinding guard: the request hostname must be in allowedHosts
156
+ * @param ctx - the request context
157
+ * @returns true when the host is accepted
158
+ */
159
+ protected isHostAllowed(ctx: WebContext): boolean;
160
+ /**
161
+ * Handle GET/POST/DELETE on the MCP endpoint
162
+ * @param ctx - the request context
163
+ */
164
+ handleHttp(ctx: WebContext): Promise<void>;
165
+ /**
166
+ * Create an SDK server + transport pair for a new MCP session
167
+ * @param ctx - the initializing request
168
+ * @param userId - caller user id
169
+ * @param requestOrigin - origin of the request (see requestOrigin)
170
+ * @returns the (not yet registered) session entry; it registers on initialize
171
+ */
172
+ protected createHttpSession(ctx: WebContext, userId: string | undefined, requestOrigin?: URL | undefined): Promise<McpSessionEntry>;
173
+ /**
174
+ * Serve the MCP tools over stdio until stdin closes
175
+ *
176
+ * Anyone able to start this command acts with `user`'s permissions
177
+ * (or anonymous permissions when no user is given).
178
+ *
179
+ * @param user - user id whose permissions apply
180
+ */
181
+ mcp(user?: string): Promise<void>;
182
+ /**
183
+ * Connect a new MCP server to a transport, acting as `user`
184
+ * @param transport - stdio (or any) transport
185
+ * @param user - user id whose permissions apply; anonymous when empty
186
+ * @returns the connected server
187
+ */
188
+ serveStdio(transport: Transport, user?: string): Promise<Server>;
189
+ /**
190
+ * Stop eviction and close every MCP session
191
+ */
192
+ stop(): Promise<void>;
193
+ }
194
+ //# sourceMappingURL=mcpservice.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcpservice.service.d.ts","sourceRoot":"","sources":["../src/mcpservice.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,mBAAmB,EACnB,6BAA6B,EAC7B,mBAAmB,EACnB,OAAO,EAGP,UAAU,EACX,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAInE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+CAA+C,CAAC;AAC/E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gDAAgD,CAAC;AAI/E,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAwB,MAAM,WAAW,CAAC;AAEnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAyB,YAAY,EAAE,MAAM,YAAY,CAAC;AAEjE;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,6BAA6B;IACrE;;;OAGG;IACH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