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 — 🐛 Bug Report: MCP Tool JSON Parsing Errors on OpenCode (GLM-4.7) · Issue #8102 · anomalyco/opencode

🐛 Bug Report: MCP Tool JSON Parsing Errors on OpenCode (GLM-4.7) #8102

New issue
Copy link
New issue
Copy link
Closed as not planned
Closed as not planned
🐛 Bug Report: MCP Tool JSON Parsing Errors on OpenCode (GLM-4.7)#8102
Copy link
Assignees
thdxr

Description

@izzamoe
izzamoe
opened on Jan 13, 2026
Issue body actions

Description

Summary

When using MCP generator tools with GLM-4.7 in OpenCode, the model frequently produces invalid JSON arguments for MCP tool calls, causing repeated JSON parsing failed errors.
The same MCP server + model works correctly on other clients (e.g. RooCode, KiloCode).

This leads to:

  • Tool call failures
  • Infinite retry loops
  • Model “giving up” mid-task

Environment

  • Client: OpenCode

  • Model: GLM-4.7

  • MCP Server: Custom local MCP (generator tools)

  • Other clients tested (working):

    • RooCode ✅
    • KiloCode ✅
  • OS: Linux

  • Transport: MCP stdio / local


Affected Tools (examples)

  • generator-mcp_get_relations
  • generator-mcp_update_database
  • generator-mcp_execute_dynamic_api

Example Errors

❌ Invalid JSON (unquoted value)

Invalid input for tool generator-mcp_get_relations: JSON parsing failed
Text: {"table_name":"t_purchase_invoice","direction":both}
Error: Unexpected identifier "both"

❌ UUID not quoted

Invalid input for tool generator-mcp_execute_dynamic_api: JSON parsing failed
Text:
{"id":cf56856a-5b7f-47aa-9877-8f45d1d2c1ee,"method":"GET","model":"m_customer","operation":"detail"}
Error: Unexpected identifier "cf56856a"

❌ Repeated failure even after self-correction

{"source":api}
Error: Unexpected identifier "api"

Model attempts to “fix” it but keeps emitting invalid JSON.


Expected Behavior

  • OpenCode should enforce or validate strict JSON serialization before MCP tool execution
  • Model output for tool arguments should be auto-corrected or rejected before sending to MCP
  • Same behavior consistency as RooCode / KiloCode

Actual Behavior

  • Model emits JS-like objects, not valid JSON
  • No client-side sanitation or retry with correction
  • Tool execution fails repeatedly
  • Model eventually halts or degrades output quality

Why This Is a Client Bug (Not MCP / Model)

  • ✅ Same MCP server works perfectly on other clients
  • ✅ Same prompts + GLM-4.7 succeed elsewhere
  • ❌ Only OpenCode shows persistent JSON formatting failures

This strongly suggests:

OpenCode does not strictly constrain / validate tool call JSON before execution


Suggested Fixes

  1. Strict JSON validation layer before MCP call
  2. Auto-quoting for enums / strings when schema requires it
  3. Reject & re-prompt model when tool args are invalid (instead of executing)
  4. Optional: show tool schema-aware JSON fixer

Impact

  • Makes MCP unusable for complex workflows
  • Breaks parallel tool execution
  • Causes model instability and task abandonment

Reproducibility

  • 🔁 Reproducible ~80–90% of the time on OpenCode
  • ❌ Not reproducible on RooCode / KiloCode

Closing

This issue significantly affects MCP reliability in OpenCode.
Please prioritize JSON argument enforcement for tool calls.

Thanks 🙏

Plugins

No response

OpenCode version

1.1.15

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

Terminal

No response

Reacted by Chindriș Mihai - Alexandru, José Manuel Domínguez, Alex Kassios, AndreiB and Di Huynh

Activity

  1. izzamoe
    added
    bugSomething isn't working
    on Jan 13, 2026
  2. github-actions
    assigned
    thdxr
    on Jan 13, 2026
  3. cieske commented on Feb 3, 2026

    @cieske
    cieske
    on Feb 3, 2026
    More actions

    I also meet JSON parsing error when using opencode + GLM-4.7 flash(served locally) and remove speculative-config-related option from serving guide solve the issues. Maybe not exactly the same situation due to the different providers, just leave it at that.

    Reacted by Jihyeon Gim, Chindriș Mihai - Alexandru, Eliott Jacopin and sure
  4. LittleCoinCoin commented on Feb 20, 2026

    @LittleCoinCoin
    LittleCoinCoin
    on Feb 20, 2026
    More actions

    @cieske's suggestion to remove speculative-config also fixed it for a vllm self-hosted GLM-4.7-Flash.

    Reacted by Busy6ee
  5. simonjhy commented on Mar 11, 2026

    @simonjhy
    simonjhy
    on Mar 11, 2026
    More actions

    I meet this issue even I did not set speculative-config parameter

  6. thdxr
    removed
    bugSomething isn't working
    on May 3, 2026
  7. github-actions commented on Jul 6, 2026

    @github-actions
    github-actionsBot
    on Jul 6, 2026 – with GitHub Actions
    Contributor
    More actions

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

  8. github-actions
    closed this as not plannedon Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @thdxr
    thdxr

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.