GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — MCP tool wrapper sends mutually exclusive optional parameters · Issue #27527 · anomalyco/opencode

MCP tool wrapper sends mutually exclusive optional parameters #27527

New issue
Copy link
New issue
Copy link
Closed
Closed
MCP tool wrapper sends mutually exclusive optional parameters#27527
Copy link
Assignees
jlongster

Description

@nixianixia
nixianixia
opened on May 14, 2026
Issue body actions

Summary

OpenCode appears to serialize MCP tool arguments in a way that sends mutually exclusive optional fields together, even when only one mode should be used. This breaks MCP tools whose schemas expose multiple mutually exclusive call modes.

I reproduced this on OpenCode 1.14.50 with a local stdio MCP server.

Environment

  • OpenCode: 1.14.50
  • MCP transport: local stdio
  • OS: Linux

Reproduction

Use an MCP tool that exposes two mutually exclusive edit modes:

  1. Full replacement:
    • content
  2. Search-and-replace:
    • old_text
    • new_text
    • optional replace_all

When attempting full replacement through OpenCode's generated tool wrapper, the tool fails with:

Cannot provide both 'content' (full replace) and 'old_text'/'new_text' (search-and-replace). Use one mode or the other.

When attempting search-and-replace through OpenCode's generated tool wrapper, it also fails with the same error.

This suggests OpenCode is sending both content and old_text/new_text fields, likely with empty-string defaults, instead of omitting absent optional fields.

Additional Example

A similar issue occurs with a list/search tool that supports either:

  • titleSearch
  • titleRegex

but not both.

Calling it through OpenCode fails with:

Cannot provide both 'titleSearch' and 'titleRegex'. Use one or the other.

This happens even when no title filter is intended.

Control Test

Calling the same MCP server directly via raw JSON-RPC works when only the intended fields are sent.

For example, this kind of payload succeeds for full replacement:

{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "edit_document",
    "arguments": {
      "document": "test-document",
      "teamspace": "test-space",
      "title": "test-document",
      "content": "updated content"
    }
  },
  "id": 2
}

So the MCP server accepts the call when optional fields are omitted correctly.

Expected Behavior

OpenCode should omit optional MCP tool arguments that were not explicitly provided by the model/tool caller.

For mutually exclusive parameter groups, absent fields should not be serialized as empty strings or default values.

Actual Behavior

OpenCode appears to send all fields declared in the generated tool schema, including fields that should be absent, causing MCP servers to reject otherwise valid calls.

Impact

This breaks MCP tools that use mutually exclusive optional parameters or mode-based arguments. Some tools become unusable through OpenCode even though they work through direct MCP JSON-RPC.

Possible Workaround

A local plugin using tool.execute.before can likely delete empty-string optional arguments before execution, but this should not be required for normal MCP tool usage.

Activity

  1. github-actions
    assigned
    jlongster
    on May 14, 2026
  2. github-actions commented on May 14, 2026

    @github-actions
    github-actionsBot
    on May 14, 2026 – with GitHub Actions
    Contributor
    More actions

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

    • MCP tool schema optional fields become required in OpenCode (jira_add_comment) #20661: Same root cause — MCP optional fields (e.g. visibility, public) are serialized with empty/default values instead of being omitted, causing MCP server validation errors
    • [MCP] Schema validation fails for tools with multiple discriminated-union/nested-object parameters (e.g. obsidian-mcp-server patch_note, append_to_note) #26277: Related schema handling issue — OpenCode incorrectly flattens or mishandles complex MCP tool schemas (discriminated unions, nested objects), causing -32602 Invalid params errors

    If your issue is distinct from the above, feel free to clarify the differences.

  3. nixianixia commented on May 14, 2026

    @nixianixia
    nixianixia
    on May 14, 2026
    Author
    More actions

    Closing after further testing showed this is caused by provider-specific tool-call argument generation with GPT models, not a confirmed OpenCode bug.

  4. nixianixia
    closed this as completedon May 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @jlongster
    jlongster

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.