jsonrpc: rename / type_apply_batch / diff_before_after still reject JSON-string args (#226 workaround only covers union params)
Symptom
#226 made tools/call tolerate clients that send an object/array parameter as a
JSON-encoded string, and #534 refined when that decoding is allowed to happen.
The workaround only lives in the union branch of JsonRpcRegistry._call, so
tools whose batch parameter is not a union still fail exactly like before:
Invalid params: batch expected dict, got strScanning every @tool parameter on main (4e4b855) for a TypedDict/dict/list
annotation, 56 are unions (covered) and 3 are not:
| file | tool | parameter |
|---|---|---|
api_modify.py:403 |
rename |
batch: RenameBatch |
api_types.py:1037 |
type_apply_batch |
batch: TypeApplyBatch |
api_composite.py:453 |
diff_before_after |
action_args: dict |
So set_comments works when the model stringifies items, but rename does not,
even though both take the same kind of object.
Minimal repro
No IDA needed — this uses the same in-process harness as tests/. Save as
_repro.py in the repo root and run it:
import pathlib
import sys
from typing import TypedDict
sys.path.insert(0, "src")
sys.path.insert(0, "tests")
from _mcp_spec_support import McpServer
class RenameBatch(TypedDict, total=False):
functions: list
srv = McpServer("repro")
@srv.tool
def rename(batch: RenameBatch) -> str:
"""Same shape as api_modify.rename(self, batch: RenameBatch)."""
return f"ok:{batch}"
for label, arguments in (
("dict ", {"batch": {"functions": [{"addr": "0x100", "name": "main"}]}}),
("string ", {"batch": '{"functions": [{"addr": "0x100", "name": "main"}]}'}),
):
resp = srv.registry.dispatch(
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {"name": "rename", "arguments": arguments},
}
)
result = resp["result"]
state = "REJECTED" if result.get("isError") else "accepted"
print(f"batch as {label}-> {state}: {result['content'][0]['text']}")Output on 4e4b855:
batch as dict -> accepted: "ok:{'functions': [{'addr': '0x100', 'name': 'main'}]}"
batch as string -> REJECTED: Invalid params: batch expected dict, got strtests/test_jsonrpc_union_params.py only exercises the union shapes
(list[str] | str, list[dict] | dict), which is why the gap is invisible to the
current suite.
Authorship disclosure
This report was written by an AI agent. The repro above was executed by the agent on
base commit 4e4b855 with the command shown, and the output is copied from that run.
Source: mrexodia/ida-pro-mcp