@mcp-ts/sdk 2.3.1 → 2.3.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/dist/adapters/agui-adapter.d.mts +1 -1
- package/dist/adapters/agui-adapter.d.ts +1 -1
- package/dist/adapters/agui-middleware.d.mts +1 -1
- package/dist/adapters/agui-middleware.d.ts +1 -1
- package/dist/adapters/ai-adapter.d.mts +1 -1
- package/dist/adapters/ai-adapter.d.ts +1 -1
- package/dist/adapters/langchain-adapter.d.mts +1 -1
- package/dist/adapters/langchain-adapter.d.ts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +33 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -1
- package/dist/index.mjs.map +1 -1
- package/dist/server/index.js +15 -0
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +15 -0
- package/dist/server/index.mjs.map +1 -1
- package/dist/shared/index.d.mts +2 -2
- package/dist/shared/index.d.ts +2 -2
- package/dist/shared/index.js +18 -1
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/index.mjs +18 -1
- package/dist/shared/index.mjs.map +1 -1
- package/dist/{tool-router-CP7qLk1J.d.ts → tool-router-BMzhoNYt.d.ts} +2 -0
- package/dist/{tool-router-BfE_9tay.d.mts → tool-router-BhHsvBfP.d.mts} +2 -0
- package/package.json +1 -1
- package/src/server/mcp/oauth-client.ts +22 -0
- package/src/shared/tool-router.ts +32 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { M as MCPClient, a as MultiSessionClient } from '../multi-session-client-DYNe6az3.mjs';
|
|
2
|
-
import { d as ToolRouter } from '../tool-router-
|
|
2
|
+
import { d as ToolRouter } from '../tool-router-BhHsvBfP.mjs';
|
|
3
3
|
import '../events-CK3N--3g.mjs';
|
|
4
4
|
import '@modelcontextprotocol/sdk/types.js';
|
|
5
5
|
import '@modelcontextprotocol/sdk/client/auth.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { M as MCPClient, a as MultiSessionClient } from '../multi-session-client-BYtguGJm.js';
|
|
2
|
-
import { d as ToolRouter } from '../tool-router-
|
|
2
|
+
import { d as ToolRouter } from '../tool-router-BMzhoNYt.js';
|
|
3
3
|
import '../events-CK3N--3g.js';
|
|
4
4
|
import '@modelcontextprotocol/sdk/types.js';
|
|
5
5
|
import '@modelcontextprotocol/sdk/client/auth.js';
|
|
@@ -7,7 +7,7 @@ import '../events-CK3N--3g.mjs';
|
|
|
7
7
|
import '@modelcontextprotocol/sdk/types.js';
|
|
8
8
|
import '@modelcontextprotocol/sdk/client/auth.js';
|
|
9
9
|
import '@modelcontextprotocol/sdk/shared/auth.js';
|
|
10
|
-
import '../tool-router-
|
|
10
|
+
import '../tool-router-BhHsvBfP.mjs';
|
|
11
11
|
import '../types-CxFaaZrM.mjs';
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -7,7 +7,7 @@ import '../events-CK3N--3g.js';
|
|
|
7
7
|
import '@modelcontextprotocol/sdk/types.js';
|
|
8
8
|
import '@modelcontextprotocol/sdk/client/auth.js';
|
|
9
9
|
import '@modelcontextprotocol/sdk/shared/auth.js';
|
|
10
|
-
import '../tool-router-
|
|
10
|
+
import '../tool-router-BMzhoNYt.js';
|
|
11
11
|
import '../types-CxFaaZrM.js';
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { M as MCPClient, a as MultiSessionClient } from '../multi-session-client-DYNe6az3.mjs';
|
|
2
2
|
import { ToolSet } from 'ai';
|
|
3
|
-
import { d as ToolRouter } from '../tool-router-
|
|
3
|
+
import { d as ToolRouter } from '../tool-router-BhHsvBfP.mjs';
|
|
4
4
|
import '../events-CK3N--3g.mjs';
|
|
5
5
|
import '@modelcontextprotocol/sdk/types.js';
|
|
6
6
|
import '@modelcontextprotocol/sdk/client/auth.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { M as MCPClient, a as MultiSessionClient } from '../multi-session-client-BYtguGJm.js';
|
|
2
2
|
import { ToolSet } from 'ai';
|
|
3
|
-
import { d as ToolRouter } from '../tool-router-
|
|
3
|
+
import { d as ToolRouter } from '../tool-router-BMzhoNYt.js';
|
|
4
4
|
import '../events-CK3N--3g.js';
|
|
5
5
|
import '@modelcontextprotocol/sdk/types.js';
|
|
6
6
|
import '@modelcontextprotocol/sdk/client/auth.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { M as MCPClient, a as MultiSessionClient } from '../multi-session-client-DYNe6az3.mjs';
|
|
2
2
|
import { StructuredTool } from '@langchain/core/tools';
|
|
3
|
-
import { d as ToolRouter } from '../tool-router-
|
|
3
|
+
import { d as ToolRouter } from '../tool-router-BhHsvBfP.mjs';
|
|
4
4
|
import '../events-CK3N--3g.mjs';
|
|
5
5
|
import '@modelcontextprotocol/sdk/types.js';
|
|
6
6
|
import '@modelcontextprotocol/sdk/client/auth.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { M as MCPClient, a as MultiSessionClient } from '../multi-session-client-BYtguGJm.js';
|
|
2
2
|
import { StructuredTool } from '@langchain/core/tools';
|
|
3
|
-
import { d as ToolRouter } from '../tool-router-
|
|
3
|
+
import { d as ToolRouter } from '../tool-router-BMzhoNYt.js';
|
|
4
4
|
import '../events-CK3N--3g.js';
|
|
5
5
|
import '@modelcontextprotocol/sdk/types.js';
|
|
6
6
|
import '@modelcontextprotocol/sdk/client/auth.js';
|
package/dist/index.d.mts
CHANGED
|
@@ -7,6 +7,6 @@ export { OAuthClientInformation, OAuthClientInformationFull, OAuthClientMetadata
|
|
|
7
7
|
export { CallToolResult, ListToolsResult, Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
8
8
|
export { A as APP_HOST_DEFAULTS, a as AppHost, D as DEFAULT_MCP_APP_CSP, S as SANDBOX_PROXY_READY_METHOD, b as SANDBOX_RESOURCE_READY_METHOD, c as SSEClient, d as SSEClientOptions } from './index-Cfjsme-a.mjs';
|
|
9
9
|
export { CallToolFn, DEFAULT_CLIENT_NAME, DEFAULT_CLIENT_URI, DEFAULT_HEARTBEAT_INTERVAL_MS, DEFAULT_LOGO_URI, DEFAULT_POLICY_URI, MCP_CLIENT_NAME, MCP_CLIENT_VERSION, REDIS_KEY_PREFIX, SESSION_TTL_SECONDS, SOFTWARE_ID, SOFTWARE_VERSION, STATE_EXPIRATION_MS, TOKEN_EXPIRY_BUFFER_MS, ToolUiConfig, createExecuteToolDefinition, createGetSchemaToolDefinition, createListServersToolDefinition, createRegexSearchToolDefinition, createSearchToolDefinition, executeMetaTool, findToolByName, getToolUiResourceUri, isMetaTool, resolveMetaToolProxy } from './shared/index.mjs';
|
|
10
|
-
export { C as CompactTool, E as EmbedFn, I as IndexedTool, S as SchemaCompressor, T as ToolGroupInfo, a as ToolIndex, b as ToolIndexOptions, c as ToolListResult, d as ToolRouter, e as ToolRouterClientInput, f as ToolRouterOptions, g as ToolRouterStrategy, h as ToolSearchOptions, i as ToolServerSummary, j as ToolSummary } from './tool-router-
|
|
10
|
+
export { C as CompactTool, E as EmbedFn, I as IndexedTool, S as SchemaCompressor, T as ToolGroupInfo, a as ToolIndex, b as ToolIndexOptions, c as ToolListResult, d as ToolRouter, e as ToolRouterClientInput, f as ToolRouterOptions, g as ToolRouterStrategy, h as ToolSearchOptions, i as ToolServerSummary, j as ToolSummary } from './tool-router-BhHsvBfP.mjs';
|
|
11
11
|
import '@modelcontextprotocol/sdk/client/auth.js';
|
|
12
12
|
import '@modelcontextprotocol/ext-apps/app-bridge';
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,6 @@ export { OAuthClientInformation, OAuthClientInformationFull, OAuthClientMetadata
|
|
|
7
7
|
export { CallToolResult, ListToolsResult, Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
8
8
|
export { A as APP_HOST_DEFAULTS, a as AppHost, D as DEFAULT_MCP_APP_CSP, S as SANDBOX_PROXY_READY_METHOD, b as SANDBOX_RESOURCE_READY_METHOD, c as SSEClient, d as SSEClientOptions } from './index-CmjMd2ac.js';
|
|
9
9
|
export { CallToolFn, DEFAULT_CLIENT_NAME, DEFAULT_CLIENT_URI, DEFAULT_HEARTBEAT_INTERVAL_MS, DEFAULT_LOGO_URI, DEFAULT_POLICY_URI, MCP_CLIENT_NAME, MCP_CLIENT_VERSION, REDIS_KEY_PREFIX, SESSION_TTL_SECONDS, SOFTWARE_ID, SOFTWARE_VERSION, STATE_EXPIRATION_MS, TOKEN_EXPIRY_BUFFER_MS, ToolUiConfig, createExecuteToolDefinition, createGetSchemaToolDefinition, createListServersToolDefinition, createRegexSearchToolDefinition, createSearchToolDefinition, executeMetaTool, findToolByName, getToolUiResourceUri, isMetaTool, resolveMetaToolProxy } from './shared/index.js';
|
|
10
|
-
export { C as CompactTool, E as EmbedFn, I as IndexedTool, S as SchemaCompressor, T as ToolGroupInfo, a as ToolIndex, b as ToolIndexOptions, c as ToolListResult, d as ToolRouter, e as ToolRouterClientInput, f as ToolRouterOptions, g as ToolRouterStrategy, h as ToolSearchOptions, i as ToolServerSummary, j as ToolSummary } from './tool-router-
|
|
10
|
+
export { C as CompactTool, E as EmbedFn, I as IndexedTool, S as SchemaCompressor, T as ToolGroupInfo, a as ToolIndex, b as ToolIndexOptions, c as ToolListResult, d as ToolRouter, e as ToolRouterClientInput, f as ToolRouterOptions, g as ToolRouterStrategy, h as ToolSearchOptions, i as ToolServerSummary, j as ToolSummary } from './tool-router-BMzhoNYt.js';
|
|
11
11
|
import '@modelcontextprotocol/sdk/client/auth.js';
|
|
12
12
|
import '@modelcontextprotocol/ext-apps/app-bridge';
|
package/dist/index.js
CHANGED
|
@@ -1783,6 +1783,13 @@ var RpcErrorCodes = {
|
|
|
1783
1783
|
};
|
|
1784
1784
|
|
|
1785
1785
|
// src/server/mcp/oauth-client.ts
|
|
1786
|
+
function isInvalidRefreshTokenError(error) {
|
|
1787
|
+
if (!(error instanceof Error)) {
|
|
1788
|
+
return false;
|
|
1789
|
+
}
|
|
1790
|
+
const text = `${error.name} ${error.message}`.toLowerCase();
|
|
1791
|
+
return text.includes("invalidgrant") || text.includes("invalid_grant") || text.includes("invalid refresh token") || /refresh\s+token\s+(?:is\s+)?(?:invalid|expired|revoked)/i.test(text);
|
|
1792
|
+
}
|
|
1786
1793
|
var MCPClient = class _MCPClient {
|
|
1787
1794
|
/**
|
|
1788
1795
|
* Creates a new MCP client instance
|
|
@@ -2474,6 +2481,14 @@ var MCPClient = class _MCPClient {
|
|
|
2474
2481
|
return true;
|
|
2475
2482
|
} catch (error) {
|
|
2476
2483
|
console.error("[OAuth] Token refresh failed:", error);
|
|
2484
|
+
if (isInvalidRefreshTokenError(error)) {
|
|
2485
|
+
try {
|
|
2486
|
+
await this.oauthProvider.invalidateCredentials?.("tokens");
|
|
2487
|
+
this.emitProgress("OAuth refresh token is invalid; requesting reauthorization...");
|
|
2488
|
+
} catch (invalidateError) {
|
|
2489
|
+
console.warn("[OAuth] Failed to invalidate stale refresh token credentials:", invalidateError);
|
|
2490
|
+
}
|
|
2491
|
+
}
|
|
2477
2492
|
return false;
|
|
2478
2493
|
}
|
|
2479
2494
|
}
|
|
@@ -5190,7 +5205,7 @@ var ToolRouter = class {
|
|
|
5190
5205
|
* If tool name is ambiguous, use namespace to specify the server.
|
|
5191
5206
|
*/
|
|
5192
5207
|
getToolSchema(toolName, namespace, options = {}) {
|
|
5193
|
-
const matches = this.
|
|
5208
|
+
const matches = this.getIndexedToolMatches(toolName, namespace, options);
|
|
5194
5209
|
if (matches.length === 0) return void 0;
|
|
5195
5210
|
if (matches.length > 1) {
|
|
5196
5211
|
const servers = matches.map((m) => m.serverId).join(", ");
|
|
@@ -5397,6 +5412,23 @@ var ToolRouter = class {
|
|
|
5397
5412
|
getDirectlyVisibleTools() {
|
|
5398
5413
|
return this.allTools.filter((tool) => !this.matchesDeferredTool(tool) || this.matchesPinnedTool(tool.name));
|
|
5399
5414
|
}
|
|
5415
|
+
getIndexedToolMatches(toolName, namespace, options = {}) {
|
|
5416
|
+
const indexedMatches = this.index.getTool(toolName, namespace, options);
|
|
5417
|
+
if (indexedMatches.length > 0 || !this.matchesPinnedTool(toolName)) {
|
|
5418
|
+
return indexedMatches;
|
|
5419
|
+
}
|
|
5420
|
+
return this.matchTools(this.pinnedTools.filter((tool) => tool.name === toolName), namespace, options);
|
|
5421
|
+
}
|
|
5422
|
+
matchTools(tools, namespace, options = {}) {
|
|
5423
|
+
if (!namespace) return tools;
|
|
5424
|
+
const exactMatches = tools.filter(
|
|
5425
|
+
(tool) => tool.sessionId === namespace || tool.serverId === namespace
|
|
5426
|
+
);
|
|
5427
|
+
if (exactMatches.length > 0) return exactMatches;
|
|
5428
|
+
if (!options.allowServerNameFragment) return [];
|
|
5429
|
+
const namespaceLower = namespace.toLowerCase();
|
|
5430
|
+
return tools.filter((tool) => tool.serverName.toLowerCase().includes(namespaceLower));
|
|
5431
|
+
}
|
|
5400
5432
|
};
|
|
5401
5433
|
function globToRegExp(pattern) {
|
|
5402
5434
|
const escaped = pattern.replace(/[.+?^${}()|[\]\\]/g, "\\$&");
|