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

+33
View File
@@ -446,6 +446,39 @@ void MakeIdOrIdsRequired(Json::Value& schema) {
schema["anyOf"] = anyOf;
}
void AppendConditionalRequired(Json::Value& schema, const char* prop,
std::initializer_list<const char*> values,
std::initializer_list<const char*> fields) {
Json::Value cond(Json::objectValue);
Json::Value ifSchema(Json::objectValue);
Json::Value reqProp(Json::arrayValue);
reqProp.append(prop);
ifSchema["required"] = reqProp;
if (values.size() > 0) {
Json::Value enums(Json::arrayValue);
for (const char* v : values)
enums.append(v);
Json::Value when(Json::objectValue);
when["enum"] = enums;
Json::Value props(Json::objectValue);
props[prop] = when;
ifSchema["properties"] = props;
}
cond["if"] = ifSchema;
Json::Value thenSchema(Json::objectValue);
Json::Value reqFields(Json::arrayValue);
for (const char* f : fields)
reqFields.append(f);
thenSchema["required"] = reqFields;
cond["then"] = thenSchema;
if (!schema.isMember("allOf") || !schema["allOf"].isArray())
schema["allOf"] = Json::Value(Json::arrayValue);
schema["allOf"].append(cond);
}
std::string PageSummary(const PageWindow& w, const char* unit) {
std::string s = std::string(u8"共 ") + std::to_string(w.total) + std::string(u8" ") + unit;
if (w.total == 0) return s + std::string(u8"。");