fix(mcp): 修复结果语义丢失、错误误判与生命周期回收#195
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Collaborator
|
[adapter.go:122]这里的 schema 归一化过头了。现在只要 type 不是 "object",就会直接把 properties 清空;这会把那些“没写 type 但已经有合法 properties”的 MCP tool 也错误降成无参数工具,导致原本的参数语义丢失。 |
Collaborator
Author
|
修了 |
Collaborator
Author
当前逻辑确实会把 type 缺失但 properties 合法的 schema 清空,把工具误降成“无参数工具”,影响真实调用语义 |
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.
变更背景
修复 MCP 主链路中的 4 个关键问题:
isError=true但空内容被错误回退为ok主要改动
internal/tools/mcp/stdio_client.godecodeCallResult,新增decodeCallContent/decodeCallContentItemisError=true且空内容时不再回退成功语义internal/tools/registry.goisError=true时返回错误,禁止空内容回退okinternal/tools/mcp/registry.goUnregisterServer增加 client 关闭流程(closeable client)internal/app/mcp_bootstrap.gointernal/tools/mcp/adapter.goensureObjectSchema强制归一为合法 object schema测试
internal/tools/mcp/stdio_client_test.gointernal/tools/mcp/registry_test.gointernal/tools/mcp/adapter_test.gointernal/tools/registry_test.gointernal/app/bootstrap_test.gogo test ./internal/app ./internal/tools ./internal/tools/mcp -count=1go test ./... -count=1Closes #194