Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion src/cortex-mcp-types/src/sampling.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -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,
}

Expand DownExpand Up@@ -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::<IncludeContext>("\"thisServer\"").unwrap(),
IncludeContext::ThisServer
);
assert_eq!(
serde_json::from_str::<IncludeContext>("\"allServers\"").unwrap(),
IncludeContext::AllServers
);
}
}