From c29d2289d0fe7b2c3dca2dc1faaa4517b2ca9a48 Mon Sep 17 00:00:00 2001 From: Jakub Zych Date: Fri, 23 Oct 2026 13:33:24 +0200 Subject: [PATCH] fix(pier): a tools/call without arguments or with null arguments is an empty object - MCP's tools/call arguments are optional; pier validated a JSON null against the input schema and refused every call of a tool without required input that an agent sent without arguments - found by plan 19.7-05's TestDispatch --- modules/pier/dispatch.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/pier/dispatch.go b/modules/pier/dispatch.go index 6353eb6d..d741125b 100644 --- a/modules/pier/dispatch.go +++ b/modules/pier/dispatch.go @@ -69,7 +69,9 @@ func (d *dispatcher) call(ctx context.Context, id Identity, info callInfo, t *to } func (d *dispatcher) run(ctx context.Context, id Identity, info callInfo, t *tool, raw json.RawMessage) (*mcp.CallToolResult, int) { - if len(bytes.TrimSpace(raw)) == 0 { + // tools/call may omit arguments (or send null) for a tool without + // required input; both mean an empty object. + if trimmed := bytes.TrimSpace(raw); len(trimmed) == 0 || bytes.Equal(trimmed, []byte("null")) { raw = json.RawMessage("{}") } var parts map[string]json.RawMessage