Skip to content

Commit 71809e4

Browse files
committed
fix(mcp): serialize include context values correctly
1 parent 7954d02 commit 71809e4

1 file changed

Lines changed: 33 additions & 1 deletion

File tree

src/cortex-mcp-types/src/sampling.rs

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,15 @@ pub struct ModelHint {
7575

7676
/// Include context option.
7777
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
78-
#[serde(rename_all = "lowercase")]
7978
pub enum IncludeContext {
8079
/// No context.
80+
#[serde(rename = "none")]
8181
None,
8282
/// This server's context.
83+
#[serde(rename = "thisServer")]
8384
ThisServer,
8485
/// All servers' context.
86+
#[serde(rename = "allServers")]
8587
AllServers,
8688
}
8789

@@ -111,3 +113,33 @@ pub enum StopReason {
111113
/// Max tokens reached.
112114
MaxTokens,
113115
}
116+
117+
#[cfg(test)]
118+
mod tests {
119+
use super::*;
120+
121+
#[test]
122+
fn include_context_uses_mcp_camel_case_values() {
123+
assert_eq!(
124+
serde_json::to_string(&IncludeContext::None).unwrap(),
125+
"\"none\""
126+
);
127+
assert_eq!(
128+
serde_json::to_string(&IncludeContext::ThisServer).unwrap(),
129+
"\"thisServer\""
130+
);
131+
assert_eq!(
132+
serde_json::to_string(&IncludeContext::AllServers).unwrap(),
133+
"\"allServers\""
134+
);
135+
136+
assert_eq!(
137+
serde_json::from_str::<IncludeContext>("\"thisServer\"").unwrap(),
138+
IncludeContext::ThisServer
139+
);
140+
assert_eq!(
141+
serde_json::from_str::<IncludeContext>("\"allServers\"").unwrap(),
142+
IncludeContext::AllServers
143+
);
144+
}
145+
}

0 commit comments

Comments
 (0)