[BUG] tools[21].function.name': string too long. Expected a string with maximum length 64, but got a string with length 65 instead. #2323

Open
opened 2026-02-16 17:35:07 -05:00 by yindo · 8 comments
Owner

Originally created by @Racle on GitHub (Oct 29, 2025).

Description

Tool name is too long. This was taken from logs.
Opencode does not send any error message to TUI, it just will die silently.
And it also do not process any more request when tool name is too long, even when unrelated to MCP servers.

Might be related to this: https://github.com/sst/opencode/blob/a0541ba57aebcdb21c36540f0efd8a251fdbc2b8/packages/opencode/src/mcp/index.ts#L207-L209

This generates tool name from mcp name + tool name.
It would be better to set that max size to 64 characters to fix this issue.

Same issue was in https://github.com/ravitemer/mcphub.nvim/pull/243 and limiting tool length fixed it. In difference, mcphub.nvim throws an error to user.

OpenCode version

0.15.23

Steps to reproduce

  1. Change MCP server to long name (60+ characters)
  2. Try to use opencode with any MCP server
  3. Opencode will just die silently after running "generating" for second

Screenshot and/or share link

Image

Operating System

Pop_os 22.04.

Terminal

Kitty, tmux, nvim with sidekick.nvim

Originally created by @Racle on GitHub (Oct 29, 2025). ### Description Tool name is too long. This was taken from logs. Opencode does not send any error message to TUI, it just will die silently. And it also do not process any more request when tool name is too long, even when unrelated to MCP servers. Might be related to this: https://github.com/sst/opencode/blob/a0541ba57aebcdb21c36540f0efd8a251fdbc2b8/packages/opencode/src/mcp/index.ts#L207-L209 This generates tool name from `mcp name` + `tool name`. It would be better to set that max size to 64 characters to fix this issue. Same issue was in https://github.com/ravitemer/mcphub.nvim/pull/243 and limiting tool length fixed it. In difference, mcphub.nvim throws an error to user. ### OpenCode version 0.15.23 ### Steps to reproduce 1. Change MCP server to long name (60+ characters) 2. Try to use opencode with _any_ MCP server 3. Opencode will just die silently after running "generating" for second ### Screenshot and/or share link <img width="432" height="233" alt="Image" src="https://github.com/user-attachments/assets/c2fdbe7b-db37-4598-88b8-57fc50bc6f3b" /> ### Operating System Pop_os 22.04. ### Terminal Kitty, tmux, nvim with sidekick.nvim
yindo added the bug label 2026-02-16 17:35:07 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Oct 29, 2025):

This issue might be a duplicate of existing issues. Please check:

  • #3245: Similar MCP tool naming issue with string pattern validation - Slack MCP server fails with 'String should match pattern' error for tool names
  • #3354: MCP tools failing with 'String should match pattern' error when using Anthropic Sonnet 4.5 and MCP servers

Both issues involve MCP server tool naming validation problems, though #3523 specifically mentions the 64-character length limit while the others mention pattern validation. The root cause appears related to how OpenCode generates tool names from MCP server names + tool names.

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Oct 29, 2025): This issue might be a duplicate of existing issues. Please check: - #3245: Similar MCP tool naming issue with string pattern validation - Slack MCP server fails with 'String should match pattern' error for tool names - #3354: MCP tools failing with 'String should match pattern' error when using Anthropic Sonnet 4.5 and MCP servers Both issues involve MCP server tool naming validation problems, though #3523 specifically mentions the 64-character length limit while the others mention pattern validation. The root cause appears related to how OpenCode generates tool names from MCP server names + tool names. Feel free to ignore if none of these address your specific case.
Author
Owner

@rekram1-node commented on GitHub (Oct 29, 2025):

What provider gave that error?

@rekram1-node commented on GitHub (Oct 29, 2025): What provider gave that error?
Author
Owner

@Racle commented on GitHub (Oct 29, 2025):

What provider gave that error?

Company internal MCP server. Tool names are generated and limited to ~50 characters.

