Repository navigation
feat(mcp): finish the per-config connection lookups (#5701) - #5817
Conversation
`connections::connect` resolves per-config via `host::for_config`, while the by-server-id lookups read the process-global `host::try_service`. A host that connects through the facade could never see the connection it just made. `main` is already midway through the answer: `all_connected_tools_for_config` and `disconnect_for_config` both exist, and `disconnect_for_config`'s own docs describe this exact trap. Neither was present at `523ef352a`, the revision the issue was written against, which is why the issue reads it as one odd function out of eight rather than as a migration with two of seven done. This finishes it — the same shape, next to each ambient counterpart: connected_overview_for_config server_tools_for_config is_connected_for_config auth_hint_for_config last_error_for_config Additive, so nothing existing changes signature and no caller has to move. Each `Err` arm logs the workspace-resolution failure instead of folding it silently into `false` / `None` / `Vec::new()`, which is the issue's second ask: "the service is not up" and "the server is not connected" should not be indistinguishable. `server_tools_for_config` breaks the mechanical `_for_config` suffix on purpose: `tools_for_config` would sit directly below `all_connected_tools_for_config` and read as its every-server sibling. Test: `per_config_lookups_see_a_per_config_connection` opens two workspaces so `try_service` has no honest answer, connects through the facade in one, and asserts the per-config lookups see it and that the other workspace does not. Verified discriminating — reimplementing one variant over `try_service` turns it red. `cargo test --features mcp --test mcp_registry_e2e` 17 passed. `cargo check --lib --features mcp` and `--no-default-features` both clean.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe MCP connections facade adds five configuration-scoped lookup functions. Each resolves the host for the supplied workspace configuration and returns a benign default when no host exists. An end-to-end test verifies isolation between two workspaces. ChangesPer-config MCP connection lookups
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to This PR adds per-configuration connection lookups without changing existing APIs or caller behavior, with focused test coverage and successful validation; no actionable merge-blocking risk remains. Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Linked Issues checkExplanation The PR adds five per-config lookup functions and verifies workspace isolation, but it does not add a per-config equivalent for Resolution Add
Warning Your free Security trial is over. An organization admin can upgrade to Advanced for continuous pull request security review or dismiss this notice. Comment |
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
How this change flows2 changed behaviours across 6 relationships. 5 surrounding behaviours are shown (60 graph nodes walked). 42 further behaviours left out to keep the diagram readable. flowchart LR
n0["connections<br/>changed"]:::changed
n1["supervisor_skips_a_disabled_server<br/>changed"]:::changed
n2["host"]:::impacted
n3["make_installed_server"]:::impacted
n4["fresh_workspace_config"]:::impacted
n5["format"]:::impacted
n6["format_connected_mcp_block"]:::impacted
n1 -->|calls| n2
n1 -->|calls| n3
n1 -->|calls| n4
n3 -->|calls| n5
n3 -->|tests| n5
n6 -->|uses| n0
classDef changed fill:#0d4429,stroke:#238636,color:#e6edf3
classDef impacted fill:#161b22,stroke:#6e7681,color:#c9d1d9
classDef flagged fill:#5a1e02,stroke:#d93f0b,color:#ffffff
classDef blocking fill:#67060c,stroke:#f85149,color:#ffffff
Green: changed behaviour. Grey: surrounding behaviour. Arrows name the call, use, implementation, or test relationship. Orange: has findings. Red: has a finding that blocks the merge. |
|
Maintainer review (merge-readiness sweep). Disclosure first: earlier in this sweep I ran GitHub's "Update branch" on this PR, which pushed a merge commit — Assessment: sound, and I could not find anything wrong with itVerified against current
The State
Nothing needed from you that I can see. |
M3gA-Mind
left a comment
There was a problem hiding this comment.
Approved after a maintainer-side verification pass.
Verified on the current head: MERGEABLE against main, zero failing and zero pending required checks, and no unresolved, non-outdated review threads.
This is one of two required approvals; a second maintainer review is still needed before merge.
…er-config MCP failure lookups Two gaps found by auditing merged PRs for e2e coverage. tinyhumansai#5796 — the tinyagents bump brought RunLimits::max_model_call_ms, and nothing exercised it. The only assertion that existed pins that the number is copied into the policy, which the wiring line satisfies without any call ever being bounded. agent_harness_e2e now stalls a scripted model call past the ceiling and asserts the turn is cut off within seconds rather than held to the hour-long turn deadline — the elapsed time is the discriminator, because the terminal event maps both bounds onto one turn_timeout copy. tinyhumansai#5817 — per_config_lookups_see_a_per_config_connection covered the success side. auth_hint_for_config had no reference in any e2e lane, and last_error_for_config was only asserted to be None after a clean connect. mcp_registry_e2e now drives a 401 from a wiremock endpoint and asserts both surface the reason for the workspace that hit it, and neither leaks to a second workspace. Both tests are revert-checked: reverting the arming line in agent/tinyagents/mod_part_01.rs makes the first fail on its chat_error assertion, and routing the two lookups back through host::try_service makes the second fail on its credential_required assertion. Adds a delay_ms entry to the scripted upstream so a completion can be withheld; no production code is touched.
…ons-for-config\n\nfeat(mcp): finish the per-config connection lookups (tinyhumansai#5701)\n
Closes #5701.
The issue is right, but
mainhas movedconnections::connectresolves per-config throughhost::for_configwhile the by-server-id lookups read the process-globalhost::try_service, so a host that connects through the facade can never see the connection it just made.Since the issue was filed,
mainalready grew two of the answers:all_connected_tools_for_configdisconnect_for_confige34226cb0, 2026-08-23 16:35 UTCThe issue was opened at 19:14 UTC the same day, ~2h40m after
disconnect_for_configlanded, and listsdisconnectamong the broken seven. That is not a mistake on the reporter's part — I checkedgit cat-file -p 523ef352a:src/openhuman/mcp/registry/mod.rs, the revision the issue names, and neither_for_configvariant exists there. The issue is accurate for its base and stale againstmain.That changes what needs doing. This is not one odd function out of eight; it is a migration with two of seven done.
disconnect_for_config's own doc comment already spells out the trap the issue spends a page reconstructing:So the three resolutions the issue proposes — take a config on all eight, take a
&McpHoston all eight, or makeconnectread the global — are all breaking, while the maintainers had already chosen a fourth: add variants, leave the ambient forms alone. This follows that.What this adds
Five functions, each next to its ambient counterpart, same shape as the two that exist:
Purely additive — no existing signature changes and no caller moves.
Each
Errarm now logs the workspace-resolution failure rather than folding it silently intofalse/None/Vec::new(). That is the issue's second ask: "the service is not up" and "the server is not connected" are different facts and currently share a return value.One naming judgment call for you to overrule if you disagree:
server_tools_for_config, nottools_for_config. The mechanical suffix would puttools_for_configdirectly beneathall_connected_tools_for_config, where it reads as that function's every-server sibling rather than as the one-server form.Test
per_config_lookups_see_a_per_config_connectionintests/mcp_registry_e2e.rs.Making it discriminate was the interesting part. With a single workspace open,
try_servicehappily returns that lone host, so a wrong implementation routed through the global would still pass. The test therefore opens two workspaces first and asserts the precondition explicitly:With two open and no default,
try_servicerefuses to guess — which is the state an embedder holding its own per-config service is in permanently. It then connects through the facade in workspace A and asserts the per-config lookups see it, that workspace B does not, and thatdisconnect_for_configdrops it.Verified red against the wrong implementation: reimplementing
is_connected_for_configovertry_service()(the way the ambient form does) turns it red —panicked at tests/mcp_registry_e2e.rs:723: the workspace that connected must see its own connection.Verification
cargo test --features mcp --test mcp_registry_e2e— 17 passed.cargo check --lib --features mcp— clean.cargo check --lib --no-default-features— clean.stub.rsdeliberately gets no additions: its docs say it mirrors only the surface always-compiled callers depend on, and these five have no such caller yet. The disabled build is the drift catcher and it is green.cargo fmt --all— clean.Summary by CodeRabbit
New Features
Bug Fixes