@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
|
@@ -400,6 +400,8 @@ declare class ToolRouter {
|
|
|
400
400
|
private matchesDeferredTool;
|
|
401
401
|
private matchesExcludedTool;
|
|
402
402
|
private getDirectlyVisibleTools;
|
|
403
|
+
private getIndexedToolMatches;
|
|
404
|
+
private matchTools;
|
|
403
405
|
}
|
|
404
406
|
|
|
405
407
|
export { type CompactTool as C, type EmbedFn as E, type IndexedTool as I, SchemaCompressor as S, type ToolGroupInfo as T, ToolIndex as a, type ToolIndexOptions as b, type ToolListResult as c, ToolRouter as d, type ToolRouterClientInput as e, type ToolRouterOptions as f, type ToolRouterStrategy as g, type ToolSearchOptions as h, type ToolServerSummary as i, type ToolSummary as j };
|
|
@@ -400,6 +400,8 @@ declare class ToolRouter {
|
|
|
400
400
|
private matchesDeferredTool;
|
|
401
401
|
private matchesExcludedTool;
|
|
402
402
|
private getDirectlyVisibleTools;
|
|
403
|
+
private getIndexedToolMatches;
|
|
404
|
+
private matchTools;
|
|
403
405
|
}
|
|
404
406
|
|
|
405
407
|
export { type CompactTool as C, type EmbedFn as E, type IndexedTool as I, SchemaCompressor as S, type ToolGroupInfo as T, ToolIndex as a, type ToolIndexOptions as b, type ToolListResult as c, ToolRouter as d, type ToolRouterClientInput as e, type ToolRouterOptions as f, type ToolRouterStrategy as g, type ToolSearchOptions as h, type ToolServerSummary as i, type ToolSummary as j };
|
package/package.json
CHANGED
|
@@ -60,6 +60,20 @@ interface McpAppClientCapabilities extends Omit<ClientCapabilities, 'extensions'
|
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
function isInvalidRefreshTokenError(error: unknown): boolean {
|
|
64
|
+
if (!(error instanceof Error)) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const text = `${error.name} ${error.message}`.toLowerCase();
|
|
69
|
+
return (
|
|
70
|
+
text.includes('invalidgrant') ||
|
|
71
|
+
text.includes('invalid_grant') ||
|
|
72
|
+
text.includes('invalid refresh token') ||
|
|
73
|
+
/refresh\s+token\s+(?:is\s+)?(?:invalid|expired|revoked)/i.test(text)
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
63
77
|
export interface MCPOAuthClientOptions {
|
|
64
78
|
serverUrl?: string;
|
|
65
79
|
serverName?: string;
|
|
@@ -970,6 +984,14 @@ export class MCPClient {
|
|
|
970
984
|
return true;
|
|
971
985
|
} catch (error) {
|
|
972
986
|
console.error('[OAuth] Token refresh failed:', error);
|
|
987
|
+
if (isInvalidRefreshTokenError(error)) {
|
|
988
|
+
try {
|
|
989
|
+
await this.oauthProvider.invalidateCredentials?.('tokens');
|
|
990
|
+
this.emitProgress('OAuth refresh token is invalid; requesting reauthorization...');
|
|
991
|
+
} catch (invalidateError) {
|
|
992
|
+
console.warn('[OAuth] Failed to invalidate stale refresh token credentials:', invalidateError);
|
|
993
|
+
}
|
|
994
|
+
}
|
|
973
995
|
return false;
|
|
974
996
|
}
|
|
975
997
|
}
|
|
@@ -274,7 +274,7 @@ export class ToolRouter {
|
|
|
274
274
|
namespace?: string,
|
|
275
275
|
options: ToolLookupOptions = {}
|
|
276
276
|
): IndexedTool | undefined {
|
|
277
|
-
const matches = this.
|
|
277
|
+
const matches = this.getIndexedToolMatches(toolName, namespace, options);
|
|
278
278
|
|
|
279
279
|
if (matches.length === 0) return undefined;
|
|
280
280
|
|
|
@@ -546,6 +546,37 @@ export class ToolRouter {
|
|
|
546
546
|
private getDirectlyVisibleTools(): IndexedTool[] {
|
|
547
547
|
return this.allTools.filter((tool) => !this.matchesDeferredTool(tool) || this.matchesPinnedTool(tool.name));
|
|
548
548
|
}
|
|
549
|
+
|
|
550
|
+
private getIndexedToolMatches(
|
|
551
|
+
toolName: string,
|
|
552
|
+
namespace?: string,
|
|
553
|
+
options: ToolLookupOptions = {}
|
|
554
|
+
): IndexedTool[] {
|
|
555
|
+
const indexedMatches = this.index.getTool(toolName, namespace, options);
|
|
556
|
+
if (indexedMatches.length > 0 || !this.matchesPinnedTool(toolName)) {
|
|
557
|
+
return indexedMatches;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
return this.matchTools(this.pinnedTools.filter((tool) => tool.name === toolName), namespace, options);
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
private matchTools(
|
|
564
|
+
tools: IndexedTool[],
|
|
565
|
+
namespace?: string,
|
|
566
|
+
options: ToolLookupOptions = {}
|
|
567
|
+
): IndexedTool[] {
|
|
568
|
+
if (!namespace) return tools;
|
|
569
|
+
|
|
570
|
+
const exactMatches = tools.filter(
|
|
571
|
+
(tool) => tool.sessionId === namespace || tool.serverId === namespace
|
|
572
|
+
);
|
|
573
|
+
if (exactMatches.length > 0) return exactMatches;
|
|
574
|
+
|
|
575
|
+
if (!options.allowServerNameFragment) return [];
|
|
576
|
+
|
|
577
|
+
const namespaceLower = namespace.toLowerCase();
|
|
578
|
+
return tools.filter((tool) => tool.serverName.toLowerCase().includes(namespaceLower));
|
|
579
|
+
}
|
|
549
580
|
}
|
|
550
581
|
|
|
551
582
|
function globToRegExp(pattern: string): RegExp {
|