Skip to content

MCP tool schema resolution: RecursionError on circular schema references #16899

@mkovalyshev-madbox

Description

@mkovalyshev-madbox

Description

After updating opencode from a pre-1.2.24 version to 1.2.24, the DataHub MCP server (and potentially other MCP servers with complex schemas) causes a RecursionError: maximum recursion depth exceeded when resolving JSON schema references.

Environment

  • Opencode version: 1.2.24
  • Platform: macOS (darwin)
  • Installation method: Binary distribution (via curl -fsSL https://opencode.ai/install | bash)
  • DataHub MCP version: mcp-server-datahub@0.5.2 (installed via uvx)
  • DataHub GMS version: 1.2.0.1 (non-cloud/self-hosted)

Configuration

// ~/.config/opencode/opencode.jsonc
{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "datahub": {
      "type": "local",
      "command": ["/Users/***/.local/bin/uvx", "mcp-server-datahub@latest"],
      "environment": {
        "DATAHUB_GMS_URL": "https://datahub.***.**/api/gms",
        "DATAHUB_GMS_TOKEN": "***"
      }
    }
  }
}

Expected behavior

The DataHub MCP should initialize successfully and provide 6 tools for querying datasets, schemas, lineage, etc. This worked correctly in opencode versions prior to March 9, 2024 (16:47).

Actual behavior

Opencode crashes with a RecursionError when processing the DataHub MCP tool schemas:

ERROR 2026-03-10T14:19:49 +3ms service=session.processor error=Error resolving schema reference '#/$defs/_And': RecursionError('maximum recursion depth exceeded') stack="AI_APICallError: Error resolving schema reference '#/$defs/_And': RecursionError('maximum recursion depth exceeded')
    at <anonymous> (../../node_modules/.bun/@ai-sdk+provider-utils@3.0.20+d6123d32214422cb/node_modules/@ai-sdk/provider-utils/dist/index.mjs:936:18)
    at processTicksAndRejections (native:7:39)" process

Analysis

The error occurs in the AI SDK's schema resolution layer (@ai-sdk/provider-utils), suggesting a recent change in how circular JSON Schema references are handled
The DataHub MCP server's tool schemas use complex nested _And type definitions for boolean query filters. These schemas have been stable for months and haven't changed between the working and non-working opencode versions. The regression is in opencode's schema resolution logic

Key observations:

  • DataHub MCP successfully registers 6 tools (toolCount=6)
  • The error occurs during the session processor's tool resolution phase
  • The schema reference #/$defs/_And suggests a recursive definition that the AI SDK now fails to resolve
  • The same MCP server version worked yesterday with an earlier opencode binary

Plugins

No response

OpenCode version

1.2.24

Steps to reproduce

  1. Install opencode 1.2.24
  2. Configure DataHub MCP server as shown above
  3. Start opencode in a project directory
  4. Observe the crash when the session processor tries to resolve tools

Screenshot and/or share link

No response

Operating System

macOS 26.3

Terminal

Kitty

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcoreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions