@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.
@@ -1141,7 +1141,7 @@ var ToolRouter = class {
1141
1141
  * If tool name is ambiguous, use namespace to specify the server.
1142
1142
  */
1143
1143
  getToolSchema(toolName, namespace, options = {}) {
1144
- const matches = this.index.getTool(toolName, namespace, options);
1144
+ const matches = this.getIndexedToolMatches(toolName, namespace, options);
1145
1145
  if (matches.length === 0) return void 0;
1146
1146
  if (matches.length > 1) {
1147
1147
  const servers = matches.map((m) => m.serverId).join(", ");
@@ -1348,6 +1348,23 @@ var ToolRouter = class {
1348
1348
  getDirectlyVisibleTools() {
1349
1349
  return this.allTools.filter((tool) => !this.matchesDeferredTool(tool) || this.matchesPinnedTool(tool.name));
1350
1350
  }
1351
+ getIndexedToolMatches(toolName, namespace, options = {}) {
1352
+ const indexedMatches = this.index.getTool(toolName, namespace, options);
1353
+ if (indexedMatches.length > 0 || !this.matchesPinnedTool(toolName)) {
1354
+ return indexedMatches;
1355
+ }
1356
+ return this.matchTools(this.pinnedTools.filter((tool) => tool.name === toolName), namespace, options);
1357
+ }
1358
+ matchTools(tools, namespace, options = {}) {
1359
+ if (!namespace) return tools;
1360
+ const exactMatches = tools.filter(
1361
+ (tool) => tool.sessionId === namespace || tool.serverId === namespace
1362
+ );
1363
+ if (exactMatches.length > 0) return exactMatches;
1364
+ if (!options.allowServerNameFragment) return [];
1365
+ const namespaceLower = namespace.toLowerCase();
1366
+ return tools.filter((tool) => tool.serverName.toLowerCase().includes(namespaceLower));
1367
+ }
1351
1368
  };
1352
1369
  function globToRegExp(pattern) {
1353
1370
  const escaped = pattern.replace(/[.+?^${}()|[\]\\]/g, "\\$&");