Repository navigation
feat(mcp): support attachment-backed broker queries for CallMcpWithQuery - #1309
Merged
Merged
Conversation
jhrozek
force-pushed
the
plan/callmcpwithquery-broker-support
branch
from
September 9, 2026 20:26
7c4d860 to
275e03b
Compare
Scope the fix to registering CallMcpWithQuery for broker-backed sessions and filtering results through the existing attachment and authorization path. Preserve direct-manager behavior and exclude engine lifecycle, permission, and persistence redesigns. Co-authored-by: mecatl <[email protected]>
Why: CallMcpWithQuery depended on the direct MCP manager, so broker-only sessions lacked the existing result-narrowing tool. Broker support must preserve session attachment authority and keep successful raw responses out of model history, events, and audit records. How: Register a session-bound query wrapper for eligible broker targets. Derive the same normalized native call for authorization and execution, reuse the attachment's frozen route and authorization gates, and apply bounded jq projection inside the concrete broker transport before returning. Validate jq and cancellation before invocation, and never retry a possibly delivered query. Keep the direct-manager path and tool schema unchanged. Add offline coverage for real Service registration, bounded projection, cancellation, attachment isolation, live and restarted authorization continuation, and direct-manager compatibility. Update architecture, public documentation, and acceptance evidence. Verified with task lint, task test, task docs, task api:check, task site:build, and the offline demo. Fixes #1304 Co-authored-by: mecatl <[email protected]>
…ation Update the callmcpwithquery-broker-support plan status now that the directing user has explicitly requested a PR: link tracking issue #1304, record the live kind/Keycloak/connector-gateway end-to-end verification (broker-only registration, attachment-routed lazy authorization, oversized-output handling), and note the known non-blocking error-message-flattening follow-up. Co-Authored-By: Claude Sonnet 5 <[email protected]>
…ht ADRs ADR 0319 was independently claimed by two other open PRs (#1238, #1278). Renumber this ADR to 0323, the next free number after main's highest (0322), to avoid a duplicate-number collision on merge. Co-Authored-By: Claude Sonnet 5 <[email protected]>
jhrozek
force-pushed
the
plan/callmcpwithquery-broker-support
branch
from
September 9, 2026 20:56
275e03b to
f62d79c
Compare
jhrozek
added a commit
that referenced
this pull request
Sep 9, 2026
…on rebuild Rebasing onto the newly-merged attachment-backed CallMcpWithQuery support (#1309) surfaced two problems in the rebased tree: - RefreshGrantedAuthorizationCatalogue's cyclomatic complexity exceeded the lint gate once merged with the surrounding code; split it into resolveGrantedBundle/buildRefreshedCatalogue/publishRefreshedCatalogue helpers with no behavior change. - continueGrantedAuthorizationLocked rebuilds the session engine from the attachment's exact catalogue tools after a granted authorization, which dropped the attachment-bound CallMcpWithQuery meta-tool that brokerTools normally adds alongside the catalogue. A parked CallMcpWithQuery call then resumed into a catalogue that no longer had it registered. Factor the addition into a shared withAttachmentQueryTool helper used by both brokerTools and the granted-authorization continuation path. Co-Authored-By: Claude Sonnet 5 <[email protected]>
jhrozek
added a commit
that referenced
this pull request
Sep 10, 2026
…on rebuild Rebasing onto the newly-merged attachment-backed CallMcpWithQuery support (#1309) surfaced two problems in the rebased tree: - RefreshGrantedAuthorizationCatalogue's cyclomatic complexity exceeded the lint gate once merged with the surrounding code; split it into resolveGrantedBundle/buildRefreshedCatalogue/publishRefreshedCatalogue helpers with no behavior change. - continueGrantedAuthorizationLocked rebuilds the session engine from the attachment's exact catalogue tools after a granted authorization, which dropped the attachment-bound CallMcpWithQuery meta-tool that brokerTools normally adds alongside the catalogue. A parked CallMcpWithQuery call then resumed into a catalogue that no longer had it registered. Factor the addition into a shared withAttachmentQueryTool helper used by both brokerTools and the granted-authorization continuation path. Co-Authored-By: Claude Sonnet 5 <[email protected]>
jhrozek
added a commit
that referenced
this pull request
Sep 10, 2026
…on rebuild Rebasing onto the newly-merged attachment-backed CallMcpWithQuery support (#1309) surfaced two problems in the rebased tree: - RefreshGrantedAuthorizationCatalogue's cyclomatic complexity exceeded the lint gate once merged with the surrounding code; split it into resolveGrantedBundle/buildRefreshedCatalogue/publishRefreshedCatalogue helpers with no behavior change. - continueGrantedAuthorizationLocked rebuilds the session engine from the attachment's exact catalogue tools after a granted authorization, which dropped the attachment-bound CallMcpWithQuery meta-tool that brokerTools normally adds alongside the catalogue. A parked CallMcpWithQuery call then resumed into a catalogue that no longer had it registered. Factor the addition into a shared withAttachmentQueryTool helper used by both brokerTools and the granted-authorization continuation path. Co-Authored-By: Claude Sonnet 5 <[email protected]>
jhrozek
added a commit
that referenced
this pull request
Sep 10, 2026
…on rebuild Rebasing onto the newly-merged attachment-backed CallMcpWithQuery support (#1309) surfaced two problems in the rebased tree: - RefreshGrantedAuthorizationCatalogue's cyclomatic complexity exceeded the lint gate once merged with the surrounding code; split it into resolveGrantedBundle/buildRefreshedCatalogue/publishRefreshedCatalogue helpers with no behavior change. - continueGrantedAuthorizationLocked rebuilds the session engine from the attachment's exact catalogue tools after a granted authorization, which dropped the attachment-bound CallMcpWithQuery meta-tool that brokerTools normally adds alongside the catalogue. A parked CallMcpWithQuery call then resumed into a catalogue that no longer had it registered. Factor the addition into a shared withAttachmentQueryTool helper used by both brokerTools and the granted-authorization continuation path. Co-Authored-By: Claude Sonnet 5 <[email protected]>
jbeda
added a commit
that referenced
this pull request
Sep 11, 2026
* commit 'cc6b16afbf7feec3e16451fdc590a3265fbf0c0b': docs: amend Shell diagnostic ownership (#1330) fix(mecatui): refresh status context on session continuation (#1328) fix(jsonlstore): preserve session saves with legacy lineage (#1327) test(sessiondebug): eliminate handle tampering flake (#1323) fix(agent): authorize structured subagent results (#1317) feat(mcp): support attachment-backed broker queries for CallMcpWithQuery (#1309) docs(agents): document full-gate timeout guidance (#1316) fix(server): let the stale-session sweep re-acquire a lost lease (#1302) feat(clientauth): headless Linux credential storage (#1291) chore(mcpbroker): trace protected call latency (#1314) # Conflicts: # docs/acceptance/canonical-shell-command-tool.md
jhrozek
added a commit
that referenced
this pull request
Sep 11, 2026
…on rebuild Rebasing onto the newly-merged attachment-backed CallMcpWithQuery support (#1309) surfaced two problems in the rebased tree: - RefreshGrantedAuthorizationCatalogue's cyclomatic complexity exceeded the lint gate once merged with the surrounding code; split it into resolveGrantedBundle/buildRefreshedCatalogue/publishRefreshedCatalogue helpers with no behavior change. - continueGrantedAuthorizationLocked rebuilds the session engine from the attachment's exact catalogue tools after a granted authorization, which dropped the attachment-bound CallMcpWithQuery meta-tool that brokerTools normally adds alongside the catalogue. A parked CallMcpWithQuery call then resumed into a catalogue that no longer had it registered. Factor the addition into a shared withAttachmentQueryTool helper used by both brokerTools and the granted-authorization continuation path. Co-Authored-By: Claude Sonnet 5 <[email protected]>
jhrozek
added a commit
that referenced
this pull request
Sep 11, 2026
…on rebuild Rebasing onto the newly-merged attachment-backed CallMcpWithQuery support (#1309) surfaced two problems in the rebased tree: - RefreshGrantedAuthorizationCatalogue's cyclomatic complexity exceeded the lint gate once merged with the surrounding code; split it into resolveGrantedBundle/buildRefreshedCatalogue/publishRefreshedCatalogue helpers with no behavior change. - continueGrantedAuthorizationLocked rebuilds the session engine from the attachment's exact catalogue tools after a granted authorization, which dropped the attachment-bound CallMcpWithQuery meta-tool that brokerTools normally adds alongside the catalogue. A parked CallMcpWithQuery call then resumed into a catalogue that no longer had it registered. Factor the addition into a shared withAttachmentQueryTool helper used by both brokerTools and the granted-authorization continuation path. Co-Authored-By: Claude Sonnet 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CallMcpWithQuerythrough the current session's existing MCP broker attachment for broker-backed targets, instead of only the direct/global MCP manager — fixes #1304: a broker-only session (no direct MCP configured) never got this tool registered at all, and even in a mixed session a broker-routed target bypassed the attachment's authorization/audit path entirely.Process note
This branch's acceptance plan (
docs/acceptance/callmcpwithquery-broker-support.md) records that the directing user explicitly waived the normal/to-acceptance-plan→/plan-orchestratespine for this implementation, and has now explicitly requested this PR. No merge is claimed — human review and merge remain required.Verification
-race(attachment-bound projection, authorization continuation across a live and a restarted host, isolation/foreign-session rejection, at-most-once/no-raw-result invariant, post-delivery failure bounding, broker-only factory registration, direct-manager compatibility, ADR-0234 authority-unchanged proof).task lint,task test(incl. standalone module checks),task docs,task api:check,task site:buildall green.CallMcpWithQueryis now registered where it previously was not (broker-only session, no direct MCP manager).CallMcpWithQuerywith a genuinely narrowing jq filter (keys) successfully returns the bounded projection where the direct call cannot.Known non-blocking follow-up
attachmentQueryTool.Executecurrently collapses every failure from the underlying tool call (a pre-transport replay-ledger rejection, a genuine transport failure, and an oversized-output rejection after a successful call) into one generic message ("target may have succeeded; automatic replay refused..."). Live-testing showed this is misleading specifically in the oversized-output case: the direct-call path already gives actionable guidance ("narrow your filter"), and the query wrapper should too. The underlying behavior is correct (nothing is silently truncated or replayed) — this is a message-quality issue, tracked in the acceptance plan's "Deferred decisions and known risks", not a blocker for this PR.Test plan
go test ./internal/adapter/mcpbroker/... ./internal/adapter/mcp/... ./internal/app/... -run 'CallMcpWithQueryBrokerSupport|Invariant_call_mcp_with_query|ADR_0234' -racetask lint && task testgo run ./cmd/mecademotask docs🤖 Generated with Claude Code