Fix(mcp): make declared schemas match what the handlers return
Several tool contracts disagreed with the runtime shape, which forces an
agent to guess instead of following outputSchema:
- get_server_status returned {"status": {...}} while outputSchema has the
fields at top level; return the status object directly.
- get_screenshot description claimed structuredContent.image carries the
base64 data; it only carries mimeType/width/height/bytes, the bytes are
in the content image block.
- host_control_service accepted service_name silently, but not in schema;
document the alias and add anyOf [{required:[name]},{required:[service_name]}]
so a call missing both fails at validation, not at execution.
- kill_network_connection dry_run invented dryRun/connection fields absent
from ActionOutputSchema; use the shared BuildDryRunResult shape.
- search_file outputSchema left files.items untyped; declare
path/name/modified/dir/size and the paging fields it already emits.
- chat_* id hints still named the removed list_online_hosts/search_hosts.
tools.json hunks keep the live-dump key order (alphabetical inside schemas),
tools_minimal.json is regenerated, and mcp_smoke.ps1 now reads the flat
structuredContent. Debug build green; check_platform_table, gen_go_tools
--check and go test ./... pass.
Co-Authored-By: deepseek-flash
This commit is contained in:
1 parent
5e012019ba
commit
292c3191dc
7 files changed
+93
-23
No files matched your search
@@ -2235,7 +2235,7 @@ std::string BuildToolsListResult(const Json::Value& id) {
|
||||
{
|
||||
Json::Value tool(Json::objectValue);
|
||||
tool["name"] = "get_screenshot";
|
||||
tool["description"] = u8"截取指定在线主机的一帧画面,返回 base64 编码的 JPEG 图片(image 对象含 mimeType/data/width/height)。支持 Windows 与带 X11 桌面的 Linux 客户端(能力位 CLIENT_CAP_SCREEN_PREVIEW),主连接 RPC、一次性返回。Android 客户端用无障碍服务 takeScreenshot 抓屏(Android 11+ 且开启无障碍服务,此时登录会声明该能力位;只支持 mode=screen)。mode 可选 screen(默认,整虚拟桌面)/region(指定矩形)/window(指定 hwnd)/monitor(指定显示器);后三种默认按源尺寸 1:1 原生分辨率抓取(适合 OCR/视觉读字),需要较新的 Windows 客户端(CLIENT_CAP_SCREEN_REGION,否则 -32005),结果在 structuredContent.capture 里回报实际源矩形与缩放比例。";
|
||||
tool["description"] = u8"截取指定在线主机的一帧画面,返回 base64 编码的 JPEG 图片:图片在 content 的 image 块(data 为 base64,mimeType=image/jpeg);structuredContent.image 只有 mimeType/width/height/bytes 元数据,不含图片数据。支持 Windows 与带 X11 桌面的 Linux 客户端(能力位 CLIENT_CAP_SCREEN_PREVIEW),主连接 RPC、一次性返回。Android 客户端用无障碍服务 takeScreenshot 抓屏(Android 11+ 且开启无障碍服务,此时登录会声明该能力位;只支持 mode=screen)。mode 可选 screen(默认,整虚拟桌面)/region(指定矩形)/window(指定 hwnd)/monitor(指定显示器);后三种默认按源尺寸 1:1 原生分辨率抓取(适合 OCR/视觉读字),需要较新的 Windows 客户端(CLIENT_CAP_SCREEN_REGION,否则 -32005),结果在 structuredContent.capture 里回报实际源矩形与缩放比例。";
|
||||
|
||||
tool["inputSchema"] = BuildGetScreenshotInputSchema(); // { id } 必填 + max_width 可选
|
||||
tool["outputSchema"] = BuildScreenshotOutputSchema();
|
||||
@@ -4585,9 +4585,9 @@ std::string BuildGetServerStatus(const Json::Value& id, CMy2015RemoteDlg* parent
|
||||
status["blocked_auth_ips"] = blockedIps;
|
||||
|
||||
Json::Value result(Json::objectValue);
|
||||
Json::Value structuredContent(Json::objectValue);
|
||||
structuredContent["status"] = status;
|
||||
result["structuredContent"] = structuredContent;
|
||||
// outputSchema 声明的就是顶层字段;不要再套一层 "status",否则按 schema 取字段
|
||||
// (structuredContent.version 等)的客户端拿不到任何东西。
|
||||
result["structuredContent"] = status;
|
||||
|
||||
std::string text = std::string(BRAND_APP_NAME) + " v" + VERSION_STR +
|
||||
std::string(u8",已运行 ") + std::to_string((long long)status["uptime_sec"].asInt64()) +
|
||||
@@ -10938,6 +10938,19 @@ Json::Value BuildSearchFileOutputSchema() {
|
||||
filesProp["type"] = "array";
|
||||
Json::Value items(Json::objectValue);
|
||||
items["type"] = "object";
|
||||
Json::Value itemProps(Json::objectValue);
|
||||
for (const char* f : { "path", "name", "modified" }) {
|
||||
Json::Value s(Json::objectValue);
|
||||
s["type"] = "string";
|
||||
itemProps[f] = s;
|
||||
}
|
||||
Json::Value dirProp(Json::objectValue);
|
||||
dirProp["type"] = "boolean";
|
||||
itemProps["dir"] = dirProp;
|
||||
Json::Value sizeProp(Json::objectValue);
|
||||
sizeProp["type"] = "integer";
|
||||
itemProps["size"] = sizeProp;
|
||||
items["properties"] = itemProps;
|
||||
filesProp["items"] = items;
|
||||
props["files"] = filesProp;
|
||||
Json::Value finProp(Json::objectValue);
|
||||
@@ -10946,6 +10959,9 @@ Json::Value BuildSearchFileOutputSchema() {
|
||||
Json::Value truncProp(Json::objectValue);
|
||||
truncProp["type"] = "boolean";
|
||||
props["truncated"] = truncProp;
|
||||
// 分页字段:BuildSearchFile 一直会带 total/totalAll/offset/limit/hasMore,
|
||||
// schema 补齐后客户端按输出契约取值才不会扑空。
|
||||
AppendPageOutputProps(props);
|
||||
Json::Value schema(Json::objectValue);
|
||||
schema["type"] = "object";
|
||||
schema["properties"] = props;
|
||||
|
||||
Reference in new issue
Block a user