Convert flat runtime params back to YAML. MCP gets readable nested params when the flat keys can be losslessly split. Non-MCP protocols keep flat keys only for lossless serialization; generic JSON-RPC validation rejects params matchers before enforcement.
(
protocol: &str,
params: BTreeMap<String, QueryMatcherDef>,
)
| 423 | // only for lossless serialization; generic JSON-RPC validation rejects params |
| 424 | // matchers before enforcement. |
| 425 | fn flat_params_to_def( |
| 426 | protocol: &str, |
| 427 | params: BTreeMap<String, QueryMatcherDef>, |
| 428 | ) -> BTreeMap<String, ParamMatcherDef> { |
| 429 | let flat = params.into_iter().collect::<Vec<_>>(); |
| 430 | // MCP uses nested YAML for readability. Non-MCP protocols keep the flat |
| 431 | // form for lossless serialization of existing proto data only. |
| 432 | if !is_mcp_protocol(protocol) { |
| 433 | return flat_param_matchers_to_def(flat); |
| 434 | } |
| 435 | |
| 436 | let mut nested = BTreeMap::new(); |
| 437 | for (key, matcher) in &flat { |
| 438 | if insert_nested_param(&mut nested, key, ParamMatcherDef::Matcher(matcher.clone())).is_err() |
| 439 | { |
| 440 | return flat_param_matchers_to_def(flat); |
| 441 | } |
| 442 | } |
| 443 | nested |
| 444 | } |
| 445 | |
| 446 | fn flat_param_matchers_to_def( |
| 447 | params: Vec<(String, QueryMatcherDef)>, |
no test coverage detected