@dudko.dev/agent-web 0.0.52 → 0.0.53
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 +22 -7
- package/dist/agent-web.js +129 -129
- package/dist/agent-web.js.map +1 -1
- package/dist/{chunk-QWOKTI62.js → chunk-MJSVRPBP.js} +24 -12
- package/dist/chunk-MJSVRPBP.js.map +1 -0
- package/dist/index.cjs +68 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +58 -12
- package/dist/index.d.ts +58 -12
- package/dist/index.js +45 -31
- package/dist/index.js.map +1 -1
- package/dist/mcp.cjs +88 -11
- package/dist/mcp.cjs.map +1 -1
- package/dist/mcp.d.cts +56 -10
- package/dist/mcp.d.ts +56 -10
- package/dist/mcp.js +88 -11
- package/dist/mcp.js.map +1 -1
- package/dist/{sandbox-QNEDQZTA.js → sandbox-WICP36ZL.js} +2 -2
- package/dist/{skills-ufoyTJ-B.d.cts → skills-BC8yMqpN.d.cts} +1 -1
- package/dist/{skills-ufoyTJ-B.d.ts → skills-BC8yMqpN.d.ts} +1 -1
- package/package.json +1 -1
- package/dist/chunk-QWOKTI62.js.map +0 -1
- /package/dist/{sandbox-QNEDQZTA.js.map → sandbox-WICP36ZL.js.map} +0 -0
package/dist/mcp.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { OAuthClientProvider, FetchLike, StreamableHTTPReconnectionOptions, OAuthClientMetadata, OAuthClientInformationMixed, OAuthTokens, OAuthDiscoveryState } from '@modelcontextprotocol/client';
|
|
2
2
|
export { UnauthorizedError } from '@modelcontextprotocol/client';
|
|
3
3
|
import { ToolSet } from 'ai';
|
|
4
|
-
import { M as McpElicitationHandler, a as McpElicitationOptions, b as
|
|
4
|
+
import { M as McpElicitationHandler, a as McpElicitationOptions, b as McpAppVisibility, c as McpAppResource, d as McpAppDownloadResource, e as McpAppToolResult } from './skills-BC8yMqpN.cjs';
|
|
5
5
|
import { McpSkillsSetting } from './index.cjs';
|
|
6
|
-
export { g as MCP_APPS_EXTENSION, h as MCP_APP_DEFAULT_VISIBILITY, i as MCP_APP_MAX_DOMAINS, j as MCP_APP_MAX_DOWNLOAD_BYTES, k as MCP_APP_MAX_HTML_CHARS, l as MCP_APP_MAX_RESULT_CHARS, m as MCP_APP_MIME_TYPE, n as MCP_ELICITATION_MAX_PER_RUN, o as MCP_ELICITATION_MAX_PER_TOOL_CALL, p as MCP_ELICITATION_TIMEOUT_MS, q as McpAppCsp, r as McpAppPermissions, s as McpAppResourceError, t as McpAppToolMeta, u as McpAppsMode, v as McpElicitationContent, w as McpElicitationContext, x as McpElicitationFieldSchema, y as McpElicitationReason, z as McpElicitationRequest, A as McpElicitationResult, B as McpElicitationSchema, C as isMcpAppMimeType, D as isMcpAppUri, E as mcpAppCspOf, F as mcpAppDownloadOf, G as mcpAppOrigin, H as mcpAppPermissionsOf, I as mcpAppResourceOf, J as mcpAppToolMeta, K as mcpAppToolResultOf, L as mcpAppsModeOf, N as normalizeMcpElicitationSchema, O as validateMcpElicitationContent } from './skills-
|
|
6
|
+
export { g as MCP_APPS_EXTENSION, h as MCP_APP_DEFAULT_VISIBILITY, i as MCP_APP_MAX_DOMAINS, j as MCP_APP_MAX_DOWNLOAD_BYTES, k as MCP_APP_MAX_HTML_CHARS, l as MCP_APP_MAX_RESULT_CHARS, m as MCP_APP_MIME_TYPE, n as MCP_ELICITATION_MAX_PER_RUN, o as MCP_ELICITATION_MAX_PER_TOOL_CALL, p as MCP_ELICITATION_TIMEOUT_MS, q as McpAppCsp, r as McpAppPermissions, s as McpAppResourceError, t as McpAppToolMeta, u as McpAppsMode, v as McpElicitationContent, w as McpElicitationContext, x as McpElicitationFieldSchema, y as McpElicitationReason, z as McpElicitationRequest, A as McpElicitationResult, B as McpElicitationSchema, C as isMcpAppMimeType, D as isMcpAppUri, E as mcpAppCspOf, F as mcpAppDownloadOf, G as mcpAppOrigin, H as mcpAppPermissionsOf, I as mcpAppResourceOf, J as mcpAppToolMeta, K as mcpAppToolResultOf, L as mcpAppsModeOf, N as normalizeMcpElicitationSchema, O as validateMcpElicitationContent } from './skills-BC8yMqpN.cjs';
|
|
7
7
|
import { VaultOptions } from './index.cjs';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -156,6 +156,45 @@ interface McpCatalogEntry {
|
|
|
156
156
|
*/
|
|
157
157
|
app?: string;
|
|
158
158
|
}
|
|
159
|
+
/**
|
|
160
|
+
* A tool a server listed, as the host may show it: EVERY tool of `tools/list` (all pages), the
|
|
161
|
+
* ones offered to the model and the ones that are not (for its app only, or skipped for a name
|
|
162
|
+
* that does not fit). Read from the listing alone - nothing is sent for it, and it changes
|
|
163
|
+
* nothing of what is mounted. Text is the server's: show it as text.
|
|
164
|
+
*/
|
|
165
|
+
interface McpListedTool {
|
|
166
|
+
server: string;
|
|
167
|
+
/** The server's own name for the tool. */
|
|
168
|
+
name: string;
|
|
169
|
+
/**
|
|
170
|
+
* The name the agent's consent rules match: the key it is mounted under, or - when it is not
|
|
171
|
+
* mounted - a key of its own (`server__tool`, as `McpAppTool.key`), given after the mounted
|
|
172
|
+
* ones: no two tools of a connection share a key, mounted or not.
|
|
173
|
+
*/
|
|
174
|
+
key: string;
|
|
175
|
+
/** Offered to the model (in `tools` / `catalog`). False: for its app only, or skipped. */
|
|
176
|
+
mounted: boolean;
|
|
177
|
+
/** `title`, else `annotations.title`, when the server gave one. */
|
|
178
|
+
title?: string;
|
|
179
|
+
description: string;
|
|
180
|
+
/** `annotations.readOnlyHint === true`. */
|
|
181
|
+
readOnly: boolean;
|
|
182
|
+
/**
|
|
183
|
+
* MCP's reading of `annotations.destructiveHint`, which means something only for a tool that
|
|
184
|
+
* is not read-only: there, true unless the server says `false` (the specification's default).
|
|
185
|
+
* Always false for a read-only tool.
|
|
186
|
+
*/
|
|
187
|
+
destructive: boolean;
|
|
188
|
+
/**
|
|
189
|
+
* The MCP App (`ui://…`) it declares in `_meta.ui`, read for this description whatever the
|
|
190
|
+
* server's apps mode (`apps` off: the app is not shown, and nothing else of it is used).
|
|
191
|
+
*/
|
|
192
|
+
app?: string;
|
|
193
|
+
/** `_meta.ui.visibility` (MCP Apps' default `['model', 'app']` when absent), with `app` only. */
|
|
194
|
+
visibility?: McpAppVisibility[];
|
|
195
|
+
/** An app of the server may call it (`ConnectedMcp.apps.appTool` answers for it). */
|
|
196
|
+
appCallable: boolean;
|
|
197
|
+
}
|
|
159
198
|
interface McpServerResult {
|
|
160
199
|
name: string;
|
|
161
200
|
connected: boolean;
|
|
@@ -171,6 +210,11 @@ interface ConnectedMcp {
|
|
|
171
210
|
/** Discovered tools, keyed by "server__tool", ready to merge into config.tools. */
|
|
172
211
|
tools: ToolSet;
|
|
173
212
|
catalog: McpCatalogEntry[];
|
|
213
|
+
/**
|
|
214
|
+
* Every tool each connected server listed, mounted or not ({@link McpListedTool}), in its
|
|
215
|
+
* order - for a host's settings. Rewritten in place by `refreshServer`, like `catalog`.
|
|
216
|
+
*/
|
|
217
|
+
listed: McpListedTool[];
|
|
174
218
|
/** Per-server connect outcome. */
|
|
175
219
|
results: McpServerResult[];
|
|
176
220
|
/**
|
|
@@ -209,8 +253,9 @@ interface McpAppTool {
|
|
|
209
253
|
/** The server's own name for the tool. */
|
|
210
254
|
name: string;
|
|
211
255
|
/**
|
|
212
|
-
* The name the agent's consent rules match: the key the tool is mounted under, or
|
|
213
|
-
*
|
|
256
|
+
* The name the agent's consent rules match: the key the tool is mounted under, or - when it
|
|
257
|
+
* is for apps only and not mounted - a key of its own (`server__tool`, `…_2` when a mounted
|
|
258
|
+
* tool's name sanitizes to the same): never another tool's.
|
|
214
259
|
*/
|
|
215
260
|
key: string;
|
|
216
261
|
description: string;
|
|
@@ -220,6 +265,12 @@ interface McpAppTool {
|
|
|
220
265
|
visibility: McpAppVisibility[];
|
|
221
266
|
/** The app it declares, if any. */
|
|
222
267
|
resourceUri?: string;
|
|
268
|
+
/**
|
|
269
|
+
* The server's identity on THIS connection - opaque, never its address: what an app's "always
|
|
270
|
+
* allow" is kept under (`AppToolCallRequest.serverId`). Another connection has another one: the
|
|
271
|
+
* server removed and added again, reconnected, or another server given the same name.
|
|
272
|
+
*/
|
|
273
|
+
serverId: string;
|
|
223
274
|
}
|
|
224
275
|
/**
|
|
225
276
|
* The host's side of MCP Apps for one connection (`apps: true`). Every call names the server:
|
|
@@ -351,11 +402,6 @@ declare const flattenContent: (content: unknown) => unknown;
|
|
|
351
402
|
declare const diagnoseMcpCors: (url: string, fetchFn?: FetchLike, opts?: {
|
|
352
403
|
protocol?: McpProtocolMode;
|
|
353
404
|
}) => Promise<string | undefined>;
|
|
354
|
-
/**
|
|
355
|
-
* Connect to one or more HTTP MCP servers and return their tools + catalogue.
|
|
356
|
-
* Servers connect concurrently; tools, catalogue, and results merge in the
|
|
357
|
-
* caller's declaration order, so the outcome is deterministic.
|
|
358
|
-
*/
|
|
359
405
|
declare const connectMcpHttp: (servers: Record<string, McpHttpServerConfig>, opts?: ConnectMcpOptions) => Promise<ConnectedMcp>;
|
|
360
406
|
|
|
361
407
|
/**
|
|
@@ -954,4 +1000,4 @@ declare class BrowserEnterpriseOAuthProvider implements OAuthClientProvider {
|
|
|
954
1000
|
declare const createEnterpriseOAuthProvider: (opts: EnterpriseOAuthProviderOptions) => BrowserEnterpriseOAuthProvider;
|
|
955
1001
|
|
|
956
1002
|
export { BrowserEnterpriseOAuthProvider, BrowserOAuthProvider, ENTERPRISE_MANAGED_AUTHORIZATION_EXTENSION, EnterpriseOAuthError, MCP_INSTRUCTIONS_MAX_CHARS_PER_SERVER, MCP_INSTRUCTIONS_MAX_CHARS_TOTAL, MCP_MODERN_PROTOCOL_VERSION, MCP_MODERN_REQUEST_HEADERS, McpAppDownloadResource, McpAppResource, McpAppToolResult, McpAppVisibility, McpElicitationHandler, McpElicitationOptions, MemoryOAuthStorage, VaultOAuthStorage, beginMcpOAuth, checkAuthorizationResponseIssuer, connectMcpHttp, createEnterpriseOAuthProvider, diagnoseMcpCors, finishMcpOAuth, flattenContent, readOAuthCallback, renderMcpInstructions };
|
|
957
|
-
export type { BrowserOAuthProviderOptions, ConnectMcpOptions, ConnectedMcp, EnterpriseAssertionAlgorithm, EnterpriseAssertionAudience, EnterpriseAssertionType, EnterpriseIdpOptions, EnterpriseOAuthHop, EnterpriseOAuthLog, EnterpriseOAuthProviderOptions, EnterprisePrivateKey, McpAppTool, McpAppsConnection, McpCatalogEntry, McpHttpServerConfig, McpOAuthCallback, McpOAuthRegistration, McpOAuthRegistrationKind, McpOAuthRequestOptions, McpOAuthStorage, McpProtocolMode, McpServerInstructions, McpServerProtocol, McpServerResult };
|
|
1003
|
+
export type { BrowserOAuthProviderOptions, ConnectMcpOptions, ConnectedMcp, EnterpriseAssertionAlgorithm, EnterpriseAssertionAudience, EnterpriseAssertionType, EnterpriseIdpOptions, EnterpriseOAuthHop, EnterpriseOAuthLog, EnterpriseOAuthProviderOptions, EnterprisePrivateKey, McpAppTool, McpAppsConnection, McpCatalogEntry, McpHttpServerConfig, McpListedTool, McpOAuthCallback, McpOAuthRegistration, McpOAuthRegistrationKind, McpOAuthRequestOptions, McpOAuthStorage, McpProtocolMode, McpServerInstructions, McpServerProtocol, McpServerResult };
|
package/dist/mcp.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { OAuthClientProvider, FetchLike, StreamableHTTPReconnectionOptions, OAuthClientMetadata, OAuthClientInformationMixed, OAuthTokens, OAuthDiscoveryState } from '@modelcontextprotocol/client';
|
|
2
2
|
export { UnauthorizedError } from '@modelcontextprotocol/client';
|
|
3
3
|
import { ToolSet } from 'ai';
|
|
4
|
-
import { M as McpElicitationHandler, a as McpElicitationOptions, b as
|
|
4
|
+
import { M as McpElicitationHandler, a as McpElicitationOptions, b as McpAppVisibility, c as McpAppResource, d as McpAppDownloadResource, e as McpAppToolResult } from './skills-BC8yMqpN.js';
|
|
5
5
|
import { McpSkillsSetting } from './index.js';
|
|
6
|
-
export { g as MCP_APPS_EXTENSION, h as MCP_APP_DEFAULT_VISIBILITY, i as MCP_APP_MAX_DOMAINS, j as MCP_APP_MAX_DOWNLOAD_BYTES, k as MCP_APP_MAX_HTML_CHARS, l as MCP_APP_MAX_RESULT_CHARS, m as MCP_APP_MIME_TYPE, n as MCP_ELICITATION_MAX_PER_RUN, o as MCP_ELICITATION_MAX_PER_TOOL_CALL, p as MCP_ELICITATION_TIMEOUT_MS, q as McpAppCsp, r as McpAppPermissions, s as McpAppResourceError, t as McpAppToolMeta, u as McpAppsMode, v as McpElicitationContent, w as McpElicitationContext, x as McpElicitationFieldSchema, y as McpElicitationReason, z as McpElicitationRequest, A as McpElicitationResult, B as McpElicitationSchema, C as isMcpAppMimeType, D as isMcpAppUri, E as mcpAppCspOf, F as mcpAppDownloadOf, G as mcpAppOrigin, H as mcpAppPermissionsOf, I as mcpAppResourceOf, J as mcpAppToolMeta, K as mcpAppToolResultOf, L as mcpAppsModeOf, N as normalizeMcpElicitationSchema, O as validateMcpElicitationContent } from './skills-
|
|
6
|
+
export { g as MCP_APPS_EXTENSION, h as MCP_APP_DEFAULT_VISIBILITY, i as MCP_APP_MAX_DOMAINS, j as MCP_APP_MAX_DOWNLOAD_BYTES, k as MCP_APP_MAX_HTML_CHARS, l as MCP_APP_MAX_RESULT_CHARS, m as MCP_APP_MIME_TYPE, n as MCP_ELICITATION_MAX_PER_RUN, o as MCP_ELICITATION_MAX_PER_TOOL_CALL, p as MCP_ELICITATION_TIMEOUT_MS, q as McpAppCsp, r as McpAppPermissions, s as McpAppResourceError, t as McpAppToolMeta, u as McpAppsMode, v as McpElicitationContent, w as McpElicitationContext, x as McpElicitationFieldSchema, y as McpElicitationReason, z as McpElicitationRequest, A as McpElicitationResult, B as McpElicitationSchema, C as isMcpAppMimeType, D as isMcpAppUri, E as mcpAppCspOf, F as mcpAppDownloadOf, G as mcpAppOrigin, H as mcpAppPermissionsOf, I as mcpAppResourceOf, J as mcpAppToolMeta, K as mcpAppToolResultOf, L as mcpAppsModeOf, N as normalizeMcpElicitationSchema, O as validateMcpElicitationContent } from './skills-BC8yMqpN.js';
|
|
7
7
|
import { VaultOptions } from './index.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -156,6 +156,45 @@ interface McpCatalogEntry {
|
|
|
156
156
|
*/
|
|
157
157
|
app?: string;
|
|
158
158
|
}
|
|
159
|
+
/**
|
|
160
|
+
* A tool a server listed, as the host may show it: EVERY tool of `tools/list` (all pages), the
|
|
161
|
+
* ones offered to the model and the ones that are not (for its app only, or skipped for a name
|
|
162
|
+
* that does not fit). Read from the listing alone - nothing is sent for it, and it changes
|
|
163
|
+
* nothing of what is mounted. Text is the server's: show it as text.
|
|
164
|
+
*/
|
|
165
|
+
interface McpListedTool {
|
|
166
|
+
server: string;
|
|
167
|
+
/** The server's own name for the tool. */
|
|
168
|
+
name: string;
|
|
169
|
+
/**
|
|
170
|
+
* The name the agent's consent rules match: the key it is mounted under, or - when it is not
|
|
171
|
+
* mounted - a key of its own (`server__tool`, as `McpAppTool.key`), given after the mounted
|
|
172
|
+
* ones: no two tools of a connection share a key, mounted or not.
|
|
173
|
+
*/
|
|
174
|
+
key: string;
|
|
175
|
+
/** Offered to the model (in `tools` / `catalog`). False: for its app only, or skipped. */
|
|
176
|
+
mounted: boolean;
|
|
177
|
+
/** `title`, else `annotations.title`, when the server gave one. */
|
|
178
|
+
title?: string;
|
|
179
|
+
description: string;
|
|
180
|
+
/** `annotations.readOnlyHint === true`. */
|
|
181
|
+
readOnly: boolean;
|
|
182
|
+
/**
|
|
183
|
+
* MCP's reading of `annotations.destructiveHint`, which means something only for a tool that
|
|
184
|
+
* is not read-only: there, true unless the server says `false` (the specification's default).
|
|
185
|
+
* Always false for a read-only tool.
|
|
186
|
+
*/
|
|
187
|
+
destructive: boolean;
|
|
188
|
+
/**
|
|
189
|
+
* The MCP App (`ui://…`) it declares in `_meta.ui`, read for this description whatever the
|
|
190
|
+
* server's apps mode (`apps` off: the app is not shown, and nothing else of it is used).
|
|
191
|
+
*/
|
|
192
|
+
app?: string;
|
|
193
|
+
/** `_meta.ui.visibility` (MCP Apps' default `['model', 'app']` when absent), with `app` only. */
|
|
194
|
+
visibility?: McpAppVisibility[];
|
|
195
|
+
/** An app of the server may call it (`ConnectedMcp.apps.appTool` answers for it). */
|
|
196
|
+
appCallable: boolean;
|
|
197
|
+
}
|
|
159
198
|
interface McpServerResult {
|
|
160
199
|
name: string;
|
|
161
200
|
connected: boolean;
|
|
@@ -171,6 +210,11 @@ interface ConnectedMcp {
|
|
|
171
210
|
/** Discovered tools, keyed by "server__tool", ready to merge into config.tools. */
|
|
172
211
|
tools: ToolSet;
|
|
173
212
|
catalog: McpCatalogEntry[];
|
|
213
|
+
/**
|
|
214
|
+
* Every tool each connected server listed, mounted or not ({@link McpListedTool}), in its
|
|
215
|
+
* order - for a host's settings. Rewritten in place by `refreshServer`, like `catalog`.
|
|
216
|
+
*/
|
|
217
|
+
listed: McpListedTool[];
|
|
174
218
|
/** Per-server connect outcome. */
|
|
175
219
|
results: McpServerResult[];
|
|
176
220
|
/**
|
|
@@ -209,8 +253,9 @@ interface McpAppTool {
|
|
|
209
253
|
/** The server's own name for the tool. */
|
|
210
254
|
name: string;
|
|
211
255
|
/**
|
|
212
|
-
* The name the agent's consent rules match: the key the tool is mounted under, or
|
|
213
|
-
*
|
|
256
|
+
* The name the agent's consent rules match: the key the tool is mounted under, or - when it
|
|
257
|
+
* is for apps only and not mounted - a key of its own (`server__tool`, `…_2` when a mounted
|
|
258
|
+
* tool's name sanitizes to the same): never another tool's.
|
|
214
259
|
*/
|
|
215
260
|
key: string;
|
|
216
261
|
description: string;
|
|
@@ -220,6 +265,12 @@ interface McpAppTool {
|
|
|
220
265
|
visibility: McpAppVisibility[];
|
|
221
266
|
/** The app it declares, if any. */
|
|
222
267
|
resourceUri?: string;
|
|
268
|
+
/**
|
|
269
|
+
* The server's identity on THIS connection - opaque, never its address: what an app's "always
|
|
270
|
+
* allow" is kept under (`AppToolCallRequest.serverId`). Another connection has another one: the
|
|
271
|
+
* server removed and added again, reconnected, or another server given the same name.
|
|
272
|
+
*/
|
|
273
|
+
serverId: string;
|
|
223
274
|
}
|
|
224
275
|
/**
|
|
225
276
|
* The host's side of MCP Apps for one connection (`apps: true`). Every call names the server:
|
|
@@ -351,11 +402,6 @@ declare const flattenContent: (content: unknown) => unknown;
|
|
|
351
402
|
declare const diagnoseMcpCors: (url: string, fetchFn?: FetchLike, opts?: {
|
|
352
403
|
protocol?: McpProtocolMode;
|
|
353
404
|
}) => Promise<string | undefined>;
|
|
354
|
-
/**
|
|
355
|
-
* Connect to one or more HTTP MCP servers and return their tools + catalogue.
|
|
356
|
-
* Servers connect concurrently; tools, catalogue, and results merge in the
|
|
357
|
-
* caller's declaration order, so the outcome is deterministic.
|
|
358
|
-
*/
|
|
359
405
|
declare const connectMcpHttp: (servers: Record<string, McpHttpServerConfig>, opts?: ConnectMcpOptions) => Promise<ConnectedMcp>;
|
|
360
406
|
|
|
361
407
|
/**
|
|
@@ -954,4 +1000,4 @@ declare class BrowserEnterpriseOAuthProvider implements OAuthClientProvider {
|
|
|
954
1000
|
declare const createEnterpriseOAuthProvider: (opts: EnterpriseOAuthProviderOptions) => BrowserEnterpriseOAuthProvider;
|
|
955
1001
|
|
|
956
1002
|
export { BrowserEnterpriseOAuthProvider, BrowserOAuthProvider, ENTERPRISE_MANAGED_AUTHORIZATION_EXTENSION, EnterpriseOAuthError, MCP_INSTRUCTIONS_MAX_CHARS_PER_SERVER, MCP_INSTRUCTIONS_MAX_CHARS_TOTAL, MCP_MODERN_PROTOCOL_VERSION, MCP_MODERN_REQUEST_HEADERS, McpAppDownloadResource, McpAppResource, McpAppToolResult, McpAppVisibility, McpElicitationHandler, McpElicitationOptions, MemoryOAuthStorage, VaultOAuthStorage, beginMcpOAuth, checkAuthorizationResponseIssuer, connectMcpHttp, createEnterpriseOAuthProvider, diagnoseMcpCors, finishMcpOAuth, flattenContent, readOAuthCallback, renderMcpInstructions };
|
|
957
|
-
export type { BrowserOAuthProviderOptions, ConnectMcpOptions, ConnectedMcp, EnterpriseAssertionAlgorithm, EnterpriseAssertionAudience, EnterpriseAssertionType, EnterpriseIdpOptions, EnterpriseOAuthHop, EnterpriseOAuthLog, EnterpriseOAuthProviderOptions, EnterprisePrivateKey, McpAppTool, McpAppsConnection, McpCatalogEntry, McpHttpServerConfig, McpOAuthCallback, McpOAuthRegistration, McpOAuthRegistrationKind, McpOAuthRequestOptions, McpOAuthStorage, McpProtocolMode, McpServerInstructions, McpServerProtocol, McpServerResult };
|
|
1003
|
+
export type { BrowserOAuthProviderOptions, ConnectMcpOptions, ConnectedMcp, EnterpriseAssertionAlgorithm, EnterpriseAssertionAudience, EnterpriseAssertionType, EnterpriseIdpOptions, EnterpriseOAuthHop, EnterpriseOAuthLog, EnterpriseOAuthProviderOptions, EnterprisePrivateKey, McpAppTool, McpAppsConnection, McpCatalogEntry, McpHttpServerConfig, McpListedTool, McpOAuthCallback, McpOAuthRegistration, McpOAuthRegistrationKind, McpOAuthRequestOptions, McpOAuthStorage, McpProtocolMode, McpServerInstructions, McpServerProtocol, McpServerResult };
|
package/dist/mcp.js
CHANGED
|
@@ -1455,11 +1455,12 @@ var DEFAULT_RECONNECTION = {
|
|
|
1455
1455
|
};
|
|
1456
1456
|
var sanitizeName = (s) => s.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
1457
1457
|
var uniqueKey = (base, taken) => {
|
|
1458
|
-
if (!
|
|
1458
|
+
if (!taken(base)) return base;
|
|
1459
|
+
const max = Math.max(MAX_TOOL_NAME_LEN, base.length);
|
|
1459
1460
|
for (let n = 2; n < 100; n++) {
|
|
1460
1461
|
const suffix = `_${n}`;
|
|
1461
|
-
const candidate = base.slice(0,
|
|
1462
|
-
if (!
|
|
1462
|
+
const candidate = base.slice(0, max - suffix.length) + suffix;
|
|
1463
|
+
if (!taken(candidate)) return candidate;
|
|
1463
1464
|
}
|
|
1464
1465
|
return "";
|
|
1465
1466
|
};
|
|
@@ -1856,6 +1857,12 @@ var connectAndList = async (name, cfg, opts, log, probe, onClient, onListener, e
|
|
|
1856
1857
|
...skills ? { skills } : {}
|
|
1857
1858
|
};
|
|
1858
1859
|
};
|
|
1860
|
+
var mcpServerSeq = 0;
|
|
1861
|
+
var newMcpServerId = () => {
|
|
1862
|
+
mcpServerSeq += 1;
|
|
1863
|
+
const random = typeof globalThis.crypto?.randomUUID === "function" ? globalThis.crypto.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
1864
|
+
return `mcp-${mcpServerSeq}-${random}`;
|
|
1865
|
+
};
|
|
1859
1866
|
var connectMcpHttp = async (servers, opts = {}) => {
|
|
1860
1867
|
const log = opts.onLog ?? (() => {
|
|
1861
1868
|
});
|
|
@@ -1874,18 +1881,31 @@ var connectMcpHttp = async (servers, opts = {}) => {
|
|
|
1874
1881
|
const clients = /* @__PURE__ */ new Map();
|
|
1875
1882
|
const tools = {};
|
|
1876
1883
|
const catalog = [];
|
|
1884
|
+
const listedTools = [];
|
|
1877
1885
|
const results = [];
|
|
1878
1886
|
const instructions = [];
|
|
1879
1887
|
const instructionsOf = /* @__PURE__ */ new Map();
|
|
1880
1888
|
const protocols = [];
|
|
1881
1889
|
const listeners = /* @__PURE__ */ new Map();
|
|
1882
1890
|
const mountedKeys = /* @__PURE__ */ new Map();
|
|
1891
|
+
const unmountedKeys = /* @__PURE__ */ new Map();
|
|
1883
1892
|
const skillCatalogs = /* @__PURE__ */ new Map();
|
|
1884
1893
|
const appsModes = new Map(
|
|
1885
1894
|
Object.entries(servers).map(([name, cfg]) => [name, mcpAppsModeOf(cfg.apps, opts.apps)])
|
|
1886
1895
|
);
|
|
1887
1896
|
const appsOn = [...appsModes.values()].includes("on");
|
|
1888
1897
|
const appToolsOf = /* @__PURE__ */ new Map();
|
|
1898
|
+
const serverIds = new Map(
|
|
1899
|
+
Object.keys(servers).map((name) => [name, newMcpServerId()])
|
|
1900
|
+
);
|
|
1901
|
+
const serverIdOf = (name) => {
|
|
1902
|
+
let id = serverIds.get(name);
|
|
1903
|
+
if (!id) {
|
|
1904
|
+
id = newMcpServerId();
|
|
1905
|
+
serverIds.set(name, id);
|
|
1906
|
+
}
|
|
1907
|
+
return id;
|
|
1908
|
+
};
|
|
1889
1909
|
const appResources = /* @__PURE__ */ new Map();
|
|
1890
1910
|
let appEventSeq = 0;
|
|
1891
1911
|
const requestToolCall = async (name, client, key, toolName, args, options) => {
|
|
@@ -1952,13 +1972,40 @@ var connectMcpHttp = async (servers, opts = {}) => {
|
|
|
1952
1972
|
for (let i = catalog.length - 1; i >= 0; i--) {
|
|
1953
1973
|
if (catalog[i].server === name) catalog.splice(i, 1);
|
|
1954
1974
|
}
|
|
1975
|
+
for (let i = listedTools.length - 1; i >= 0; i--) {
|
|
1976
|
+
if (listedTools[i].server === name) listedTools.splice(i, 1);
|
|
1977
|
+
}
|
|
1955
1978
|
const keys = [];
|
|
1956
1979
|
const appTools = /* @__PURE__ */ new Map();
|
|
1980
|
+
const takenByOthers = (key) => {
|
|
1981
|
+
for (const [server, own2] of unmountedKeys) if (server !== name && own2.has(key)) return true;
|
|
1982
|
+
return false;
|
|
1983
|
+
};
|
|
1984
|
+
const unmounted = [];
|
|
1957
1985
|
let schemaValidator;
|
|
1958
1986
|
let mounted = 0;
|
|
1959
1987
|
const appsMode = appsModes.get(name) ?? "off";
|
|
1960
1988
|
for (const t of listed) {
|
|
1961
1989
|
const prefixed = prefix + sanitizeName(t.name);
|
|
1990
|
+
const declared = mcpAppToolMeta(t);
|
|
1991
|
+
const readOnlyHint = t.annotations?.readOnlyHint === true;
|
|
1992
|
+
const titled = typeof t.title === "string" ? t.title : t.annotations?.title;
|
|
1993
|
+
const entry = {
|
|
1994
|
+
server: name,
|
|
1995
|
+
name: t.name,
|
|
1996
|
+
key: prefixed,
|
|
1997
|
+
mounted: false,
|
|
1998
|
+
...typeof titled === "string" && titled ? { title: titled } : {},
|
|
1999
|
+
description: t.description ?? "",
|
|
2000
|
+
readOnly: readOnlyHint,
|
|
2001
|
+
// MCP's reading: `destructiveHint` means something only for a tool that is not
|
|
2002
|
+
// read-only, and its default there is true.
|
|
2003
|
+
destructive: !readOnlyHint && t.annotations?.destructiveHint !== false,
|
|
2004
|
+
...declared.resourceUri ? { app: declared.resourceUri, visibility: declared.visibility } : {},
|
|
2005
|
+
appCallable: false
|
|
2006
|
+
};
|
|
2007
|
+
listedTools.push(entry);
|
|
2008
|
+
const notMounted = (app) => unmounted.push({ entry, prefixed, ...app ? { app } : {} });
|
|
1962
2009
|
const ui = appsMode !== "off" ? mcpAppToolMeta(t) : void 0;
|
|
1963
2010
|
if (appsMode === "on" && ui?.refusedUri !== void 0) {
|
|
1964
2011
|
log(
|
|
@@ -1972,19 +2019,20 @@ var connectMcpHttp = async (servers, opts = {}) => {
|
|
|
1972
2019
|
"info",
|
|
1973
2020
|
`[mcp] ${name}: tool "${t.name}" is for its app only, and apps are off for this server; not mounted`
|
|
1974
2021
|
);
|
|
2022
|
+
notMounted();
|
|
1975
2023
|
continue;
|
|
1976
2024
|
}
|
|
1977
|
-
|
|
1978
|
-
|
|
2025
|
+
notMounted(
|
|
2026
|
+
ui.visibility.includes("app") ? {
|
|
1979
2027
|
name: t.name,
|
|
1980
|
-
key: prefixed,
|
|
1981
2028
|
description: t.description ?? "",
|
|
1982
2029
|
inputSchema: t.inputSchema,
|
|
1983
2030
|
readOnly: t.annotations?.readOnlyHint === true,
|
|
1984
2031
|
visibility: ui.visibility,
|
|
1985
|
-
...ui.resourceUri ? { resourceUri: ui.resourceUri } : {}
|
|
1986
|
-
|
|
1987
|
-
|
|
2032
|
+
...ui.resourceUri ? { resourceUri: ui.resourceUri } : {},
|
|
2033
|
+
serverId: serverIdOf(name)
|
|
2034
|
+
} : void 0
|
|
2035
|
+
);
|
|
1988
2036
|
log("info", `[mcp] ${name}: tool "${t.name}" is for its app only; not mounted`);
|
|
1989
2037
|
continue;
|
|
1990
2038
|
}
|
|
@@ -1993,11 +2041,13 @@ var connectMcpHttp = async (servers, opts = {}) => {
|
|
|
1993
2041
|
"warn",
|
|
1994
2042
|
`[mcp] ${name}: tool "${t.name}" exceeds the ${MAX_TOOL_NAME_LEN}-char name limit; skipping`
|
|
1995
2043
|
);
|
|
2044
|
+
notMounted();
|
|
1996
2045
|
continue;
|
|
1997
2046
|
}
|
|
1998
|
-
const key = uniqueKey(prefixed, tools);
|
|
2047
|
+
const key = uniqueKey(prefixed, (k) => Object.hasOwn(tools, k) || takenByOthers(k));
|
|
1999
2048
|
if (!key) {
|
|
2000
2049
|
log("warn", `[mcp] ${name}: cannot find a free name for tool "${t.name}"; skipping`);
|
|
2050
|
+
notMounted();
|
|
2001
2051
|
continue;
|
|
2002
2052
|
}
|
|
2003
2053
|
if (key !== prefixed) {
|
|
@@ -2006,7 +2056,10 @@ var connectMcpHttp = async (servers, opts = {}) => {
|
|
|
2006
2056
|
const description = t.description ?? "";
|
|
2007
2057
|
const readOnly = t.annotations?.readOnlyHint === true;
|
|
2008
2058
|
const appUri = appsMode === "on" ? ui?.resourceUri : void 0;
|
|
2059
|
+
entry.key = key;
|
|
2060
|
+
entry.mounted = true;
|
|
2009
2061
|
if (appsMode === "on" && ui?.visibility.includes("app")) {
|
|
2062
|
+
entry.appCallable = true;
|
|
2010
2063
|
appTools.set(t.name, {
|
|
2011
2064
|
name: t.name,
|
|
2012
2065
|
key,
|
|
@@ -2014,7 +2067,8 @@ var connectMcpHttp = async (servers, opts = {}) => {
|
|
|
2014
2067
|
inputSchema: t.inputSchema,
|
|
2015
2068
|
readOnly,
|
|
2016
2069
|
visibility: ui.visibility,
|
|
2017
|
-
...appUri ? { resourceUri: appUri } : {}
|
|
2070
|
+
...appUri ? { resourceUri: appUri } : {},
|
|
2071
|
+
serverId: serverIdOf(name)
|
|
2018
2072
|
});
|
|
2019
2073
|
}
|
|
2020
2074
|
let outputValidator;
|
|
@@ -2098,6 +2152,28 @@ var connectMcpHttp = async (servers, opts = {}) => {
|
|
|
2098
2152
|
mounted += 1;
|
|
2099
2153
|
}
|
|
2100
2154
|
mountedKeys.set(name, keys);
|
|
2155
|
+
const own = /* @__PURE__ */ new Set();
|
|
2156
|
+
unmountedKeys.set(name, own);
|
|
2157
|
+
for (const { entry, prefixed, app } of unmounted) {
|
|
2158
|
+
const key = uniqueKey(
|
|
2159
|
+
prefixed,
|
|
2160
|
+
(k) => Object.hasOwn(tools, k) || own.has(k) || takenByOthers(k)
|
|
2161
|
+
);
|
|
2162
|
+
if (!key) {
|
|
2163
|
+
if (app)
|
|
2164
|
+
log(
|
|
2165
|
+
"warn",
|
|
2166
|
+
`[mcp] ${name}: cannot find a free name for tool "${entry.name}"; its app may not call it`
|
|
2167
|
+
);
|
|
2168
|
+
continue;
|
|
2169
|
+
}
|
|
2170
|
+
entry.key = key;
|
|
2171
|
+
own.add(key);
|
|
2172
|
+
if (app) {
|
|
2173
|
+
entry.appCallable = true;
|
|
2174
|
+
appTools.set(app.name, { ...app, key });
|
|
2175
|
+
}
|
|
2176
|
+
}
|
|
2101
2177
|
if (appsMode === "on") {
|
|
2102
2178
|
appToolsOf.set(name, appTools);
|
|
2103
2179
|
appResources.delete(name);
|
|
@@ -2223,6 +2299,7 @@ var connectMcpHttp = async (servers, opts = {}) => {
|
|
|
2223
2299
|
return {
|
|
2224
2300
|
tools,
|
|
2225
2301
|
catalog,
|
|
2302
|
+
listed: listedTools,
|
|
2226
2303
|
results,
|
|
2227
2304
|
instructions,
|
|
2228
2305
|
protocols,
|