Issue: MCP Client disconnects immediately if Server returns a Prompt with an empty name {"name":""} #8348

Open
opened 2026-02-16 18:09:44 -05:00 by yindo · 1 comment
Owner

Originally created by @mhuber88 on GitHub (Feb 2, 2026).

Originally assigned to: @rekram1-node on GitHub.

Description

Description

The OpenCode MCP client appears to have strict validation on the prompts/list capability. If an MCP server returns a prompt object containing an empty string for the name ({"name": ""}), OpenCode throws an error and immediately closes the socket/connection with MCP error -32000.

This prevents the use of servers that may have minor schema bugs (like the official reportportal/mcp-server:1.0.0) but are otherwise functional.

Observed Behavior
The connection status shows "Connected" briefly, then logs an error and disconnects. The tools never populate.

Log Output:
ERROR service=mcp clientName=reportportal promptName= error=MCP error -32000: Connection closed failed to get prompt from MCP server

Expected Behavior
OpenCode should:

Detect the invalid name property.

Log a warning (e.g., Skipping invalid prompt: name is empty).

Continue processing the rest of the valid prompts/tools in the list.

Keep the connection alive.

Context / Environment
OS: macOS

Problematic Server: reportportal/mcp-server:1.0.0 (Docker)

Attempted Workaround

We attempted to strip the invalid JSON stream using a middleware/proxy wrapper (e.g. perl substitution) to remove the empty prompt entry. However, this proved unstable.

We were ultimately forced to downgrade the OpenCode CLI to a previous version to bypass this strict validation crash, suggesting this may be a regression in the latest CLI release.

Plugins

No response

OpenCode version

most recent version

Steps to reproduce

Reproduction Steps

  1. Create a dummy MCP server script (bad-server.sh) that mimics the ReportPortal v1.0.0 behavior:
#!/bin/bash
# Simple mock to reproduce the crash
while read line; do
  # 1. Handshake
  if [[ "$line" == *"initialize"* ]]; then
    echo '{"jsonrpc":"2.0","id":1,"result":{"protocolVersion":"2024-11-05","capabilities":{"prompts":{}},"serverInfo":{"name":"bug-repro","version":"1.0"}}}'
  fi
  # 2. OpenCode asks for prompts
  if [[ "$line" == *"prompts/list"* ]]; then
    # 3. Server returns a prompt with an empty name
    echo '{"jsonrpc":"2.0","id":2,"result":{"prompts":[{"name":"","description":"This crashes OpenCode"},{"name":"valid_prompt","description":"This should work"}]}}'
  fi
done
  1. Register this server in opencode.jsonc.

  2. Run opencode mcp list.

Screenshot and/or share link

No response

Operating System

macOS 26.2

Terminal

No response

Originally created by @mhuber88 on GitHub (Feb 2, 2026). Originally assigned to: @rekram1-node on GitHub. ### Description ### Description The OpenCode MCP client appears to have strict validation on the `prompts/list` capability. If an MCP server returns a prompt object containing an empty string for the name (`{"name": ""}`), OpenCode throws an error and immediately closes the socket/connection with `MCP error -32000`. This prevents the use of servers that may have minor schema bugs (like the official `reportportal/mcp-server:1.0.0`) but are otherwise functional. Observed Behavior The connection status shows "Connected" briefly, then logs an error and disconnects. The tools never populate. Log Output: `ERROR service=mcp clientName=reportportal promptName= error=MCP error -32000: Connection closed failed to get prompt from MCP server` Expected Behavior OpenCode should: Detect the invalid name property. Log a warning (e.g., Skipping invalid prompt: name is empty). Continue processing the rest of the valid prompts/tools in the list. Keep the connection alive. Context / Environment OS: macOS Problematic Server: reportportal/mcp-server:1.0.0 (Docker) ## Attempted Workaround We attempted to strip the invalid JSON stream using a middleware/proxy wrapper (e.g. perl substitution) to remove the empty prompt entry. However, this proved unstable. We were ultimately forced to downgrade the OpenCode CLI to a previous version to bypass this strict validation crash, suggesting this may be a regression in the latest CLI release. ### Plugins _No response_ ### OpenCode version most recent version ### Steps to reproduce ### Reproduction Steps 1. Create a dummy MCP server script (`bad-server.sh`) that mimics the ReportPortal v1.0.0 behavior: ```bash #!/bin/bash # Simple mock to reproduce the crash while read line; do # 1. Handshake if [[ "$line" == *"initialize"* ]]; then echo '{"jsonrpc":"2.0","id":1,"result":{"protocolVersion":"2024-11-05","capabilities":{"prompts":{}},"serverInfo":{"name":"bug-repro","version":"1.0"}}}' fi # 2. OpenCode asks for prompts if [[ "$line" == *"prompts/list"* ]]; then # 3. Server returns a prompt with an empty name echo '{"jsonrpc":"2.0","id":2,"result":{"prompts":[{"name":"","description":"This crashes OpenCode"},{"name":"valid_prompt","description":"This should work"}]}}' fi done ``` 2. Register this server in opencode.jsonc. 3. Run opencode mcp list. ### Screenshot and/or share link _No response_ ### Operating System macOS 26.2 ### Terminal _No response_
yindo added the bug label 2026-02-16 18:09:44 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Feb 2, 2026):

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

  • #9425: Remote MCP servers showing 'connected' but silently failing to register tools - relates to MCP connection/registration failures
  • #8920: MCP resources mimeType errors - relates to MCP schema validation and error handling
  • #2068: Apidog MCP Server crashes OpenCode - relates to MCP servers with schema issues causing crashes

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

@github-actions[bot] commented on GitHub (Feb 2, 2026): This issue might be a duplicate of existing issues. Please check: - #9425: Remote MCP servers showing 'connected' but silently failing to register tools - relates to MCP connection/registration failures - #8920: MCP resources mimeType errors - relates to MCP schema validation and error handling - #2068: Apidog MCP Server crashes OpenCode - relates to MCP servers with schema issues causing crashes Feel free to ignore if none of these address your specific case.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#8348