Make tool failures actionable with suggestions and scope hints.

Unregistered tools now suggest close matches; MCP insufficient_scope is rewritten with fallbacks so ops agents stop blind-retrying SQL without sql:query.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-08-10 22:42:37 +08:00
parent 229e8b1368
commit d245e463c0
6 changed files with 159 additions and 4 deletions

View file

@ -127,6 +127,9 @@ class _McpBoundTool:
return {"ok": False, "error_code": "mcp_runtime_invalid_payload", "error": "invalid_response"}
if "ok" not in res:
res["ok"] = False
from runtime.tools.tool_error_hints import enrich_mcp_scope_error
res = enrich_mcp_scope_error(res)
if tool_name == "listCliTargets" and res.get("ok") is not False and cache_key:
_set_list_cli_cache(cache_key, res)
res = dict(res)