Skip to content

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

Closed

Description

@eddienubes

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

Activity

  1. github-actions commented on Oct 22, 2025

    @github-actions
    Contributor

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

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

  2. self-assigned this
    on Oct 22, 2025
  3. rekram1-node commented on Oct 22, 2025

    @rekram1-node
    Contributor

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

  4. eddienubes commented on Oct 22, 2025

    @eddienubes
    ContributorAuthor

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

  5. rekram1-node commented on Oct 22, 2025

    @rekram1-node
    Contributor

    @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

  6. eddienubes commented on Oct 25, 2025

    @eddienubes
    ContributorAuthor

    @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?

  7. rekram1-node commented on Oct 25, 2025

    @rekram1-node
    Contributor

    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

  8. bientavu commented on Oct 31, 2025

    @bientavu

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions