summaryrefslogtreecommitdiffhomepage
path: root/packages
diff options
context:
space:
mode:
authorAiden Cline <[email protected]>2026-02-11 18:19:53 -0600
committerGitHub <[email protected]>2026-02-12 00:19:53 +0000
commit3befd0c6c57d15369b3177e7d64dd7658ca5ab6a (patch)
tree3a2420205f4cac824a72a18314e33d79587206f3 /packages
parent8577eb8ec92b8f2d5f91a043dbd03d0fbc5209ee (diff)
downloadopencode-3befd0c6c57d15369b3177e7d64dd7658ca5ab6a.tar.gz
opencode-3befd0c6c57d15369b3177e7d64dd7658ca5ab6a.zip
tweak: use promise all for mcp listTools calls (#13229)
Diffstat (limited to 'packages')
-rw-r--r--packages/opencode/src/mcp/index.ts39
1 files changed, 21 insertions, 18 deletions
diff --git a/packages/opencode/src/mcp/index.ts b/packages/opencode/src/mcp/index.ts
index 29e958fe3..3c29fe03d 100644
--- a/packages/opencode/src/mcp/index.ts
+++ b/packages/opencode/src/mcp/index.ts
@@ -571,25 +571,28 @@ export namespace MCP {
const clientsSnapshot = await clients()
const defaultTimeout = cfg.experimental?.mcp_timeout
- for (const [clientName, client] of Object.entries(clientsSnapshot)) {
- // Only include tools from connected MCPs (skip disabled ones)
- if (s.status[clientName]?.status !== "connected") {
- continue
- }
+ const connectedClients = Object.entries(clientsSnapshot).filter(
+ ([clientName]) => s.status[clientName]?.status === "connected",
+ )
- const toolsResult = await client.listTools().catch((e) => {
- log.error("failed to get tools", { clientName, error: e.message })
- const failedStatus = {
- status: "failed" as const,
- error: e instanceof Error ? e.message : String(e),
- }
- s.status[clientName] = failedStatus
- delete s.clients[clientName]
- return undefined
- })
- if (!toolsResult) {
- continue
- }
+ const toolsResults = await Promise.all(
+ connectedClients.map(async ([clientName, client]) => {
+ const toolsResult = await client.listTools().catch((e) => {
+ log.error("failed to get tools", { clientName, error: e.message })
+ const failedStatus = {
+ status: "failed" as const,
+ error: e instanceof Error ? e.message : String(e),
+ }
+ s.status[clientName] = failedStatus
+ delete s.clients[clientName]
+ return undefined
+ })
+ return { clientName, client, toolsResult }
+ }),
+ )
+
+ for (const { clientName, client, toolsResult } of toolsResults) {
+ if (!toolsResult) continue
const mcpConfig = config[clientName]
const entry = isMcpConfigured(mcpConfig) ? mcpConfig : undefined
const timeout = entry?.timeout ?? defaultTimeout