Skip to content

Bug: Apidog MCP Server Crashes OpenCode #2068

Closed

Description

@danielbenjie

When using the Apidog MCP for one of their clients, Purespectrum (docs), the opencode crashes.

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "PureSpectrum": {
      "type": "local",
      "enabled": true,
      "command": ["npx", "-y", "apidog-mcp-server@latest", "--site-id=748984"]
    }
  }
}

Prompt to use the MCP server:

Look at the PureSpectrum documentation to see how to create a survey

Used this to get the debug logs, see attached file:

opencode --print-logs --log-level DEBUG 

Main Error:

Caught panic:

interface conversion: interface {} is []interface {}, not string

Restoring terminal...

goroutine 384 [running]:
runtime/debug.Stack()
        /opt/hostedtoolcache/go/1.24.6/x64/src/runtime/debug/stack.go:26 +0x64
github.com/charmbracelet/bubbletea/v2.(*Program).recoverFromPanic(0x140001a1200, {0x102fd7a40, 0x140000b3d70})
        /home/runner/go/pkg/mod/github.com/charmbracelet/bubbletea/[email protected]/tea.go:1139 +0x10c
github.com/charmbracelet/bubbletea/v2.(*Program).handleCommands.func1.1.1()
        /home/runner/go/pkg/mod/github.com/charmbracelet/bubbletea/[email protected]/tea.go:479 +0x40
panic({0x102fd7a40?, 0x140000b3d70?})
        /opt/hostedtoolcache/go/1.24.6/x64/src/runtime/panic.go:792 +0x124
github.com/sst/opencode/internal/components/chat.renderArgs(0x140009a21b0, {0x1400237aa3e, 0x4})
        /home/runner/work/opencode/opencode/packages/tui/internal/components/chat/message.go:906 +0x620
github.com/sst/opencode/internal/components/chat.renderToolTitle({{0x1400003cb07, 0x1e}, {0x1400003cbd5, 0x1e}, {0x1400003cb34, 0x1e}, {0x1400003cb61, 0x1e}, {{0x1400237aa2b, 0x7}, ...}, ...}, ...)
        /home/runner/work/opencode/opencode/packages/tui/internal/components/chat/message.go:810 +0xf9c
github.com/sst/opencode/internal/components/chat.renderToolDetails(_, {{0x1400003cb07, 0x1e}, {0x1400003cbd5, 0x1e}, {0x1400003cb34, 0x1e}, {0x1400003cb61, 0x1e}, {{0x1400237aa2b, ...}, ...}, ...}, ...)
        /home/runner/work/opencode/opencode/packages/tui/internal/components/chat/message.go:714 +0x2518
github.com/sst/opencode/internal/components/chat.(*messagesComponent).renderView.func2()
        /home/runner/work/opencode/opencode/packages/tui/internal/components/chat/messages.go:581 +0x3914
github.com/charmbracelet/bubbletea/v2.(*Program).handleCommands.func1.1()
        /home/runner/go/pkg/mod/github.com/charmbracelet/bubbletea/[email protected]/tea.go:484 +0x64
created by github.com/charmbracelet/bubbletea/v2.(*Program).handleCommands.func1 in goroutine 110
        /home/runner/go/pkg/mod/github.com/charmbracelet/bubbletea/[email protected]/tea.go:474 +0x10c

INFO  2025-08-19T15:10:37 +2ms service=bus type=* unsubscribing
INFO  2025-08-19T15:10:37 +0ms service=server event disconnected
INFO  2025-08-19T15:10:37 +3ms service=session session=ses_73d1e62d4ffezF9mQlf0GFv7NQ type=tool-result part
INFO  2025-08-19T15:10:37 +0ms service=app name=lsp shutdown
INFO  2025-08-19T15:10:37 +1ms service=app name=session shutdown
INFO  2025-08-19T15:10:37 +0ms service=app name=mcp shutdown
INFO  2025-08-19T15:10:37 +21ms service=bus type=storage.write publishing
INFO  2025-08-19T15:10:37 +0ms service=bus type=message.part.updated publishing
INFO  2025-08-19T15:10:37 +1ms service=session session=ses_73d1e62d4ffezF9mQlf0GFv7NQ type=abort part
INFO  2025-08-19T15:10:37 +0ms service=session session=ses_73d1e62d4ffezF9mQlf0GFv7NQ type=abort unhandled
INFO  2025-08-19T15:10:37 +5ms service=bus type=storage.write publishing
INFO  2025-08-19T15:10:37 +0ms service=bus type=message.updated publishing
INFO  2025-08-19T15:10:37 +2ms service=session session=ses_73d1e62d4ffezF9mQlf0GFv7NQ sessionID=ses_73d1e62d4ffezF9mQlf0GFv7NQ unlocking
INFO  2025-08-19T15:10:37 +0ms service=bus type=session.idle publishing
INFO  2025-08-19T15:10:37 +1ms service=server duration=15183 response

Activity

  1. github-actions commented on Aug 19, 2025

    @github-actions
    Contributor

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

    The interface conversion panic in #2059 appears to be nearly identical to your issue, both occurring in the chat rendering system when handling tool responses from MCP servers.

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

  2. rekram1-node commented on Aug 19, 2025

    @rekram1-node
    Collaborator

    looks like this may be a tui issue

  3. danielbenjie commented on Aug 19, 2025

    @danielbenjie
    Author

    @rekram1-node
    I asked OpenCode, that does look like a tui issue:
    see code here

    The crash occurs in packages/tui/internal/components/chat/message.go:906 where opencode assumes the path parameter from MCP tools is always a string, but PureSpectrum's MCP server sends it as an array ([]interface{}).

    Root Cause: Line 906: value = util.Relative(value.(string)) fails when value is []interface{} instead of string.

    Fix Required: Replace the unsafe type assertion with a type switch to handle both strings and arrays gracefully. The code should check the actual type and convert accordingly.

  4. rekram1-node commented on Aug 19, 2025

    @rekram1-node
    Collaborator

    /opencode please create PR addressing issue above^^ add a casting check to fix it like:
    value, ok := util.Relative(value.(string)); ok {...}

  5. opencode-agent commented on Aug 19, 2025

    @opencode-agent
    Contributor

    ✅ Fixed the MCP Server Crash

    I've successfully implemented the fix for the interface conversion panic and pushed it to a new branch. The changes:

    Fix Applied: packages/tui/internal/components/chat/message.go:905-907

    • Replaced unsafe value.(string) with safe type checking: if strValue, ok := value.(string); ok
    • Prevents crashes when MCP servers send path parameters as arrays instead of strings

    Branch: opencode/issue2068-20250819183358

    Create PR: Visit https://github.com/sst/opencode/pull/new/opencode/issue2068-20250819183358

    The fix gracefully handles cases where MCP tools send path parameters as different types (like arrays from Apidog's PureSpectrum client), preventing the crash while maintaining functionality for string paths.

    Adding%20type%20check%20for%20MCP%20server%20tool%20response%20par
    opencode session  |  github run

  6. rekram1-node commented on Aug 19, 2025

    @rekram1-node
    Collaborator

    This should be fixed in next release diagnosed by opencode and fixed with opencode too hahaha

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

Metadata

Metadata

Assignees

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