[PR #1350] [CLOSED] Load MCP in parallel and cache MCP tools #9902

Closed
opened 2026-02-16 18:14:21 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/anomalyco/opencode/pull/1350
Author: @mpazik
Created: 7/27/2025
Status: Closed

Base: devHead: cache-mcp


📝 Commits (1)

  • a5b08ca load MCP in parallel and cache MCP tools

📊 Changes

1 file changed (+15 additions, -9 deletions)

View changed files

📝 packages/opencode/src/mcp/index.ts (+15 -9)

📄 Description

The remote MCP servers are painfully slow to load, especially since I am currently in China and coding over VPN.

I noticed that loading sequentially doesn't help. After conducting a few tests, I found that the initial client was the slowest.

Test Results

Config

  "mcp": {
    "context7": {
      "type": "remote",
      "url": "https://mcp.context7.com/sse"
    },
    "coin": {
      "type": "remote",
      "url": "https://mcp.api.coingecko.com/sse"
    },
    "fetch": {
      "type": "remote",
      "url": "https://remote.mcpservers.org/fetch/mcp"
    }
  }

Below are the results from my simple benchmark of three runs:

Original implementation:

  • Clients load: 8436ms - 12622ms
  • Tools load (per message): 1192ms - 1387ms

Parallel client and tool loading:

  • Clients load: 2437ms - 3412ms
  • Tools load (per message): 367ms - 569ms

After caching:

  • Clients and tools load together
  • No additional loading per message
  • Drawback: Need to restart opencode on MCP server changes but as it is API I assume it will change very infrequently.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/anomalyco/opencode/pull/1350 **Author:** [@mpazik](https://github.com/mpazik) **Created:** 7/27/2025 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `cache-mcp` --- ### 📝 Commits (1) - [`a5b08ca`](https://github.com/anomalyco/opencode/commit/a5b08cab669eabf09f27ca86963d3d930fc3f1f2) load MCP in parallel and cache MCP tools ### 📊 Changes **1 file changed** (+15 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `packages/opencode/src/mcp/index.ts` (+15 -9) </details> ### 📄 Description The remote MCP servers are painfully slow to load, especially since I am currently in China and coding over VPN. I noticed that loading sequentially doesn't help. After conducting a few tests, I found that the initial client was the slowest. ## Test Results Config ``` "mcp": { "context7": { "type": "remote", "url": "https://mcp.context7.com/sse" }, "coin": { "type": "remote", "url": "https://mcp.api.coingecko.com/sse" }, "fetch": { "type": "remote", "url": "https://remote.mcpservers.org/fetch/mcp" } } ``` Below are the results from my simple benchmark of three runs: Original implementation: - Clients load: 8436ms - 12622ms - Tools load (per message): 1192ms - 1387ms Parallel client and tool loading: - Clients load: 2437ms - 3412ms - Tools load (per message): 367ms - 569ms After caching: - Clients and tools load together - No additional loading per message - Drawback: Need to restart opencode on MCP server changes but as it is API I assume it will change very infrequently. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 18:14:21 -05:00
yindo closed this issue 2026-02-16 18:14:21 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#9902