@mcp-ts/sdk 2.3.1 → 2.3.2

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.
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcp-ts/sdk",
3
- "version": "2.3.1",
3
+ "version": "2.3.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -274,7 +274,7 @@ export class ToolRouter {
274
274
  namespace?: string,
275
275
  options: ToolLookupOptions = {}
276
276
  ): IndexedTool | undefined {
277
- const matches = this.index.getTool(toolName, namespace, options);
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 {