Repository navigation
Conversation
Some OpenAI/Anthropic/Gemini-compatible endpoints validate tool schemas
at request registration time. Two constructs used here are rejected:
1. Root-level `$defs` referenced via `$ref: "#/$defs/..."`. Endpoints
that drop root `$defs` fail with:
"Pointer '/$defs/point' does not exist"
2. Union type arrays inside `items`, e.g. `items: { type: ["string",
"number"] }`. Strict endpoints fail with:
"field predicate failed: $type == Type.ARRAY"
Because a client may send all tools from all enabled MCP servers in one
batch, a single invalid schema can cause the entire request to fail.
Changes:
- server.mjs: inline `$ref: "#/$defs/point"` (3 uses in
drawio_create_diagram) and remove the now-unused root `$defs`.
- live-server.mjs, powerpoint-server.mjs: replace union `type` arrays
with `anyOf` in add_table `data` and add_chart `categories`.
Behavior is unchanged; only the emitted JSON Schema shape is adjusted.
Made-with: Proma
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
部分 OpenAI / Anthropic / Gemini 兼容端点会在请求注册阶段校验工具 schema。本仓库当前有两处构造会被拒绝,导致工具无法使用:
1. 根级
$defs+$ref引用server.mjs的drawio_create_diagram用$ref: "#/$defs/point"引用同一 schema 根部的定义。会丢弃根级$defs的端点报:2.
items中的联合类型数组live-server.mjs与powerpoint-server.mjs中,add_table的data和add_chart的categories使用:严格端点(如 Gemini)对
items.type做枚举字段谓词校验,联合类型数组会失败:影响为什么会被放大
MCP 客户端(如 Proma)会把所有已启用服务器的全部工具放进同一次请求。因此只要其中一个工具的 schema 非法,整批请求会被拒绝,用户侧表现为 agent 模式整体不可用,而非单个工具报错。
改动
scripts/server.mjs$ref: "#/$defs/point"就地内联,删除已无用的根级$defsscripts/live-server.mjsadd_table.data、add_chart.categories:联合type数组 →anyOfscripts/powerpoint-server.mjs语义不变,只调整发出的 JSON Schema 形状:
anyOf是 JSON Schema 标准构造,Anthropic / OpenAI / Gemini 系端点均可接受;内联$ref等价于原有定义。验证
在本机(Node v22.13.1)确认:
node --check三个文件均通过tools/list:$defs引用与联合类型数组均为 0 处$ref或联合类型items改动前后均未触及工具的执行逻辑,仅 schema 描述层。
参考
同类问题在其它项目中的处理方式(仅供参考,未逐行核对):
fix(openai): normalize tool schemas before OpenAI / Responses / Codex requests— fix(openai): normalize tool schemas before OpenAI / Responses / Codex requests aaif-goose/goose#8474fix(openai): flatten top-level anyOf/oneOf/allOf in Responses API tool schemas— fix(openai): flatten top-level anyOf/oneOf/allOf in Responses API tool schemas BerriAI/litellm#38792Made with Proma · GitHub