stitchkit 0.3.0 → 0.4.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/README.md +11 -10
- package/dist/browser/client.d.ts.map +1 -1
- package/dist/browser/socket-io.d.ts +17 -0
- package/dist/browser/socket-io.d.ts.map +1 -1
- package/dist/cli.d.ts +23 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +21 -0
- package/dist/contract/define.d.ts +35 -2
- package/dist/contract/define.d.ts.map +1 -1
- package/dist/contract/index.d.ts +1 -1
- package/dist/contract/index.d.ts.map +1 -1
- package/dist/contract/index.js +2 -1
- package/dist/index-0ed3bx43.js +33 -0
- package/dist/index-0ma1eqv4.js +1007 -0
- package/dist/index-1cf8jkhf.js +219 -0
- package/dist/index-37x76zdn.js +4 -0
- package/dist/{index-dpj1jcys.js → index-3qmtdfpa.js} +156 -4
- package/dist/index-48ffdxgk.js +6 -0
- package/dist/{index-4kz3aqpx.js → index-78q1qm7v.js} +4 -1
- package/dist/{index-kckky6zw.js → index-afzt3nmx.js} +1 -1
- package/dist/{index-4b1j82gp.js → index-d4rwrjbc.js} +1 -1
- package/dist/{index-0t460v7k.js → index-vhdvv00d.js} +1 -1
- package/dist/index-x3fcszf8.js +8 -0
- package/dist/index.js +16 -4
- package/dist/internal/http-input.d.ts +13 -0
- package/dist/internal/http-input.d.ts.map +1 -0
- package/dist/internal/secure-fetch.d.ts +27 -0
- package/dist/internal/secure-fetch.d.ts.map +1 -0
- package/dist/internal/within-dir.d.ts.map +1 -1
- package/dist/node.d.ts +10 -1
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +38 -7
- package/dist/observability/audit.d.ts.map +1 -1
- package/dist/observability/event.d.ts +4 -0
- package/dist/observability/event.d.ts.map +1 -1
- package/dist/observability/index.js +3 -0
- package/dist/react.js +2 -0
- package/dist/server/implement.d.ts.map +1 -1
- package/dist/server/index.d.ts +5 -2
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +172 -216
- package/dist/server/middleware/auth.d.ts +17 -0
- package/dist/server/middleware/auth.d.ts.map +1 -1
- package/dist/server/middleware/pkce.d.ts +17 -0
- package/dist/server/middleware/pkce.d.ts.map +1 -0
- package/dist/server/node.d.ts +9 -0
- package/dist/server/node.d.ts.map +1 -1
- package/dist/server/openapi.d.ts +52 -0
- package/dist/server/openapi.d.ts.map +1 -0
- package/dist/server/socket-io.d.ts +60 -15
- package/dist/server/socket-io.d.ts.map +1 -1
- package/dist/server/types.d.ts +5 -1
- package/dist/server/types.d.ts.map +1 -1
- package/dist/server/websocket.d.ts +73 -0
- package/dist/server/websocket.d.ts.map +1 -0
- package/dist/tools/cli-args.d.ts +68 -0
- package/dist/tools/cli-args.d.ts.map +1 -0
- package/dist/tools/cli-format.d.ts +39 -0
- package/dist/tools/cli-format.d.ts.map +1 -0
- package/dist/tools/cli-wait.d.ts +45 -0
- package/dist/tools/cli-wait.d.ts.map +1 -0
- package/dist/tools/cli.d.ts +77 -0
- package/dist/tools/cli.d.ts.map +1 -0
- package/dist/tools/coerce.d.ts.map +1 -1
- package/dist/tools/json-schema.d.ts +29 -4
- package/dist/tools/json-schema.d.ts.map +1 -1
- package/dist/tools/mcp-app.d.ts +59 -0
- package/dist/tools/mcp-app.d.ts.map +1 -0
- package/dist/tools/mcp-handler.d.ts +18 -0
- package/dist/tools/mcp-handler.d.ts.map +1 -1
- package/dist/tools/mcp.d.ts +9 -0
- package/dist/tools/mcp.d.ts.map +1 -1
- package/dist/tools/mount-download.d.ts +30 -0
- package/dist/tools/mount-download.d.ts.map +1 -0
- package/dist/tools/mount-upload.d.ts +19 -0
- package/dist/tools/mount-upload.d.ts.map +1 -0
- package/dist/tools/mount-wait.d.ts +36 -0
- package/dist/tools/mount-wait.d.ts.map +1 -0
- package/dist/tools/mount.d.ts +6 -2
- package/dist/tools/mount.d.ts.map +1 -1
- package/dist/tools/native-result.d.ts +17 -0
- package/dist/tools/native-result.d.ts.map +1 -0
- package/dist/tools/oauth-metadata.d.ts +28 -0
- package/dist/tools/oauth-metadata.d.ts.map +1 -0
- package/dist/tools/oauth-provider.d.ts +85 -0
- package/dist/tools/oauth-provider.d.ts.map +1 -0
- package/dist/tools/remote.d.ts +2 -2
- package/dist/tools/remote.d.ts.map +1 -1
- package/dist/tools/toolkit.d.ts +51 -0
- package/dist/tools/toolkit.d.ts.map +1 -0
- package/dist/tools/view-file.d.ts +12 -0
- package/dist/tools/view-file.d.ts.map +1 -1
- package/dist/tools/wait-core.d.ts +33 -0
- package/dist/tools/wait-core.d.ts.map +1 -0
- package/dist/tools.d.ts +12 -1
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +587 -421
- package/package.json +22 -9
- package/dist/index-q6ja2qwq.js +0 -7
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIME type a host uses to recognise an MCP Apps UI resource — it renders the
|
|
3
|
+
* HTML as an interactive sandboxed iframe rather than displaying the source.
|
|
4
|
+
*/
|
|
5
|
+
export declare const RESOURCE_MIME_TYPE = "text/html;profile=mcp-app";
|
|
6
|
+
/** Placeholder a widget HTML file carries where the ext-apps runtime is inlined. */
|
|
7
|
+
export declare const EXT_APPS_BUNDLE_PLACEHOLDER = "/*__EXT_APPS_BUNDLE__*/";
|
|
8
|
+
/**
|
|
9
|
+
* Content-Security-Policy allowlists a widget declares so the host's iframe can
|
|
10
|
+
* reach external origins (maps to the host's CSP directives). Default is
|
|
11
|
+
* block-all, so any external image / fetch origin must be listed.
|
|
12
|
+
*/
|
|
13
|
+
export interface McpAppCsp {
|
|
14
|
+
/** `connect-src` — fetch / XHR / WebSocket origins. */
|
|
15
|
+
connectDomains?: string[];
|
|
16
|
+
/** `img-src` / `script-src` / `style-src` / `font-src` / `media-src` origins. */
|
|
17
|
+
resourceDomains?: string[];
|
|
18
|
+
/** `frame-src` — nested iframe origins (currently restricted in some hosts). */
|
|
19
|
+
frameDomains?: string[];
|
|
20
|
+
/** `base-uri` origins. */
|
|
21
|
+
baseUriDomains?: string[];
|
|
22
|
+
}
|
|
23
|
+
/** UI metadata attached to a served resource's content (`_meta.ui`). */
|
|
24
|
+
export interface McpAppResourceMeta {
|
|
25
|
+
csp?: McpAppCsp;
|
|
26
|
+
/** Drop the host's outer card border (mobile). */
|
|
27
|
+
prefersBorder?: boolean;
|
|
28
|
+
/** Stable origin for external-API CORS allowlists. */
|
|
29
|
+
domain?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A UI resource served over MCP. `read` returns the widget HTML (already
|
|
33
|
+
* bundle-inlined). The default `mimeType` is the apps MIME type, so a plain
|
|
34
|
+
* widget needs only `uri`, `name` and `read`.
|
|
35
|
+
*/
|
|
36
|
+
export interface McpResourceDef {
|
|
37
|
+
/** `ui://…` uri — must match a tool's `ui.resourceUri`. */
|
|
38
|
+
uri: string;
|
|
39
|
+
/** Human-readable name (shown in `resources/list`). */
|
|
40
|
+
name: string;
|
|
41
|
+
/** MIME type — defaults to `RESOURCE_MIME_TYPE`. */
|
|
42
|
+
mimeType?: string;
|
|
43
|
+
/** Optional UI metadata (CSP, border, domain) applied to the content. */
|
|
44
|
+
ui?: McpAppResourceMeta;
|
|
45
|
+
/** Return the resource body — the widget HTML for an apps resource. */
|
|
46
|
+
read: () => string | Promise<string>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Inline the `@modelcontextprotocol/ext-apps` browser runtime into a widget's
|
|
50
|
+
* HTML, replacing `EXT_APPS_BUNDLE_PLACEHOLDER`. The iframe CSP blocks CDN
|
|
51
|
+
* script fetches, so the runtime must be inlined at startup rather than
|
|
52
|
+
* imported. `ext-apps` is an optional peer — a clear error is thrown if the
|
|
53
|
+
* widget needs the bundle but the peer is not installed.
|
|
54
|
+
*
|
|
55
|
+
* The bundle's trailing `export{…}` is rewritten to `globalThis.ExtApps = {…}`
|
|
56
|
+
* so an inline `<script type="module">` can read `globalThis.ExtApps`.
|
|
57
|
+
*/
|
|
58
|
+
export declare function inlineMcpAppBundle(html: string): string;
|
|
59
|
+
//# sourceMappingURL=mcp-app.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-app.d.ts","sourceRoot":"","sources":["../../src/tools/mcp-app.ts"],"names":[],"mappings":"AAYA;;;GAGG;AACH,eAAO,MAAM,kBAAkB,8BAA8B,CAAC;AAE9D,oFAAoF;AACpF,eAAO,MAAM,2BAA2B,4BAA4B,CAAC;AAErE;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB,uDAAuD;IACvD,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,iFAAiF;IACjF,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,gFAAgF;IAChF,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,0BAA0B;IAC1B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,wEAAwE;AACxE,MAAM,WAAW,kBAAkB;IACjC,GAAG,CAAC,EAAE,SAAS,CAAC;IAChB,kDAAkD;IAClD,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,sDAAsD;IACtD,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,2DAA2D;IAC3D,GAAG,EAAE,MAAM,CAAC;IACZ,uDAAuD;IACvD,IAAI,EAAE,MAAM,CAAC;IACb,oDAAoD;IACpD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yEAAyE;IACzE,EAAE,CAAC,EAAE,kBAAkB,CAAC;IACxB,uEAAuE;IACvE,IAAI,EAAE,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACtC;AAID;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CA4BvD"}
|
|
@@ -1,7 +1,25 @@
|
|
|
1
1
|
import { type McpServerBuildConfig } from './mcp';
|
|
2
|
+
import { type ProtectedResourceConfig } from './oauth-metadata';
|
|
2
3
|
export interface McpHandlerConfig<TAuth> extends McpServerBuildConfig<TAuth> {
|
|
3
4
|
/** Resolve an incoming request to an identity. Return `null` → 401. */
|
|
4
5
|
auth: (req: Request) => TAuth | null | Promise<TAuth | null>;
|
|
6
|
+
/**
|
|
7
|
+
* OAuth 2.0 Protected Resource metadata (RFC 9728). When set, a `401` carries
|
|
8
|
+
* a `WWW-Authenticate: Bearer resource_metadata="…"` header so an MCP client
|
|
9
|
+
* can discover the authorization server. Serve the matching metadata document
|
|
10
|
+
* with `oauthProtectedResourceRoute(protectedResource)`.
|
|
11
|
+
*/
|
|
12
|
+
protectedResource?: ProtectedResourceConfig;
|
|
13
|
+
/**
|
|
14
|
+
* Stateless mode (default `false`). Each request builds a fresh transport +
|
|
15
|
+
* server and is handled in isolation — no `Mcp-Session-Id`, no in-memory
|
|
16
|
+
* session store. A restart / deploy / scale-out therefore never invalidates a
|
|
17
|
+
* client (no `404 Session not found`), which is what most request/response
|
|
18
|
+
* tool servers want. The trade-off is no server-initiated messages
|
|
19
|
+
* (`notifications/progress`, standalone SSE) between requests — fine for
|
|
20
|
+
* synchronous tools. Leave `false` only when you need that server push.
|
|
21
|
+
*/
|
|
22
|
+
stateless?: boolean;
|
|
5
23
|
}
|
|
6
24
|
/**
|
|
7
25
|
* Build a Streamable-HTTP MCP request handler (`Request → Response`).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-handler.d.ts","sourceRoot":"","sources":["../../src/tools/mcp-handler.ts"],"names":[],"mappings":"AASA,OAAO,EAAkB,KAAK,oBAAoB,EAAsB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"mcp-handler.d.ts","sourceRoot":"","sources":["../../src/tools/mcp-handler.ts"],"names":[],"mappings":"AASA,OAAO,EAAkB,KAAK,oBAAoB,EAAsB,MAAM,OAAO,CAAC;AACtF,OAAO,EAAE,KAAK,uBAAuB,EAAyB,MAAM,kBAAkB,CAAC;AAqEvF,MAAM,WAAW,gBAAgB,CAAC,KAAK,CAAE,SAAQ,oBAAoB,CAAC,KAAK,CAAC;IAC1E,uEAAuE;IACvE,IAAI,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,KAAK,GAAG,IAAI,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;IAC7D;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,uBAAuB,CAAC;IAC5C;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAoBD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EACpC,MAAM,EAAE,gBAAgB,CAAC,KAAK,CAAC,GAC9B,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAkHrC"}
|
package/dist/tools/mcp.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
import type { ServiceDef, StitchLogger } from '../server/types';
|
|
3
3
|
import { type ToolCallHooks, type ToolLifecycle } from './execute';
|
|
4
|
+
import { type McpResourceDef } from './mcp-app';
|
|
4
5
|
import { type ToolExtend } from './mount';
|
|
5
6
|
/**
|
|
6
7
|
* What to do when a tool's schema cannot be advertised on the MCP surface — a
|
|
@@ -74,6 +75,8 @@ export interface McpServerBuildConfig<TAuth> {
|
|
|
74
75
|
/** Register native (non-contract) MCP tools — receives the `McpServer`
|
|
75
76
|
* directly. For tools returning multimodal content, e.g. `mountViewFile`. */
|
|
76
77
|
nativeTools?: (server: McpServer) => void;
|
|
78
|
+
/** MCP Apps UI resources (`ui://…`) served for tools that declare `ui`. */
|
|
79
|
+
resources?: McpResourceDef[];
|
|
77
80
|
/** Server instructions — a short (≤2KB) hint to the host on when and how to
|
|
78
81
|
* use these tools. Surfaced to MCP tool-search. */
|
|
79
82
|
instructions?: string;
|
|
@@ -89,4 +92,10 @@ export interface McpServerBuildConfig<TAuth> {
|
|
|
89
92
|
* Transport-agnostic — the shared core behind every MCP transport.
|
|
90
93
|
*/
|
|
91
94
|
export declare function buildMcpServer<TAuth>(config: McpServerBuildConfig<TAuth>, auth: TAuth): McpServer;
|
|
95
|
+
/**
|
|
96
|
+
* Register one MCP Apps UI resource on an `McpServer`. The `read` callback's
|
|
97
|
+
* HTML is served under the resource `uri` with the apps MIME type; any `ui`
|
|
98
|
+
* metadata (CSP, border, domain) is attached to the content's `_meta.ui`.
|
|
99
|
+
*/
|
|
100
|
+
export declare function mountMcpResource(server: McpServer, resource: McpResourceDef): void;
|
|
92
101
|
//# sourceMappingURL=mcp.d.ts.map
|
package/dist/tools/mcp.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../src/tools/mcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../src/tools/mcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAIpE,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,aAAa,EAGnB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,KAAK,cAAc,EAAsB,MAAM,WAAW,CAAC;AACpE,OAAO,EAKL,KAAK,UAAU,EAChB,MAAM,SAAS,CAAC;AAEjB;;;;;;;;GAQG;AACH,MAAM,MAAM,wBAAwB,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AA8JjE,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,qCAAqC;IACrC,KAAK,CAAC,EAAE,aAAa,CAAC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EAAE,wBAAwB,CAAC;IAChD,0EAA0E;IAC1E,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB;kFAC8E;IAC9E,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,SAAS,KAAK,IAAI,CAAC;IAC1C,2EAA2E;IAC3E,SAAS,CAAC,EAAE,cAAc,EAAE,CAAC;IAC7B;wDACoD;IACpD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,+EAA+E;IAC/E,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,+EAA+E;IAC/E,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,gEAAgE;IAChE,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;CACpE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAClC,MAAM,EAAE,oBAAoB,CAAC,KAAK,CAAC,EACnC,IAAI,EAAE,KAAK,GACV,SAAS,CAuBX;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,cAAc,GAAG,IAAI,CAgBlF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import type { z } from 'zod';
|
|
3
|
+
export interface DownloadToolConfig {
|
|
4
|
+
/** Tool name. Default `'download'`. */
|
|
5
|
+
name?: string;
|
|
6
|
+
description: string;
|
|
7
|
+
/** Tool input shape (e.g. `{ url: z.string().optional(), id: z.string().optional() }`). */
|
|
8
|
+
inputSchema: z.ZodRawShape;
|
|
9
|
+
/** Resolve the args to a media URL — `null` when there is nothing to download. */
|
|
10
|
+
resolveUrl: (args: Record<string, unknown>) => Promise<string | null> | string | null;
|
|
11
|
+
/** Directory to save into by default. */
|
|
12
|
+
defaultDir: string;
|
|
13
|
+
/** Read a per-call output directory from the args. */
|
|
14
|
+
dirFromArgs?: (args: Record<string, unknown>) => string | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Allow downloading from private / internal / loopback hosts. Default `false`
|
|
17
|
+
* — the SSRF guard, since the URL comes from model-controlled args. Enable
|
|
18
|
+
* only in a trusted network.
|
|
19
|
+
*/
|
|
20
|
+
allowPrivateHosts?: boolean;
|
|
21
|
+
/** Max bytes to read before aborting (memory cap). Default 100 MB. */
|
|
22
|
+
maxBytes?: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Register a native "download" tool — resolves a URL from the args, fetches it
|
|
26
|
+
* and writes it to disk with a content-type / URL-derived extension. Returns
|
|
27
|
+
* the saved path / size / mime.
|
|
28
|
+
*/
|
|
29
|
+
export declare function mountDownload(server: McpServer, config: DownloadToolConfig): void;
|
|
30
|
+
//# sourceMappingURL=mount-download.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mount-download.d.ts","sourceRoot":"","sources":["../../src/tools/mount-download.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA0C7B,MAAM,WAAW,kBAAkB;IACjC,uCAAuC;IACvC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,2FAA2F;IAC3F,WAAW,EAAE,CAAC,CAAC,WAAW,CAAC;IAC3B,kFAAkF;IAClF,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC;IACtF,yCAAyC;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,sDAAsD;IACtD,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,MAAM,GAAG,SAAS,CAAC;IACpE;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,sEAAsE;IACtE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,kBAAkB,GAAG,IAAI,CAkDjF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `mountUpload` — a generic native MCP tool that uploads a local file. The app
|
|
3
|
+
* injects how to read + send the file (`upload`); the tool wiring lives here.
|
|
4
|
+
* → ADR 0019.
|
|
5
|
+
*/
|
|
6
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
7
|
+
export interface UploadToolConfig {
|
|
8
|
+
/** Tool name. Default `'upload'`. */
|
|
9
|
+
name?: string;
|
|
10
|
+
description: string;
|
|
11
|
+
/** Read a local `path` and upload it, returning whatever the upload yields. */
|
|
12
|
+
upload: (path: string) => Promise<unknown>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Register a native "upload" tool — takes a local `path`, hands it to
|
|
16
|
+
* `config.upload` (which reads + sends it) and returns the result.
|
|
17
|
+
*/
|
|
18
|
+
export declare function mountUpload(server: McpServer, config: UploadToolConfig): void;
|
|
19
|
+
//# sourceMappingURL=mount-upload.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mount-upload.d.ts","sourceRoot":"","sources":["../../src/tools/mount-upload.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAKzE,MAAM,WAAW,gBAAgB;IAC/B,qCAAqC;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,+EAA+E;IAC/E,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAC5C;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAyB7E"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `mountWait` — a generic native MCP tool that blocks until an async job
|
|
3
|
+
* reaches a terminal state. The poll loop is the shared `pollUntil`; the app
|
|
4
|
+
* injects only the domain bits (what to poll, when it's done). Owns the MCP
|
|
5
|
+
* wiring so the consumer never imports `@modelcontextprotocol/sdk`. → ADR 0019.
|
|
6
|
+
*/
|
|
7
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
8
|
+
import type { z } from 'zod';
|
|
9
|
+
export interface WaitToolConfig {
|
|
10
|
+
/** Tool name. Default `'wait'`. */
|
|
11
|
+
name?: string;
|
|
12
|
+
description: string;
|
|
13
|
+
/** Tool input shape (e.g. `{ id: z.string() }`). */
|
|
14
|
+
inputSchema: z.ZodRawShape;
|
|
15
|
+
/** Fetch the current state for the call's args — one poll tick. */
|
|
16
|
+
poll: (args: Record<string, unknown>) => Promise<unknown>;
|
|
17
|
+
/** Terminal when this returns `true`. */
|
|
18
|
+
done: (state: unknown) => boolean;
|
|
19
|
+
/** Read a per-call timeout (seconds) from the args. */
|
|
20
|
+
timeoutFromArgs?: (args: Record<string, unknown>) => number | undefined;
|
|
21
|
+
/** Backoff schedule in seconds; the last entry repeats. */
|
|
22
|
+
backoff?: number[];
|
|
23
|
+
/** Default timeout in seconds. */
|
|
24
|
+
defaultTimeout?: number;
|
|
25
|
+
/** Render the final state. Default: pretty JSON, `isError` on timeout. */
|
|
26
|
+
render?: (state: unknown, timedOut: boolean) => {
|
|
27
|
+
text: string;
|
|
28
|
+
isError: boolean;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Register a native "wait" tool — polls `config.poll(args)` with backoff until
|
|
33
|
+
* `config.done` or the timeout, then returns the final state.
|
|
34
|
+
*/
|
|
35
|
+
export declare function mountWait(server: McpServer, config: WaitToolConfig): void;
|
|
36
|
+
//# sourceMappingURL=mount-wait.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mount-wait.d.ts","sourceRoot":"","sources":["../../src/tools/mount-wait.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAK7B,MAAM,WAAW,cAAc;IAC7B,mCAAmC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,oDAAoD;IACpD,WAAW,EAAE,CAAC,CAAC,WAAW,CAAC;IAC3B,mEAAmE;IACnE,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1D,yCAAyC;IACzC,IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC;IAClC,uDAAuD;IACvD,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,MAAM,GAAG,SAAS,CAAC;IACxE,2DAA2D;IAC3D,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,kCAAkC;IAClC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,0EAA0E;IAC1E,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,KAAK;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;CACpF;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,cAAc,GAAG,IAAI,CA2BzE"}
|
package/dist/tools/mount.d.ts
CHANGED
|
@@ -10,12 +10,16 @@ import { type ToolCallHooks, type ToolLifecycle, type ToolResult } from './execu
|
|
|
10
10
|
/**
|
|
11
11
|
* Extra arguments folded into a mounted tool's schema — the host supplies them,
|
|
12
12
|
* `resolve` turns them into handler context. Shared by `mountMcp` / `mountAgent`.
|
|
13
|
+
*
|
|
14
|
+
* `TContext` is the typed handler context the extension contributes — left as
|
|
15
|
+
* `Record<string, unknown>` for the untyped mounts, pinned by `createToolkit`
|
|
16
|
+
* so `resolve` is checked against the app's context shape.
|
|
13
17
|
*/
|
|
14
|
-
export interface ToolExtend {
|
|
18
|
+
export interface ToolExtend<TContext extends Record<string, unknown> = Record<string, unknown>> {
|
|
15
19
|
/** Extra Zod fields added to every (matching) tool's input schema. */
|
|
16
20
|
schema: Record<string, z.ZodType>;
|
|
17
21
|
/** Turn the extra arguments into context merged into the handler. */
|
|
18
|
-
resolve: (args: Record<string, unknown>) =>
|
|
22
|
+
resolve: (args: Record<string, unknown>) => Partial<TContext> | Promise<Partial<TContext>>;
|
|
19
23
|
/** Limit the extension to specific methods — default: every method. */
|
|
20
24
|
filter?: (service: ServiceDef, method: MethodDef) => boolean;
|
|
21
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../../src/tools/mount.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,UAAU,EAChB,MAAM,WAAW,CAAC;AAKnB
|
|
1
|
+
{"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../../src/tools/mount.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OA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AAE,UAAU,EACnB,SAAS,EAAE,SAAS,EACpB,MAAM,GAAE,kBAAuB,GAC9B,aAAa,EAAE,CA4BjB;AAED,kDAAkD;AAClD,MAAM,WAAW,gBAAgB;IAC/B,iDAAiD;IACjD,MAAM,EAAE,eAAe,CAAC;IACxB,0EAA0E;IAC1E,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,gDAAgD;IAChD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,qCAAqC;IACrC,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,yEAAyE;IACzE,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,gEAAgE;IAChE,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;IACnE,+EAA+E;IAC/E,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,gBAAgB,GACvB,CAAC,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,UAAU,CAAC,CAsBhF;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,OAAO,CAAC,UAAU,EAAE;IAAE,EAAE,EAAE,KAAK,CAAA;CAAE,CAAC,EAC1C,QAAQ,CAAC,EAAE,MAAM,EACjB,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,GACjE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAazB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The MCP text-content result shape shared by the native tools (`mountWait`,
|
|
3
|
+
* `mountDownload`, `mountUpload`) — one place so each tool file does not
|
|
4
|
+
* re-spell the `{ content: [{ type: 'text' }], isError }` envelope.
|
|
5
|
+
*/
|
|
6
|
+
export interface NativeTextResult {
|
|
7
|
+
content: Array<{
|
|
8
|
+
type: 'text';
|
|
9
|
+
text: string;
|
|
10
|
+
}>;
|
|
11
|
+
isError?: boolean;
|
|
12
|
+
/** MCP tool results carry an open `_meta` etc. — the SDK's result type is index-signed. */
|
|
13
|
+
[key: string]: unknown;
|
|
14
|
+
}
|
|
15
|
+
/** A single text block, optionally flagged as an error. */
|
|
16
|
+
export declare function textResult(text: string, isError?: boolean): NativeTextResult;
|
|
17
|
+
//# sourceMappingURL=native-result.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-result.d.ts","sourceRoot":"","sources":["../../src/tools/native-result.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,2FAA2F;IAC3F,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,2DAA2D;AAC3D,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,UAAQ,GAAG,gBAAgB,CAG1E"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { RawRoute } from '../server/types';
|
|
2
|
+
/**
|
|
3
|
+
* OAuth 2.0 Protected Resource Metadata (RFC 9728). An MCP server acting as a
|
|
4
|
+
* resource server publishes this so a client, after a `401`, can discover which
|
|
5
|
+
* authorization server(s) issue tokens for it.
|
|
6
|
+
*/
|
|
7
|
+
export interface ProtectedResourceConfig {
|
|
8
|
+
/** Canonical resource identifier — the MCP server URL (RFC 8707 audience). */
|
|
9
|
+
resource: string;
|
|
10
|
+
/** Issuer URL(s) of the authorization server(s) that mint tokens for it. */
|
|
11
|
+
authorizationServers: string[];
|
|
12
|
+
/** Scopes the resource understands — advertised, not enforced here. */
|
|
13
|
+
scopesSupported?: string[];
|
|
14
|
+
}
|
|
15
|
+
/** Well-known prefix for the protected-resource metadata document (RFC 9728). */
|
|
16
|
+
export declare const PROTECTED_RESOURCE_PATH = "/.well-known/oauth-protected-resource";
|
|
17
|
+
/** Absolute URL of the protected-resource metadata for a given resource. */
|
|
18
|
+
export declare function protectedResourceMetadataUrl(resource: string): string;
|
|
19
|
+
/** The `WWW-Authenticate` header value a protected `401` must carry (RFC 9728 §5.1). */
|
|
20
|
+
export declare function wwwAuthenticateHeader(resource: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* A `RawRoute` serving the RFC 9728 protected-resource metadata at the path
|
|
23
|
+
* advertised by `protectedResourceMetadataUrl(config.resource)`. Mount it
|
|
24
|
+
* alongside the MCP handler; set the matching `protectedResource` on
|
|
25
|
+
* `createMcpHandler` so the `401` points here.
|
|
26
|
+
*/
|
|
27
|
+
export declare function oauthProtectedResourceRoute(config: ProtectedResourceConfig): RawRoute;
|
|
28
|
+
//# sourceMappingURL=oauth-metadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth-metadata.d.ts","sourceRoot":"","sources":["../../src/tools/oauth-metadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACtC,8EAA8E;IAC9E,QAAQ,EAAE,MAAM,CAAC;IACjB,4EAA4E;IAC5E,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,uEAAuE;IACvE,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B;AAED,iFAAiF;AACjF,eAAO,MAAM,uBAAuB,0CAA0C,CAAC;AAa/E,4EAA4E;AAC5E,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAErE;AAED,wFAAwF;AACxF,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE9D;AASD;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,uBAAuB,GAAG,QAAQ,CAqBrF"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { RawRoute } from '../server/types';
|
|
2
|
+
/** A client as registered via DCR. Public clients (PKCE) carry no secret. */
|
|
3
|
+
export interface RegisteredClient {
|
|
4
|
+
clientId: string;
|
|
5
|
+
redirectUris: string[];
|
|
6
|
+
clientName?: string;
|
|
7
|
+
}
|
|
8
|
+
/** Metadata posted to `/register` (RFC 7591) before a client id is assigned. */
|
|
9
|
+
export interface ClientMetadata {
|
|
10
|
+
redirectUris: string[];
|
|
11
|
+
clientName?: string;
|
|
12
|
+
tokenEndpointAuthMethod?: string;
|
|
13
|
+
}
|
|
14
|
+
/** State persisted between `/authorize` and `/token`, keyed by the auth code. */
|
|
15
|
+
export interface AuthCodeData {
|
|
16
|
+
clientId: string;
|
|
17
|
+
redirectUri: string;
|
|
18
|
+
codeChallenge: string;
|
|
19
|
+
/** Always `S256` — `/authorize` rejects any other method (OAuth 2.1, public client). */
|
|
20
|
+
codeChallengeMethod: 'S256';
|
|
21
|
+
resource: string;
|
|
22
|
+
scope?: string;
|
|
23
|
+
userId: string;
|
|
24
|
+
expiresAt: number;
|
|
25
|
+
}
|
|
26
|
+
/** State persisted for a refresh token. */
|
|
27
|
+
export interface RefreshData {
|
|
28
|
+
clientId: string;
|
|
29
|
+
resource: string;
|
|
30
|
+
scope?: string;
|
|
31
|
+
userId: string;
|
|
32
|
+
}
|
|
33
|
+
/** The parsed `/authorize` request handed to the domain login/consent step. */
|
|
34
|
+
export interface AuthRequest {
|
|
35
|
+
clientId: string;
|
|
36
|
+
redirectUri: string;
|
|
37
|
+
scope?: string;
|
|
38
|
+
resource: string;
|
|
39
|
+
state?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface OAuthProviderConfig {
|
|
42
|
+
/** Authorization-server issuer — its own origin, e.g. `https://api.example.com`. */
|
|
43
|
+
issuer: string;
|
|
44
|
+
/** HMAC secret used to sign access-token JWTs. */
|
|
45
|
+
signingSecret: string;
|
|
46
|
+
/** Canonical resource id (MCP URL) — the access-token `aud`. */
|
|
47
|
+
resource: string;
|
|
48
|
+
/** Access-token lifetime in seconds. Default `3600`. */
|
|
49
|
+
accessTokenTtlSec?: number;
|
|
50
|
+
/** Scopes advertised in server metadata. */
|
|
51
|
+
scopesSupported?: string[];
|
|
52
|
+
/** Path prefix for the OAuth endpoints. Default `/oauth`. */
|
|
53
|
+
basePath?: string;
|
|
54
|
+
/** Client registry (DCR). */
|
|
55
|
+
clients: {
|
|
56
|
+
register(metadata: ClientMetadata): Promise<RegisteredClient>;
|
|
57
|
+
get(clientId: string): Promise<RegisteredClient | null>;
|
|
58
|
+
};
|
|
59
|
+
/** Single-use authorization-code store. `take` must atomically read+delete. */
|
|
60
|
+
codes: {
|
|
61
|
+
save(code: string, data: AuthCodeData): Promise<void>;
|
|
62
|
+
take(code: string): Promise<AuthCodeData | null>;
|
|
63
|
+
};
|
|
64
|
+
/** Optional refresh-token store. Omit to disable the refresh grant. */
|
|
65
|
+
refreshTokens?: {
|
|
66
|
+
save(token: string, data: RefreshData): Promise<void>;
|
|
67
|
+
take(token: string): Promise<RefreshData | null>;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Authenticate the user and capture consent for an `/authorize` request.
|
|
71
|
+
* Return `{ userId }` to issue a code, or a `Response` (e.g. a redirect to a
|
|
72
|
+
* login page) to drive the browser through the domain's own login first.
|
|
73
|
+
*/
|
|
74
|
+
authorizeUser(req: Request, authRequest: AuthRequest): Promise<{
|
|
75
|
+
userId: string;
|
|
76
|
+
} | Response>;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Build the OAuth 2.1 authorization-server routes for an MCP resource. Mount the
|
|
80
|
+
* returned routes in the server's `rawRoutes`, alongside
|
|
81
|
+
* `oauthProtectedResourceRoute` and an MCP handler whose `protectedResource`
|
|
82
|
+
* names this issuer.
|
|
83
|
+
*/
|
|
84
|
+
export declare function mountOAuthProvider(config: OAuthProviderConfig): RawRoute[];
|
|
85
|
+
//# sourceMappingURL=oauth-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth-provider.d.ts","sourceRoot":"","sources":["../../src/tools/oauth-provider.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAIhD,6EAA6E;AAC7E,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,gFAAgF;AAChF,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,uBAAuB,CAAC,EAAE,MAAM,CAAC;CAClC;AAED,iFAAiF;AACjF,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,wFAAwF;IACxF,mBAAmB,EAAE,MAAM,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,2CAA2C;AAC3C,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,+EAA+E;AAC/E,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,C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G,QAAQ,CAAC,CAAC;CAC3C;AAoED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,mBAAmB,GAAG,QAAQ,EAAE,CAkR1E"}
|
package/dist/tools/remote.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type
|
|
1
|
+
import { type HttpClient } from '../browser/http';
|
|
2
|
+
import { type ContractDef, type EndpointDef } from '../contract';
|
|
3
3
|
import type { ServiceDef } from '../server/types';
|
|
4
4
|
export interface ImplementRemoteOptions {
|
|
5
5
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote.d.ts","sourceRoot":"","sources":["../../src/tools/remote.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"remote.d.ts","sourceRoot":"","sources":["../../src/tools/remote.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,WAAW,EAEjB,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAAa,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAc7D,MAAM,WAAW,sBAAsB;IACrC;;;;OAIG;IACH,aAAa,CAAC,EAAE,CACd,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC1B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACjE;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EACnE,QAAQ,EAAE,WAAW,CAAC,CAAC,EAAE,MAAM,CAAC,EAChC,IAAI,EAAE,UAAU,EAChB,OAAO,CAAC,EAAE,sBAAsB,GAC/B,UAAU,CA8DZ"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed tool-path context — the tool-side mirror of `createImplement<TCtx>()`.
|
|
3
|
+
*
|
|
4
|
+
* A handler is already typed (`createImplement<AppContext>()` gives `ctx.user`
|
|
5
|
+
* its real type on every surface). What was untyped is the *wiring*: the
|
|
6
|
+
* `context` a tool transport injects, and a `ToolExtend.resolve` result, were
|
|
7
|
+
* `Record<string, unknown>` — TypeScript could not catch a missing or
|
|
8
|
+
* wrong-typed `user`. → ADR 0017.
|
|
9
|
+
*
|
|
10
|
+
* `createToolkit<AppContext>()` fixes the context shape once and returns the
|
|
11
|
+
* tool-mounting functions with `context` (and `extend.resolve`) checked against
|
|
12
|
+
* it — so the CLI, MCP and agent surfaces are born as type-safe as the handler.
|
|
13
|
+
* It is pure typing sugar: each method forwards verbatim to the underlying
|
|
14
|
+
* function, which still accepts the loose form for callers that do not opt in
|
|
15
|
+
* (ADR 0002 keeps the core context loose by default).
|
|
16
|
+
*/
|
|
17
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
18
|
+
import type { ToolSet } from 'ai';
|
|
19
|
+
import type { ServiceDef } from '../server/types';
|
|
20
|
+
import { type AgentMountConfig } from './agent';
|
|
21
|
+
import { type CliConfig } from './cli';
|
|
22
|
+
import { type McpMountConfig, type McpServerBuildConfig } from './mcp';
|
|
23
|
+
import { type McpHandlerConfig } from './mcp-handler';
|
|
24
|
+
import { type StdioMcpServerConfig } from './mcp-stdio';
|
|
25
|
+
import type { ToolExtend } from './mount';
|
|
26
|
+
/** Re-type a config's static `context` (and `extend`) to the toolkit's `TContext`. */
|
|
27
|
+
type WithStaticContext<C, TContext extends Record<string, unknown>> = Omit<C, 'context' | 'extend'> & {
|
|
28
|
+
context?: TContext;
|
|
29
|
+
extend?: ToolExtend<TContext>;
|
|
30
|
+
};
|
|
31
|
+
/** Re-type a config's `(auth) => context` factory to the toolkit's `TContext`. */
|
|
32
|
+
type WithAuthContext<C, TAuth, TContext extends Record<string, unknown>> = Omit<C, 'context'> & {
|
|
33
|
+
context?: (auth: TAuth) => TContext;
|
|
34
|
+
};
|
|
35
|
+
/** The context-pinned tool surface returned by `createToolkit`. */
|
|
36
|
+
export interface Toolkit<TContext extends Record<string, unknown>> {
|
|
37
|
+
mountMcp(server: McpServer, services: ServiceDef | ServiceDef[], config?: WithStaticContext<McpMountConfig, TContext>): void;
|
|
38
|
+
mountAgent(services: ServiceDef | ServiceDef[], config?: WithStaticContext<AgentMountConfig, TContext>): ToolSet;
|
|
39
|
+
buildMcpServer<TAuth>(config: WithAuthContext<McpServerBuildConfig<TAuth>, TAuth, TContext>, auth: TAuth): McpServer;
|
|
40
|
+
createMcpHandler<TAuth>(config: WithAuthContext<McpHandlerConfig<TAuth>, TAuth, TContext>): (req: Request) => Promise<Response>;
|
|
41
|
+
createStdioMcpServer<TAuth>(config: WithAuthContext<StdioMcpServerConfig<TAuth>, TAuth, TContext>): Promise<McpServer>;
|
|
42
|
+
createCli<TAuth = unknown>(config: CliConfig<TAuth, TContext>): Promise<void>;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Fix the tool-handler context type once. `const tools =
|
|
46
|
+
* createToolkit<AppContext>()` — then `tools.createCli`, `tools.mountMcp`, … all
|
|
47
|
+
* type-check their injected `context` against `AppContext`.
|
|
48
|
+
*/
|
|
49
|
+
export declare function createToolkit<TContext extends Record<string, unknown>>(): Toolkit<TContext>;
|
|
50
|
+
export {};
|
|
51
|
+
//# sourceMappingURL=toolkit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolkit.d.ts","sourceRoot":"","sources":["../../src/tools/toolkit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,KAAK,EAA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BAAiB,CAAC,gBAAgB,EAAE,QAAQ,CAAC,GACrD,OAAO,CAAC;IACX,cAAc,CAAC,KAAK,EAClB,MAAM,EAAE,eAAe,CAAC,oBAAoB,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,EACrE,IAAI,EAAE,KAAK,GACV,SAAS,CAAC;IACb,gBAAgB,CAAC,KAAK,EACpB,MAAM,EAAE,eAAe,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,GAChE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IACvC,oBAAoB,CAAC,KAAK,EACxB,MAAM,EAAE,eAAe,CAAC,oBAAoB,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,GACpE,OAAO,CAAC,SAAS,CAAC,CAAC;IACtB,SAAS,CAAC,KAAK,GAAG,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/E;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,QAAQ,CAAC,CAS3F"}
|
|
@@ -13,6 +13,16 @@
|
|
|
13
13
|
* sandboxed to a `baseDir`, and downloads are capped before they reach memory.
|
|
14
14
|
*/
|
|
15
15
|
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
16
|
+
/**
|
|
17
|
+
* Annotation telling the client who a content block is for. `audience` lists
|
|
18
|
+
* `'user'` (render for the human) and/or `'assistant'` (keep in model context);
|
|
19
|
+
* `priority` (0–1) hints how prominently. Same shape as the MCP resource/prompt
|
|
20
|
+
* annotation.
|
|
21
|
+
*/
|
|
22
|
+
export interface McpAnnotations {
|
|
23
|
+
audience?: ('user' | 'assistant')[];
|
|
24
|
+
priority?: number;
|
|
25
|
+
}
|
|
16
26
|
/** An MCP content block — text / image / audio (video cannot be inlined). */
|
|
17
27
|
export type McpMediaContent = {
|
|
18
28
|
type: 'text';
|
|
@@ -21,10 +31,12 @@ export type McpMediaContent = {
|
|
|
21
31
|
type: 'image';
|
|
22
32
|
data: string;
|
|
23
33
|
mimeType: string;
|
|
34
|
+
annotations?: McpAnnotations;
|
|
24
35
|
} | {
|
|
25
36
|
type: 'audio';
|
|
26
37
|
data: string;
|
|
27
38
|
mimeType: string;
|
|
39
|
+
annotations?: McpAnnotations;
|
|
28
40
|
};
|
|
29
41
|
export interface ViewFileOptions {
|
|
30
42
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view-file.d.ts","sourceRoot":"","sources":["../../src/tools/view-file.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;
|
|
1
|
+
{"version":3,"file":"view-file.d.ts","sourceRoot":"","sources":["../../src/tools/view-file.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAwBzE;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,EAAE,CAAC,MAAM,GAAG,WAAW,CAAC,EAAE,CAAC;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,6EAA6E;AAC7E,MAAM,MAAM,eAAe,GACvB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,cAAc,CAAA;CAAE,GAC/E;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,cAAc,CAAA;CAAE,CAAC;AAEpF,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AA4DD;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAChC,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,eAAe,EAAE,CAAC,CA4C5B;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,GAAE,eAAoB,GAAG,IAAI,CA+BpF"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shared poll-until-done loop — one backoff/timeout engine behind both the
|
|
3
|
+
* CLI `--wait` (`pollUntilDone`) and the native MCP `mountWait` tool, so the
|
|
4
|
+
* polling mechanics live in exactly one place. Domain-free (ADR 0002): the
|
|
5
|
+
* caller supplies how to fetch a state (`poll`) and when it is terminal (`done`).
|
|
6
|
+
*/
|
|
7
|
+
export interface PollUntilParams<T> {
|
|
8
|
+
/** Fetch the current state — called once per tick. */
|
|
9
|
+
poll: () => Promise<T>;
|
|
10
|
+
/** Stop when this returns `true` for a fetched state. */
|
|
11
|
+
done: (state: T) => boolean;
|
|
12
|
+
/** Backoff schedule in seconds; the last entry repeats. Default `[2,3,5,5,8,10]`. */
|
|
13
|
+
backoff?: number[];
|
|
14
|
+
/** Max seconds before giving up. Default `600`. */
|
|
15
|
+
timeoutSec?: number;
|
|
16
|
+
/** Injectable sleep for tests. */
|
|
17
|
+
sleepFn?: (ms: number) => Promise<void>;
|
|
18
|
+
/** Progress callback — `(attempt, elapsedSec)` after each non-terminal poll. */
|
|
19
|
+
onTick?: (attempt: number, elapsedSec: number) => void;
|
|
20
|
+
}
|
|
21
|
+
export interface PollUntilResult<T> {
|
|
22
|
+
/** The last fetched state. */
|
|
23
|
+
state: T;
|
|
24
|
+
/** `true` when the timeout was hit before `done`. */
|
|
25
|
+
timedOut: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Poll until `done` or the timeout. Polls first, then sleeps with backoff —
|
|
29
|
+
* returns the terminal state (`timedOut: false`) or the last state seen when
|
|
30
|
+
* the deadline passed (`timedOut: true`).
|
|
31
|
+
*/
|
|
32
|
+
export declare function pollUntil<T>(params: PollUntilParams<T>): Promise<PollUntilResult<T>>;
|
|
33
|
+
//# sourceMappingURL=wait-core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wait-core.d.ts","sourceRoot":"","sources":["../../src/tools/wait-core.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,sDAAsD;IACtD,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC;IACvB,yDAAyD;IACzD,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC;IAC5B,qFAAqF;IACrF,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,mDAAmD;IACnD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kCAAkC;IAClC,OAAO,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,gFAAgF;IAChF,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;CACxD;AAED,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,8BAA8B;IAC9B,KAAK,EAAE,CAAC,CAAC;IACT,qDAAqD;IACrD,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED;;;;GAIG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAkB1F"}
|
package/dist/tools.d.ts
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
|
+
export type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
1
2
|
export { type AgentContext, type AgentMountConfig, mountAgent } from './tools/agent';
|
|
3
|
+
export { type CliConfig, createCli } from './tools/cli';
|
|
4
|
+
export type { ExitCodeMap } from './tools/cli-format';
|
|
5
|
+
export type { CliWaitConfig } from './tools/cli-wait';
|
|
2
6
|
export { coerceJsonArgs } from './tools/coerce';
|
|
3
7
|
export type { ToolCallHooks, ToolLifecycle, ToolResult } from './tools/execute';
|
|
4
8
|
export { flattenDiscriminatedUnion } from './tools/flatten';
|
|
5
9
|
export { buildToolManifest, type ToolManifestEntry } from './tools/manifest';
|
|
6
|
-
export { buildMcpServer, type IncompatibleSchemaPolicy, type McpMountConfig, type McpServerBuildConfig, mountMcp, validateMcpSchemas, } from './tools/mcp';
|
|
10
|
+
export { buildMcpServer, type IncompatibleSchemaPolicy, type McpMountConfig, type McpServerBuildConfig, mountMcp, mountMcpResource, validateMcpSchemas, } from './tools/mcp';
|
|
11
|
+
export { EXT_APPS_BUNDLE_PLACEHOLDER, inlineMcpAppBundle, type McpAppCsp, type McpAppResourceMeta, type McpResourceDef, RESOURCE_MIME_TYPE, } from './tools/mcp-app';
|
|
7
12
|
export { createMcpHandler, type McpHandlerConfig } from './tools/mcp-handler';
|
|
8
13
|
export { createStdioMcpServer, type StdioMcpServerConfig } from './tools/mcp-stdio';
|
|
9
14
|
export { collectTools, type MountableTool, type ToolExtend } from './tools/mount';
|
|
15
|
+
export { type DownloadToolConfig, mountDownload } from './tools/mount-download';
|
|
16
|
+
export { mountUpload, type UploadToolConfig } from './tools/mount-upload';
|
|
17
|
+
export { mountWait, type WaitToolConfig } from './tools/mount-wait';
|
|
18
|
+
export { oauthProtectedResourceRoute, PROTECTED_RESOURCE_PATH, type ProtectedResourceConfig, protectedResourceMetadataUrl, wwwAuthenticateHeader, } from './tools/oauth-metadata';
|
|
19
|
+
export { type AuthCodeData, type AuthRequest, type ClientMetadata, mountOAuthProvider, type OAuthProviderConfig, type RefreshData, type RegisteredClient, } from './tools/oauth-provider';
|
|
10
20
|
export { type ImplementRemoteOptions, implementRemote } from './tools/remote';
|
|
21
|
+
export { createToolkit, type Toolkit } from './tools/toolkit';
|
|
11
22
|
export { type McpMediaContent, mountViewFile, resolveMedia } from './tools/view-file';
|
|
12
23
|
//# sourceMappingURL=tools.d.ts.map
|
package/dist/tools.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,gBAAgB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACrF,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAChF,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,KAAK,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EACL,cAAc,EACd,KAAK,wBAAwB,EAC7B,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,QAAQ,EACR,kBAAkB,GACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAE,KAAK,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACpF,OAAO,EAAE,YAAY,EAAE,KAAK,aAAa,EAAE,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAClF,OAAO,EAAE,KAAK,sBAAsB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EAAE,KAAK,eAAe,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC"}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