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:
1 parent
31883edc09
commit
a818ace83c
5 files changed
+257
-1
No files matched your search
@@ -328,6 +328,47 @@
|
||||
"name": "get_screenshot",
|
||||
"description": "截取指定在线主机的一帧画面,返回 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 里回报实际源矩形与缩放比例。",
|
||||
"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)。超出虚拟桌面的部分会被裁剪。",
|
||||
@@ -722,6 +763,18 @@
|
||||
"name": "terminal_exec",
|
||||
"description": "在已打开的持久会话中执行一条命令,或轮询取回正在运行的命令输出。带 command 时执行并在 timeout_ms 内等待;等待超时返回 done:false 与已产生的部分输出,会话不销毁(命令仍在远端运行)。session_id 可省略:自动复用该主机已有的持久会话,没有就隐式打开一个(结果里有 session_id 与 reused),不必先 terminal_open。不带 command、只传 session_id 时进入轮询模式:继续等待并取回增量输出,直到 done:true(此时有 exit_code)。命令不受白名单约束。PTY 会话(新 Windows 客户端 ConPTY / Linux 与新版 Android 的 POSIX PTY)下可用管道 | 与 && / || 串联,退出码取整条管道/串联,适合「ls -1 | wc -l」这类先过滤再回传的用法;不要用后台执行符 &(POSIX)或换行。老非 PTY Windows 客户端仍不支持 & 与 |,请拆成多条调用。",
|
||||
"inputSchema": {
|
||||
"anyOf": [
|
||||
{
|
||||
"required": [
|
||||
"command"
|
||||
]
|
||||
},
|
||||
{
|
||||
"required": [
|
||||
"session_id"
|
||||
]
|
||||
}
|
||||
],
|
||||
"properties": {
|
||||
"command": {
|
||||
"description": "要执行的命令(完整 shell,不受白名单约束)。省略时进入轮询模式:不执行新命令,只等待并取回当前会话的增量输出(上一条命令超时后用这个方式继续取)。PTY 会话(Windows ConPTY / Linux PTY)下可用管道 | 与 && / || 串联,退出码取整条管道/串联;不要用后台执行符 &(POSIX)或换行。老非 PTY 客户端仍不支持 & 与 |,请拆成多条调用。Linux 下通过 POSIX shell 执行,可用 ; 串联且退出码取最后一条命令",
|
||||
|
||||
Reference in new issue
Block a user