mcp: remote servers with >61 tools are silently truncated
Summary
Remote MCP servers exposing more than 61 tools are silently capped by OpenCode: only the first 61 tools appear in the tool catalog, and any additional tool is reported as Unknown tool even though the server advertises it via tools/list. This makes tools added after the initial handshake unusable, with no error or warning beyond the connection log line mcp connected tools=61.
Environment
- opencode version: v2.3.2
- OS: Linux 7.0.0-43-generic (linux x64)
- Terminal:
TERM=xterm-256color,COLORTERM=truecolor(TERM_PROGRAMunset) - Shell: /usr/bin/fish
- Install/channel: latest (release)
- Active plugins: none found in
~/.config/opencode/opencode.json
Reproduction
- Configure a remote MCP server in
~/.config/opencode/opencode.json(e.g.opencode mcp add organify --global --url https://…/mcp). - Authenticate via
/mcps. - Connect an MCP server that exposes more than 61 tools (verified with servers exposing 62 and 79 tools).
- Try to call one of the tools beyond the 61st (e.g.
list_workspaces).
Expected Behavior
All tools returned by the MCP server's tools/list should be available in the tool catalog and callable via tools.<server>.<name>.
Actual Behavior
Exactly 61 tools are exposed. search({ namespace: "<server>" }) returns 61 items; calling the 62nd tool fails with:
Unknown tool 'organify.list_workspaces'. Did you mean tools.organify.list_workspace_teams?
The service log reports mcp connected … tools=61, while a direct JSON-RPC tools/list call against the same endpoint returns 62 tools including list_workspaces. Reproduced consistently across:
- TUI restart,
- full
opencode service restart(new run id), - MCP config removal + re-add + fresh OAuth authorization,
- a second MCP entry with a different name pointing at the same URL.
The public endpoint was also verified at the server level: nginx proxies to the correct container, the running binary contains the tool, and a direct tools/list returns TOOL COUNT: 62.
Additional Context
No config option for a tool limit was found in https://opencode.ai/config.json; the only MCP-specific tuning appears to be mcp_timeout. Searches of opencode-ai/opencode issues for mcp max tools, mcp tools truncated, too many tools mcp, mcp tool count, mcp tools missing found no existing report.
Workaround: none found for exposing the additional tools in this version; the MCP server itself is healthy and tools within the first 61 work normally.
Thanks for the detailed report and for checking the server side so carefully.
In the MCP code I read, I did not find a limit on the number of tools. The tools=N in the mcp connected log line counts the tools that were kept after each one is checked, and a tool can be left out in two ways:
- OpenCode skips a listed tool whose
inputSchemais not an object, or whoseinputSchema.typeis something other than"object". It logs askipping invalid MCP toolwarning for each one it skips. - The MCP SDK that OpenCode uses also leaves out tools with an invalid
x-mcp-headerdeclaration, and prints[mcp-sdk] excluding tool '<name>' from tools/list: invalid x-mcp-header declaration — <reason>.
So list_workspaces may have been dropped because of how it is defined, not because of its position in the list. Could you share:
- Any
skipping invalid MCP toolor[mcp-sdk] excluding toollines from around the connection. The log is at~/.local/share/opencode/log/opencode.log(opencode debug paths logprints the folder), e.g.grep -E 'skipping invalid MCP tool|excluding tool' ~/.local/share/opencode/log/opencode.log. - The raw
tools/listentry forlist_workspaces, and how it differs from a tool that works (for examplelist_workspace_teams). Please remove anything private first. - For the server with 79 tools: did OpenCode also show exactly 61, and which tools were missing?
You can reply here with the details, or edit the issue. If you edit it, please also leave a comment saying you've updated it, so we know when you're done.
Related issues I found, ordered by likelihood (I don't think either one is the same problem):
- #64117: tools a server announces later through
notifications/tools/list_changednever become callable. Your tools stay missing after a restart and a fresh connection, so this is probably a different cause. - #52420: tool names that differ only in characters normalized to
_collide, so one replaces the other.
Thanks for the quick reply. I re-checked both points you asked for.
1. Skip/exclusion warnings — none found
grep -E 'skipping invalid MCP tool|excluding tool' ~/.local/share/opencode/log/opencode.log
returns nothing. A broader case-insensitive grep for invalid|skip|exclud|tool around the connection shows only the normal mcp connected … tools=61 lines and a few older failed to call MCP tool … HTTP 401 warnings (from an expired token, before re-auth). No tool-skip warning of any kind.
2. Raw tools/list entries
Both from a direct JSON-RPC tools/list call against the running Go server (COUNT 62), with the private fields redacted as requested (none present):
{"name":"list_workspace_teams","title":"List workspace teams","description":"List teams in a workspace with member counts. Read-only.","inputSchema":{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"workspaceSlug":{"type":"string","description":"Workspace slug"},"userId":{"description":"User ID","type":"string"}},"required":["workspaceSlug"]},"annotations":{"readOnlyHint":true}}
{"name":"list_workspaces","title":"List workspaces","description":"List every workspace the authenticated user can access …","inputSchema":{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"userId":{"description":"User ID (always overridden by the authenticated bearer token).","type":"string"}}},"annotations":{"openWorldHint":false,"readOnlyHint":true}}
Both have inputSchema.type: "object", valid properties, and no x-mcp-header. The only structural difference I can see is that list_workspaces has no required array. That alone does not explain it: other tools without required (e.g. organify.system.status, plan_create_tasks, create_sprint) are present in the 61 exposed by OpenCode.
3. The 79-tool server
With the previous TypeScript implementation, dump-tools.mjs reported 79 tools and OpenCode again exposed exactly 61. I did not record the exact list of the 18 missing ones at the time, but they were the tools added most recently (notifications/avatar/pulse/subtasks/task-media/list-workspaces and similar). So the “exactly 61” coincidence happened with two different servers and two different sets of extra tools.
Extra data points
- The server log line says
ready (62 tools, backend=http). - After the Go-only migration I removed the MCP entry from config, deleted the OAuth credentials from the OpenCode DB, re-added the server, re-authenticated, restarted the TUI, and finally did a full
opencode service restart(newrun=3d489a6d). Every reconnect still logstools=61. - A second MCP entry with a different name pointing at the same URL also got 61.
- Calling the missing tool returns
Unknown tool 'organify.list_workspaces'. Did you mean tools.organify.list_workspace_teams?
Happy to try a narrow experiment if useful — e.g. adding "required":[] to the schema, or changing the tool name — and report whether it appears. Just tell me what to change.
Thanks for the extra details. I tried this on v2.3.2 (Linux) with a small test MCP server over Streamable HTTP. Its tools copy your list_workspaces schema shape: $schema draft-07, type: "object", one optional property, no required. OpenCode kept every tool in each case:
- 62 tools:
mcp connected server=many tools=62 - 79 tools, after
opencode service restart:tools=79 - 62 tools sent in pages of 50: OpenCode asked for both pages (
tools/list {}and then{"cursor":"50"}) and loggedtools=62
So I couldn't reproduce a limit at 61. The tools=N in mcp connected is counted right after OpenCode reads the server's tools/list reply, so in your setup OpenCode most likely received only 61 tools. My test had no OAuth, so it doesn't cover that part of your setup. These could narrow it down:
- Your server's own log of the
tools/listrequest it gets from OpenCode: how many tools it returned, and whether it sent anextCursor. - Run your direct test the way OpenCode connects:
initializewith"protocolVersion": "2025-11-25", thentools/list, using the bearer token OpenCode got from your OAuth flow rather than another one. Does it still return 62? - Whether the server filters tools by OAuth scope, user or client. If the 61 tools OpenCode sees are exactly the older tools, a scope or permission check on the newer ones would explain it.
If you can share a minimal server or a public endpoint where this happens, we can try again with it.
Follow-up on your three suggestions — I ran all of them.
1. Server-side view of the tools/list request
The Go server does not log individual JSON-RPC methods, but a direct tools/list from the same host returns the full set with no pagination:
2025-11-25 COUNT 62 HAS True cursor None
2025-06-18 COUNT 62 HAS True cursor None
2. Direct test exactly the way OpenCode connects
Using the bearer token OpenCode obtained from its own OAuth flow (read from the OpenCode credential store), against http://127.0.0.1:4010/mcp with both protocolVersion: "2025-11-25" and "2025-06-18": COUNT 62, list_workspaces present, no nextCursor. So the server sends 62 tools with no paging.
3. Filtering by OAuth scope / user / client
I checked go/internal/mcp/httpserver.go and go/internal/mcp/protocol.go: tools/list returns the full s.tools slice verbatim; there is no scope, user, permission or entitlement filtering in the MCP server.
So the remaining difference from your repro is OAuth. Your test had no OAuth; this server requires a bearer token, and OpenCode goes through the full DCR + PKCE flow. With the identical token and protocol version, a raw client gets 62 tools while OpenCode logs tools=61. That suggests something in the OAuth/authenticated MCP client path is dropping the tool — and notably no skipping invalid MCP tool warning appears in the log at all.
Happy to test a minimal OAuth-protected server if you have one, or to run OpenCode with OPENCODE_LOG_LEVEL=DEBUG and paste the connection lines. Just tell me what would be most useful.
Thanks for running those checks. I tried again on v2.3.2 with OAuth, close to your setup: a small test server that is both the MCP server and its OAuth sign-in server. It does the sign-in the same way as yours (ending with PKCE), refuses /mcp without a token, sends its replies as SSE, and offers 62 tools. The 62nd is a copy of your list_workspaces schema. After opencode mcp add organify --url … and opencode mcp auth organify, OpenCode connected with the token, sent initialize with 2025-11-25 and then tools/list, and logged:
mcp connected server=organify tools=62
The earlier runs without OAuth also kept every tool: 62, 79, and 62 split across two pages. So in my tests paging, the protocol version, the OAuth path and SSE replies don't cap the list at 61. I couldn't reproduce it with any of them, and I don't have a cause yet.
What would help most:
- Run
opencode mcp list --standalone --print-logs --log-level debugfrom the project where it happens, and paste the lines about your server (remove tokens). - Point OpenCode at
http://127.0.0.1:4010/mcpdirectly instead of the public URL, using a new server name so it signs in again. Is it stilltools=61? If not, the proxy is involved. - If you can, a small server, or a test endpoint with a throwaway account, where this happens, so a maintainer can run OpenCode against it.
Ran the two things I could without another sign-in round.
1. Debug output
opencode mcp list --standalone --print-logs --log-level debug
from the project directory prints:
… level=DEBUG message="spawning process" command=/home/noejunior299/.opencode/bin/opencode args="[\"serve\",\"--stdio\",\"--port\",\"0\"]" …
… level=INFO message="watcher started" path=/home/noejunior299/Documents/projects/techify/organify …
No MCP servers configured
… level=INFO message="watcher stopped" …
So --standalone does not pick up my global ~/.config/opencode/opencode.json MCP entry — it reports No MCP servers configured, while plain opencode mcp list says ✓ organify connected. I therefore could not capture the per-server debug lines you asked for. Is there a flag/env to make the standalone server load the global config?
2. Direct http://127.0.0.1:4010/mcp
That address is on the remote server, not on this machine, so OpenCode cannot reach it as-is. I can set up an SSH tunnel and add a second MCP entry with a new name, but the server's OAuth issuer is https://mcp.organify.ao, so I expect the loopback sign-in to fail or to be blocked by the OAuth redirect rules. Before I spend a sign-in round on it: do you expect that test to be meaningful given the issuer mismatch, or is there a better way to force OpenCode to re-read tools/list with full DEBUG logging?
For reference, the normal log still shows only these MCP lines after every reconnect (no skip warnings at any level):
level=INFO message="mcp connected" server=organify tools=61 …
and the log file is not rotated, so the warnings you described would be in it if they had been emitted.
Thanks, that helps.
About --standalone: my first --standalone runs printed the same No MCP servers configured, even with the server in the project's own opencode.json. So I don't think your global config is the cause. Please skip that command. Your tools=61 lines come from the background service, and its log is the more useful one anyway.
About the SSH tunnel: I'd skip it. With your issuer on https://mcp.organify.ao, a failed sign-in through a loopback tunnel wouldn't tell us anything about this bug.
What would help instead, with no new sign-in needed:
- Run
opencode service restart, thenopencode mcp list. Then post every line about your server from that run:grep 'role=server' ~/.local/share/opencode/log/opencode.log | grep -i organify | tail -40(opencode debug paths logprints the log folder). Remove anything private. - The order: are the 61 tools OpenCode keeps exactly the first 61 in the order your server's
tools/listreturns them, withlist_workspaceslast? With the 79-tool server you said the missing 18 were the newest ones. If they were also the last 18 in the list, then something is cutting the list at a fixed position. - The reply to
tools/listthrough the public URL: itsContent-Type(application/jsonortext/event-stream), its size in bytes, and whether nginx compresses it or sends it in chunks. - Your
organifyentry from~/.config/opencode/opencode.json(with no secrets), so I can see anytimeout,protocol,headersoroauthsettings.
For reference, my two test servers both returned 62 tools with the same schema shape as yours. One required an OAuth sign-in and sent replies as SSE. OpenCode logged tools=62 for both. A small server, or a test endpoint where this happens, would still be the fastest way to pin it down.
Root cause found — and it is on my side, not in OpenCode. Please close this issue.
Your question about the order/reply finally pointed to it: I compared tools/list through the public URL against a direct call to the container:
- direct to the new server (
127.0.0.1:4010): 62 tools,list_workspacespresent (index 35, not last), nonextCursor; - same call through
https://mcp.organify.ao/mcp: 61 tools,list_workspacesabsent, nonextCursor.
The active nginx config had:
server_name mcp.organify.ao;
location ~ ^/(authorize|token|...|mcp)(/|$) { proxy_pass http://127.0.0.1:4020; }
Port 4020 belongs to an older parallel container (organify-mcp-go) that was built before list_workspaces existed, while the current Go server was on 4010. So OpenCode was faithfully exposing exactly the 61 tools it received from the stale upstream. My earlier "cap of 61" theory was wrong — the number 61 was just the old binary's tool count.
Response details through the public URL at the time (for the record): Content-Type: application/json, Content-Length absent (chunked), server: cloudflare, cf-cache-status: DYNAMIC, body 39,418 bytes. No compression or paging involved.
I rebuilt and recreated the stale mcp-go container from the current source. Verified again:
PUBLIC COUNT 62 HAS list_workspaces True
Thanks for your patience and for the systematic questions — the "is it the first 61 in order?" prompt is what made me compare the two endpoints. Sorry for the false report.
Thanks for tracking it down and writing up what you found. It all fits: OpenCode was showing the 61 tools the old copy of your server on port 4020 returned, and it matches my tests, where OpenCode kept every tool the server sent.
Since this wasn't a bug in OpenCode, the issue will be closed as not reproduced. If you see the tool count stop short again with an up-to-date server behind the URL, reply here and it will be reopened.