From 71809e46ea3ab0728d8f66e564c8271cfee1ed99 Mon Sep 17 00:00:00 2001 From: juliuss007 <157698750+juliuss007@users.noreply.github.com> Date: Wed, 27 May 2026 06:28:49 +0200 Subject: [PATCH] fix(mcp): serialize include context values correctly --- src/cortex-mcp-types/src/sampling.rs | 34 +++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/cortex-mcp-types/src/sampling.rs b/src/cortex-mcp-types/src/sampling.rs index e4b36a7d1..c7708d05d 100644 --- a/src/cortex-mcp-types/src/sampling.rs +++ b/src/cortex-mcp-types/src/sampling.rs @@ -75,13 +75,15 @@ pub struct ModelHint { /// Include context option. #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, JsonSchema)] -#[serde(rename_all = "lowercase")] pub enum IncludeContext { /// No context. + #[serde(rename = "none")] None, /// This server's context. + #[serde(rename = "thisServer")] ThisServer, /// All servers' context. + #[serde(rename = "allServers")] AllServers, } @@ -111,3 +113,33 @@ pub enum StopReason { /// Max tokens reached. MaxTokens, } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn include_context_uses_mcp_camel_case_values() { + assert_eq!( + serde_json::to_string(&IncludeContext::None).unwrap(), + "\"none\"" + ); + assert_eq!( + serde_json::to_string(&IncludeContext::ThisServer).unwrap(), + "\"thisServer\"" + ); + assert_eq!( + serde_json::to_string(&IncludeContext::AllServers).unwrap(), + "\"allServers\"" + ); + + assert_eq!( + serde_json::from_str::("\"thisServer\"").unwrap(), + IncludeContext::ThisServer + ); + assert_eq!( + serde_json::from_str::("\"allServers\"").unwrap(), + IncludeContext::AllServers + ); + } +}