Fix(mcp): declare conditional tool arguments and surface probe headers

Several tools enforced argument requirements that existed only in prose,
so a model had to send a bad call to learn them. A new
AppendConditionalRequired helper emits allOf/if/then entries, and the
schemas now say:

- get_screenshot: mode=region needs width and height; mode=window needs
  hwnd. monitor keeps its default of 0.
- remote_keyboard: action=type needs text; key_down/key_up/key_press
  need key.
- remote_mouse: action=drag needs x2 and y2.
- terminal_exec: command or session_id, at least one (anyOf), matching the
  handler's -32602 when both are missing.

http_probe put the response headers only in structuredContent, which a
client that reads the text block never sees; Location, Set-Cookie and
Content-Type are exactly what a redirect or auth decision needs. The
text block now starts with a headers section, bounded to 4096 bytes and
1200 bytes per line, backing off to a UTF-8 boundary when a line has to
be cut. The full set stays in structuredContent.headers.

mcp/tools.json mirrors the schemas and tools_minimal.json is regenerated.
Verified against a fresh Debug build: verify_tools --live reports 49
tools identical.

Co-Authored-By: deepseek-flash
This commit is contained in:
yuanyuanxianganddeepseek-flash committed 2026-11-13 13:12:10 +01:00
1 parent 31883edc09
commit a818ace83c
5 files changed
+257 -1

No files matched your search

+117
View File
@@ -515,6 +515,47 @@
],
"impl": "mfc",
"inputSchema": {
"allOf": [
{
"if": {
"properties": {
"mode": {
"enum": [
"region"
]
}
},
"required": [
"mode"
]
},
"then": {
"required": [
"width",
"height"
]
}
},
{
"if": {
"properties": {
"mode": {
"enum": [
"window"
]
}
},
"required": [
"mode"
]
},
"then": {
"required": [
"hwnd"
]
}
}
],
"properties": {
"height": {
"description": "region 模式必填:矩形高度(像素,1~8192)。超出虚拟桌面的部分会被裁剪。",
@@ -1575,6 +1616,18 @@
],
"impl": "mfc",
"inputSchema": {
"anyOf": [
{
"required": [
"command"
]
},
{
"required": [
"session_id"
]
}
],
"properties": {
"command": {
"description": "要执行的命令(完整 shell,不受白名单约束)。省略时进入轮询模式:不执行新命令,只等待并取回当前会话的增量输出(上一条命令超时后用这个方式继续取)。PTY 会话(Windows ConPTY / Linux PTY)下可用管道 | 与 && / || 串联,退出码取整条管道/串联;不要用后台执行符 &(POSIX)或换行。老非 PTY 客户端仍不支持 & 与 |,请拆成多条调用。Linux 下通过 POSIX shell 执行,可用 ; 串联且退出码取最后一条命令",
@@ -1853,6 +1906,48 @@
],
"impl": "mfc",
"inputSchema": {
"allOf": [
{
"if": {
"properties": {
"action": {
"enum": [
"type"
]
}
},
"required": [
"action"
]
},
"then": {
"required": [
"text"
]
}
},
{
"if": {
"properties": {
"action": {
"enum": [
"key_down",
"key_up",
"key_press"
]
}
},
"required": [
"action"
]
},
"then": {
"required": [
"key"
]
}
}
],
"properties": {
"action": {
"description": "动作:key_down / key_up / key_press / type",
@@ -1937,6 +2032,28 @@
],
"impl": "mfc",
"inputSchema": {
"allOf": [
{
"if": {
"properties": {
"action": {
"enum": [
"drag"
]
}
},
"required": [
"action"
]
},
"then": {
"required": [
"x2",
"y2"
]
}
}
],
"properties": {
"action": {
"description": "动作:move / down / up / click / right_click / middle_click / drag / scroll",