mirror of
https://github.com/open-webui/computer.git
synced 2026-11-05 01:17:24 +00:00
[GH-ISSUE #87] MCP tool schema conversion drops top-level $defs while preserving $ref, producing invalid OpenAI tool schemas #41
Labels
No labels
enhancement
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
open-webui/computer#41
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @hackadelic on GitHub (Jun 30, 2026).
Original GitHub issue: https://github.com/open-webui/computer/issues/87
Description
CPTR's MCP tool conversion drops top-level JSON Schema fields such as
$defswhile preserving properties that reference those definitions with$ref.This produces invalid OpenAI-compatible tool schemas. Backends that resolve or compile tool schemas then reject the entire chat request before inference begins.
I encountered this with CPTR 0.7.1 using Crawl4AI MCP tools and an OpenAI-compatible LiteLLM → llama-swap → llama.cpp backend.
Environment
CPTR version:
0.7.1CPTR host: Linux
MCP tools: Crawl4AI, among others
OpenAI-compatible route:
Model:
ls5090/unsloth/qwen3.6-27b-mtpThe model and llama-swap route are not the source of the malformed schemas. The failure occurs while the backend attempts to convert the tool JSON Schema into its tool-call parser, before model inference starts.
Actual error
Malformed schemas sent by CPTR
For the Crawl4AI Markdown tool, CPTR sends a property containing:
However, the surrounding
parametersschema contains no$defsobject definingFilterType.A second tool independently has the same problem:
Again, the surrounding schema contains no
$defs.HookConfig.This shows that it is not one malformed MCP tool definition. Multiple MCP schemas lose their root definitions during CPTR's conversion.
Apparent root cause
In:
MCPClient.list_tool_specs()currently creates a new reduced parameter schema:This preserves nested
$refvalues because they are insideproperties, but discards the top-level$defsobject those references depend on.It also drops any other root-level JSON Schema keywords, including potentially:
$schema$id$defsdefinitionsallOfoneOfanyOfadditionalPropertiespatternPropertiesdependentSchemasunevaluatedPropertiesAn MCP
inputSchemais already a JSON Schema document and should not be reconstructed by selecting onlypropertiesandrequired.Expected behavior
CPTR should preserve the complete MCP
tool.inputSchemawhen converting it to an OpenAI-compatible function definition.A schema such as:
should retain both:
and:
Suggested fix
Preserve the complete input schema instead of copying only two fields.
For example:
A smaller change would be:
with suitable validation/default handling.
Minimal regression test
Create a mocked MCP tool with this
inputSchema:After
list_tool_specs(), assert:It would also be useful to verify preservation of another root keyword such as:
Steps to reproduce
inputSchemauses$defsand a local$ref.but the parent
parametersobject no longer contains:Impact
Any MCP server using valid JSON Schema references can make all model requests fail before inference.
This is especially likely with schemas generated by Pydantic, which commonly place reusable models and enums under
$defs.The issue is backend-independent in principle: any OpenAI-compatible provider that validates, dereferences, or compiles the transmitted schemas may reject them.
Backends that silently ignore unresolved schema references might appear to work, which can hide the problem.
Workaround
Locally changing CPTR to preserve the complete
tool.inputSchemaresolves the malformed-schema portion of the request.Removing the affected MCP tools or stripping
$refvalues is not a good permanent workaround because it discards valid schema information and weakens tool validation.Security note
I have intentionally not attached the complete raw chat request because it includes private conversation content and credentials. The relevant sanitized tool-schema excerpts and backend error are included above.
@tjbck commented on GitHub (Jun 30, 2026):
Should be addressed!