bug(mcp): madt_api_call returns no structured content when a jq or template filter is empty #836
Labels
No labels
breaking
bug
documentation
enhancement
epic
good first issue
help wanted
refactoring
resolution/duplicate
resolution/invalid
resolution/wontfix
security
severity/critical
severity/high
severity/low
severity/medium
status/abandoned
status/blocked
status/needs-decision
status/needs-info
status/needs-verification
testing
upstream
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
sixfold-space/madtea#836
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
madt_api_callfails with a protocol error whenever its response body is empty after filtering. A jq or template expression that matches nothing is the common trigger. The tool declares a JSON output schema, so the go-sdk rejects an empty structured result, and the caller sees a tool failure instead of an empty result.Steps to reproduce
Run a call whose jq expression matches nothing, against any endpoint that returns a normal body:
The endpoint returns a 200 with a non-empty array. The jq filter selects nothing.
Expected
An empty result. The CLI (
madtea api ... --jq ...) prints nothing and exits 0. The MCP tool should return a schema-valid empty result, for example{"result": ""}.Actual
The call reports a tool error. The error text names only the output schema. It gives no hint that an empty filter result is the cause.
Why it happens
internal/service/api/call.go:144applies jq. On no matches,applyJQ(internal/service/api/output.go:29) returns an empty string with no error, soCallreturnsCallResult{Body: []byte(""), Filtered: true}.internal/mcp/tools_api.go:81testslen(result.Body) == 0. Both empty-body branches, the tip-absent return at line 83 and the tip-present return at line 85, return anilstructured value.madt_api_calldeclares a JSON output schema (internal/mcp/output_schema.go:200). The go-sdk requires structured content for a tool that declares one, so anilstructured value is rejected with the error above.The same path triggers on any empty body. A 204 response hits it. A
type=issuesfilter that leaves an empty array hits it too.Scope
madt_api_callonly. The CLI renders the empty body fine, because it has no output-schema contract.Fix direction
madt_api_callis the raw passthrough escape hatch, and its JSON output schema is the declared design, so the fix stays inside that schema rather than dropping it. The empty-body branches inapiCallshould return a schema-valid empty result, an emptyresultstring or an empty JSON value, rather thannil. The built-in-command tip should ride as an added text block on top of that valid structured result, as it already does on the non-empty path.Acceptance criteria
madt_api_callwhose jq or template filter matches nothing returns a schema-valid result such as{"result": ""}, not a "did not return structured content" error.Related
Distinct from #153 and #181, which cover non-2xx error bodies. This is a 2xx response with an empty post-filter body.
Environment
357ee888.