@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.
package/dist/index.mjs CHANGED
@@ -5090,7 +5090,7 @@ var ToolRouter = class {
5090
5090
  * If tool name is ambiguous, use namespace to specify the server.
5091
5091
  */
5092
5092
  getToolSchema(toolName, namespace, options = {}) {
5093
- const matches = this.index.getTool(toolName, namespace, options);
5093
+ const matches = this.getIndexedToolMatches(toolName, namespace, options);
5094
5094
  if (matches.length === 0) return void 0;
5095
5095
  if (matches.length > 1) {
5096
5096
  const servers = matches.map((m) => m.serverId).join(", ");
@@ -5297,6 +5297,23 @@ var ToolRouter = class {
5297
5297
  getDirectlyVisibleTools() {
5298
5298
  return this.allTools.filter((tool) => !this.matchesDeferredTool(tool) || this.matchesPinnedTool(tool.name));
5299
5299
  }
5300
+ getIndexedToolMatches(toolName, namespace, options = {}) {
5301
+ const indexedMatches = this.index.getTool(toolName, namespace, options);
5302
+ if (indexedMatches.length > 0 || !this.matchesPinnedTool(toolName)) {
5303
+ return indexedMatches;
5304
+ }
5305
+ return this.matchTools(this.pinnedTools.filter((tool) => tool.name === toolName), namespace, options);
5306
+ }
5307
+ matchTools(tools, namespace, options = {}) {
5308
+ if (!namespace) return tools;
5309
+ const exactMatches = tools.filter(
5310
+ (tool) => tool.sessionId === namespace || tool.serverId === namespace
5311
+ );
5312
+ if (exactMatches.length > 0) return exactMatches;
5313
+ if (!options.allowServerNameFragment) return [];
5314
+ const namespaceLower = namespace.toLowerCase();
5315
+ return tools.filter((tool) => tool.serverName.toLowerCase().includes(namespaceLower));
5316
+ }
5300
5317
  };
5301
5318
  function globToRegExp(pattern) {
5302
5319
  const escaped = pattern.replace(/[.+?^${}()|[\]\\]/g, "\\$&");