* Discover tools from one server. Cache-aside by default; pass * `forceRefresh: true` from explicit-refresh paths (refresh button, OAuth * callback) to bypass both positive and negative caches. Concurrent callers * for the same `(workspaceId, serverId, userId, forceRefresh)` share one *
(
userId: string,
serverId: string,
workspaceId: string,
forceRefresh = false
)
| 605 | * upstream request. |
| 606 | */ |
| 607 | async discoverServerTools( |
| 608 | userId: string, |
| 609 | serverId: string, |
| 610 | workspaceId: string, |
| 611 | forceRefresh = false |
| 612 | ): Promise<McpTool[]> { |
| 613 | const inflightKey = `${workspaceId}:${serverId}:${userId}:${forceRefresh ? 'force' : 'cache'}` |
| 614 | const existing = this.inflightServerDiscovery.get(inflightKey) |
| 615 | if (existing) return existing |
| 616 | |
| 617 | const promise = this.discoverServerToolsImpl( |
| 618 | userId, |
| 619 | serverId, |
| 620 | workspaceId, |
| 621 | forceRefresh |
| 622 | ).finally(() => { |
| 623 | this.inflightServerDiscovery.delete(inflightKey) |
| 624 | }) |
| 625 | this.inflightServerDiscovery.set(inflightKey, promise) |
| 626 | return promise |
| 627 | } |
| 628 | |
| 629 | private async discoverServerToolsImpl( |
| 630 | userId: string, |
no test coverage detected