Skip to content

Commit 43652ea

Browse files
committed
test(meta-tools): guard registry/descriptor parity for built-in tools
Add an integration test asserting the registered meta-tools and the Tool Optimization built-in descriptor stay in lockstep — same tool names and same write flags, both directions. The descriptor is the single source of truth the desktop shelf renders and per-tool toggles read from, so drift would surface a tool the gateway won''t dispatch (or hide one it will). Also pins mcpmux_search_tools as present and read-only. Signed-off-by: Mohammod Al Amin Ashik <maa.ashik00@gmail.com>
1 parent a2f3ac9 commit 43652ea

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

tests/rust/tests/integration/meta_tools.rs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,50 @@ async fn bind_current_workspace_emits_workspace_binding_changed() {
690690
);
691691
}
692692

693+
/// The Tool Optimization built-in descriptor (`builtin_servers()`) is the
694+
/// single source of truth the desktop UI renders and per-tool toggles read
695+
/// from. It must stay in lockstep with the tools the gateway actually
696+
/// registers — otherwise the shelf shows a tool the gateway won't dispatch
697+
/// (or hides one it will). Guards both directions, including write flags.
698+
#[tokio::test(flavor = "multi_thread")]
699+
async fn builtin_descriptor_matches_registered_meta_tools() {
700+
use std::collections::BTreeMap;
701+
702+
let f = Fixture::new().await;
703+
704+
// name -> is_write, from what the gateway advertises (writes carry the
705+
// destructive_hint annotation).
706+
let registered: BTreeMap<String, bool> = f
707+
.registry
708+
.list_as_tools()
709+
.iter()
710+
.map(|t| {
711+
let is_write = t
712+
.annotations
713+
.as_ref()
714+
.and_then(|a| a.destructive_hint)
715+
.unwrap_or(false);
716+
(t.name.to_string(), is_write)
717+
})
718+
.collect();
719+
720+
let descriptor = mcpmux_core::builtin_server(TOOL_OPTIMIZATION_SERVER_ID)
721+
.expect("Tool Optimization descriptor exists");
722+
let described: BTreeMap<String, bool> = descriptor
723+
.tools
724+
.iter()
725+
.map(|t| (t.name.to_string(), t.write))
726+
.collect();
727+
728+
assert_eq!(
729+
registered, described,
730+
"registered meta-tools and the Tool Optimization descriptor drifted \
731+
(name set or write flags differ)"
732+
);
733+
// Sanity: the new search tool is present and read-only.
734+
assert_eq!(described.get("mcpmux_search_tools"), Some(&false));
735+
}
736+
693737
#[tokio::test(flavor = "multi_thread")]
694738
async fn invalid_feature_set_argument_rejected() {
695739
let f = Fixture::new().await;

0 commit comments

Comments
 (0)