Skip to content

MCP servers with outputSchema in tools/list break tool discovery #21591

@claygeo

Description

@claygeo

Bug Description

When an MCP server returns outputSchema in its tools/list response, opencode shows "Failed to get tools" and the server becomes unusable. The outputSchema field is valid per MCP spec (protocol version 2025-06-18).

Steps to Reproduce

  1. Configure an MCP server that returns tools with outputSchema in the tool definition
  2. Start opencode
  3. Observe "Failed to get tools" for that server

Expected Behavior

Tools should load successfully. opencode doesn't use outputSchema — it only reads inputSchema in convertMcpTool().

Actual Behavior

The entire listTools() call fails because cacheToolMetadata() calls AjvJsonSchemaValidator.getValidator(tool.outputSchema), and if AJV can't compile the schema (unsupported keywords, complex schemas), it throws an unhandled error.

Root Cause

AjvJsonSchemaValidator.getValidator() in the MCP SDK calls ajv.compile(schema) with no try/catch. The error propagates through listTools() → caught by opencode's defs() → returns undefined → "Failed to get tools".

Environment

  • opencode version: latest (dev branch)
  • MCP SDK: v1.27.1
  • OS: any

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions