Bug: Apidog MCP Server Crashes OpenCode #1375

Closed
opened 2026-02-16 17:30:41 -05:00 by yindo · 6 comments
Owner

Originally created by @danielbenjie on GitHub (Aug 19, 2025).

Originally assigned to: @adamdotdevin on GitHub.

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/v2@v2.0.0-beta.4/tea.go:1139 +0x10c
github.com/charmbracelet/bubbletea/v2.(*Program).handleCommands.func1.1.1()
        /home/runner/go/pkg/mod/github.com/charmbracelet/bubbletea/v2@v2.0.0-beta.4/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/v2@v2.0.0-beta.4/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/v2@v2.0.0-beta.4/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

Originally created by @danielbenjie on GitHub (Aug 19, 2025). Originally assigned to: @adamdotdevin on GitHub. When using the [Apidog MCP](https://docs.apidog.com/apidog-mcp-server) for one of their clients, Purespectrum ([docs](https://documentation.purespectrum.com/create-survey-14788870e0)), the opencode crashes. ```json { "$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: ```bash Look at the PureSpectrum documentation to see how to create a survey ``` Used this to get the debug logs, see attached file: ```bash opencode --print-logs --log-level DEBUG ``` Main Error: ```bash 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/v2@v2.0.0-beta.4/tea.go:1139 +0x10c github.com/charmbracelet/bubbletea/v2.(*Program).handleCommands.func1.1.1() /home/runner/go/pkg/mod/github.com/charmbracelet/bubbletea/v2@v2.0.0-beta.4/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/v2@v2.0.0-beta.4/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/v2@v2.0.0-beta.4/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 ```
yindo closed this issue 2026-02-16 17:30:41 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Aug 19, 2025):

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

  • #2059: Very similar panic with interface conversion error in the TUI rendering system
  • #1878: MCP client crashes and connection issues that require restarts
  • #1720: MCP server configuration causing crashes and fatal errors
  • #1725: MCP server compatibility issues causing API errors

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.

@github-actions[bot] commented on GitHub (Aug 19, 2025): This issue might be a duplicate of existing issues. Please check: - #2059: Very similar panic with interface conversion error in the TUI rendering system - #1878: MCP client crashes and connection issues that require restarts - #1720: MCP server configuration causing crashes and fatal errors - #1725: MCP server compatibility issues causing API errors 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.
Author
Owner

@rekram1-node commented on GitHub (Aug 19, 2025):

looks like this may be a tui issue

@rekram1-node commented on GitHub (Aug 19, 2025): looks like this may be a tui issue
Author
Owner

@danielbenjie commented on GitHub (Aug 19, 2025):

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

@danielbenjie commented on GitHub (Aug 19, 2025): @rekram1-node I asked OpenCode, that does look like a tui issue: see code [here](https://github.com/sst/opencode/blob/dev/packages/tui/internal/components/chat/message.go?plain=1#L906) > 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.
Author
Owner

@rekram1-node commented on GitHub (Aug 19, 2025):

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

@rekram1-node commented on GitHub (Aug 19, 2025): /opencode please create PR addressing issue above^^ add a casting check to fix it like: value, ok := util.Relative(value.(string)); ok {...}
Author
Owner

@opencode-agent[bot] commented on GitHub (Aug 19, 2025):

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

@opencode-agent[bot] commented on GitHub (Aug 19, 2025): ## ✅ 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. <a href="https://opencode.ai/s/nfnG42LS"><img width="200" alt="Adding%20type%20check%20for%20MCP%20server%20tool%20response%20par" src="https://social-cards.sst.dev/opencode-share/QWRkaW5nIHR5cGUgY2hlY2sgZm9yIE1DUCBzZXJ2ZXIgdG9vbCByZXNwb25zZSBwYXJzaW5n.png?model=anthropic/claude-sonnet-4-20250514&version=0.5.7&id=nfnG42LS" /></a> [opencode session](https://opencode.ai/s/nfnG42LS)&nbsp;&nbsp;|&nbsp;&nbsp;[github run](/sst/opencode/actions/runs/17078570889)
Author
Owner

@rekram1-node commented on GitHub (Aug 19, 2025):

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

@rekram1-node commented on GitHub (Aug 19, 2025): This should be fixed in next release diagnosed by `opencode` and fixed with `opencode` too hahaha
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1375