@Racle commented on GitHub (Oct 29, 2025): > What provider gave that error? Company internal MCP server. Tool names are generated and limited to ~50 characters.
Author
Owner

@rekram1-node commented on GitHub (Oct 29, 2025):

@Racle but that error comes from an inference provider I thought, I don't think the ai sdk is throwing it (could be wrong tho)

What inference provider was it? Openai? Google?

@rekram1-node commented on GitHub (Oct 29, 2025): @Racle but that error comes from an inference provider I thought, I don't think the ai sdk is throwing it (could be wrong tho) What inference provider was it? Openai? Google?
Author
Owner

@Racle commented on GitHub (Oct 29, 2025):

@Racle but that error comes from an inference provider I thought, I don't think the ai sdk is throwing it (could be wrong tho)

What inference provider was it? Openai? Google?

Test MCP config what can be used to test this:

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "chrome-devtools-aaaaaaaaaaaaaaaaaaaaa": {
      "type": "local",
      "command": ["npx", "chrome-devtools-mcp@latest"]
    }
  }
}


I'm using GitHub Copilot GPT-4.1 as that is the only one I currently have access.

I see the error in opencode log files (running this as opencode --log-level DEBUG ), but terminal client just dies silently. There is no error message.

INFO  2025-10-29T16:10:59 +1ms service=session.prompt session=ses_5cf4368afffewe4wL4auBcU6OA type=error part
ERROR 2025-10-29T16:10:59 +1ms service=session.prompt session=ses_5cf4368afffewe4wL4auBcU6OA error=Invalid 'tools[29].function.name': string too long. Expected a string with maximum length 64, but got a string with length 65 instead. process

@Racle commented on GitHub (Oct 29, 2025): > [@Racle](https://github.com/Racle) but that error comes from an inference provider I thought, I don't think the ai sdk is throwing it (could be wrong tho) > > What inference provider was it? Openai? Google? Test MCP config what can be used to test this: ``` { "$schema": "https://opencode.ai/config.json", "mcp": { "chrome-devtools-aaaaaaaaaaaaaaaaaaaaa": { "type": "local", "command": ["npx", "chrome-devtools-mcp@latest"] } } } ``` I'm using `GitHub Copilot GPT-4.1` as that is the only one I currently have access. I see the error in opencode log files (running this as `opencode --log-level DEBUG `), but terminal client just dies silently. There is no error message. ``` INFO 2025-10-29T16:10:59 +1ms service=session.prompt session=ses_5cf4368afffewe4wL4auBcU6OA type=error part ERROR 2025-10-29T16:10:59 +1ms service=session.prompt session=ses_5cf4368afffewe4wL4auBcU6OA error=Invalid 'tools[29].function.name': string too long. Expected a string with maximum length 64, but got a string with length 65 instead. process ```
Author
Owner

@rekram1-node commented on GitHub (Oct 29, 2025):

good to know thanks!

@rekram1-node commented on GitHub (Oct 29, 2025): good to know thanks!
Author
Owner

@faizhasim commented on GitHub (Nov 13, 2025):

I encounter similar issues when using any of the gpt models (from copilot) and docker mcp enabled. Other models (claude/gemini 2.5 pro) works fine.

Image
@faizhasim commented on GitHub (Nov 13, 2025): I encounter similar issues when using any of the gpt models (from copilot) and docker mcp enabled. Other models (claude/gemini 2.5 pro) works fine. <img width="1047" height="78" alt="Image" src="https://github.com/user-attachments/assets/31dc9e6a-8247-4a7f-9757-0749a3b8b624" />
Author
Owner

@rekram1-node commented on GitHub (Nov 13, 2025):

Yeah if you are using too many tools they get upset, im not sure what we can do for u besides truncate the tools and give u an error or warning

@rekram1-node commented on GitHub (Nov 13, 2025): Yeah if you are using too many tools they get upset, im not sure what we can do for u besides truncate the tools and give u an error or warning
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#2323