Expand description
Composite tool middleware for fan-out to multiple backend tools.
Composite tools are virtual tools that do not exist on any single backend. When called, they fan out the request to multiple backend tools concurrently, aggregating all results into a single response. This is useful for cross-cutting operations like “search everything” or “health-check all backends.”
§How it works
The CompositeService intercepts two request types:
ListTools– appends the composite tool definitions to the response so clients discover them alongside regular backend tools.CallTool– if the tool name matches a composite, the same arguments are forwarded to every target tool concurrently usingtokio::JoinSet. Results from all targets are collected into a singleCallToolResultwhosecontentis the concatenation of all individual results. If any target fails, the aggregated result’sis_errorflag is set totrue, but successful results are still included.
All other request types pass through unchanged.
§Strategy
The strategy field controls execution order. Currently one strategy
is supported:
parallel(default) – all target tools execute concurrently viatokio::JoinSet. Results are returned in completion order.
§Configuration
Composite tools are defined at the top level in TOML, referencing namespaced tool names from any backend:
[[composite_tools]]
name = "search_all"
description = "Search across all knowledge sources"
tools = ["github/search", "jira/search", "docs/search"]
strategy = "parallel"Validation enforces that composite tool names are non-empty, unique, and reference at least one target tool.
§Middleware stack position
Composite tools are the outermost middleware in the request-processing
stack, applied after aliasing. This means composite tool names are not
subject to alias rewriting, but the target tools they reference are
resolved through the full middleware chain (including aliases, filters,
and validation). The ordering in proxy.rs:
- Request validation (
crate::validation) - Capability filtering (
crate::filter) - Search-mode filtering (
crate::filter) - Tool aliasing (
crate::alias) - Composite tools (this module)
Structs§
- Composite
Layer - Tower layer that produces a
CompositeService. - Composite
Service - Tower service that intercepts
ListToolsandCallToolrequests to support composite tool fan-out.