[mcp] Can't submit a message using Anthropic Sonnet 4.5 and MCP tools due to "String should match pattern" #2225

Closed
opened 2026-02-16 17:34:44 -05:00 by yindo · 7 comments
Owner

Originally created by @eddienubes on GitHub (Oct 22, 2025).

Originally assigned to: @rekram1-node on GitHub.

Description

An error is thrown sending a message.
AI_APICallError: tools.11.custom.name: String should match pattern '^[a-zA-Z0-9_-]{1,128}$'

OpenCode version

0.15.13

Steps to reproduce

Prerequisites

MCP Configuration

 "mcp": {
    "atlassian/mcp-server": {
      "type": "local",
      "command": [
        "npx",
        "-y",
        "mcp-remote",
        "https://mcp.atlassian.com/v1/sse"
      ],
      "enabled": true
    }
 }
  1. opencode
  2. ask anything

Screenshot and/or share link

Image

Operating System

macOS 15.6.1

Terminal

kitty

Originally created by @eddienubes on GitHub (Oct 22, 2025). Originally assigned to: @rekram1-node on GitHub. ### Description An error is thrown sending a message. `AI_APICallError: tools.11.custom.name: String should match pattern '^[a-zA-Z0-9_-]{1,128}$'` ### OpenCode version 0.15.13 ### Steps to reproduce ## Prerequisites **MCP Configuration** ```json "mcp": { "atlassian/mcp-server": { "type": "local", "command": [ "npx", "-y", "mcp-remote", "https://mcp.atlassian.com/v1/sse" ], "enabled": true } } ``` 1. `opencode` 2. ask anything ### Screenshot and/or share link <img width="2356" height="1200" alt="Image" src="https://github.com/user-attachments/assets/a8229368-c1d5-4908-9573-f48c54531a84" /> ### Operating System macOS 15.6.1 ### Terminal kitty
yindo added the bug label 2026-02-16 17:34:44 -05:00
yindo closed this issue 2026-02-16 17:34:45 -05:00
Author
Owner

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

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

  • #3245: Slack MCP server request fails with AI_APICallError: tools.11.custom.name: String should match pattern (exact same error message with MCP tool name validation)

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

@github-actions[bot] commented on GitHub (Oct 22, 2025): This issue might be a duplicate of existing issues. Please check: - #3245: Slack MCP server request fails with AI_APICallError: tools.11.custom.name: String should match pattern (exact same error message with MCP tool name validation) Feel free to ignore if none of these address your specific case.
Author
Owner

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

basically we need to sanitize all mcp server tools per provider to adjust their schemas to be compliant

@rekram1-node commented on GitHub (Oct 22, 2025): basically we need to sanitize all mcp server tools per provider to adjust their schemas to be compliant
Author
Owner

@eddienubes commented on GitHub (Oct 22, 2025):

@rekram1-node does sanitization need to be different for each provider? (assuming that's what per provider means)

@eddienubes commented on GitHub (Oct 22, 2025): @rekram1-node does sanitization need to be different for each provider? (assuming that's what `per provider` means)
Author
Owner

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

@eddienubes well only to a point, an example of this is that google gemini has much more strict json schema than openai does, so for gemini models we need to do X, but for anthropic we need to do Y, etc

So not literally every provider but some of the large ones have different rules

@rekram1-node commented on GitHub (Oct 22, 2025): @eddienubes well only to a point, an example of this is that google gemini has much more strict json schema than openai does, so for gemini models we need to do X, but for anthropic we need to do Y, etc So not literally every provider but some of the large ones have different rules
Author
Owner

@eddienubes commented on GitHub (Oct 25, 2025):

@rekram1-node hiya! I can volunteer implementing char escaping for major providers such as google, anthropic and others that require special treatment. Is there anything I need to consider before jumpstarting?

@eddienubes commented on GitHub (Oct 25, 2025): @rekram1-node hiya! I can volunteer implementing char escaping for major providers such as google, anthropic and others that require special treatment. Is there anything I need to consider before jumpstarting?
Author
Owner

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

Thanks @eddienubes that'd be awesome. I will give you some reference files:

transform.ts has schema function that currently does nothing but we should add a case for github-copilot provider here I believe, and then we need to define some transformation for the tool schemas to map to a github copilot compatible format.

transform.ts: https://github.com/sst/opencode/blob/ae62bc8b1fce194ae99a05251ed4bf85e38acc32/packages/opencode/src/provider/transform.ts#L157

Function is used here:
https://github.com/sst/opencode/blob/ae62bc8b1fce194ae99a05251ed4bf85e38acc32/packages/opencode/src/session/prompt.ts#L520

@rekram1-node commented on GitHub (Oct 25, 2025): Thanks @eddienubes that'd be awesome. I will give you some reference files: transform.ts has `schema` function that currently does nothing but we should add a case for `github-copilot` provider here I believe, and then we need to define some transformation for the tool schemas to map to a github copilot compatible format. transform.ts: https://github.com/sst/opencode/blob/ae62bc8b1fce194ae99a05251ed4bf85e38acc32/packages/opencode/src/provider/transform.ts#L157 Function is used here: https://github.com/sst/opencode/blob/ae62bc8b1fce194ae99a05251ed4bf85e38acc32/packages/opencode/src/session/prompt.ts#L520
Author
Owner

@bientavu commented on GitHub (Oct 31, 2025):

Hello guys, same issue on my side, voting for this fix 👍

@bientavu commented on GitHub (Oct 31, 2025): Hello guys, same issue on my side, voting for this fix 👍
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#2225