test(context): test context request handling and refactor for reusable client-server tests (#97)

This commit is contained in:
Jonathan Hendler 2025-04-06 16:13:05 -10:00 • committed by GitHub
commit 910d3b39db
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 902 additions and 140 deletions

View file

@ -84,6 +84,7 @@ pub trait ClientHandler: Sized + Send + Sync + 'static {
McpError::method_not_found::<CreateMessageRequestMethod>(),
))
}
fn list_roots(
&self,
context: RequestContext<RoleClient>,

View file

@ -713,6 +713,16 @@ pub struct SamplingMessage {
pub content: Content,
}
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
pub enum ContextInclusion {
#[serde(rename = "allServers")]
AllServers,
#[serde(rename = "none")]
None,
#[serde(rename = "thisServer")]
ThisServer,
}
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct CreateMessageRequestParam {
@ -722,7 +732,7 @@ pub struct CreateMessageRequestParam {
#[serde(skip_serializing_if = "Option::is_none")]
pub system_prompt: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub include_context: Option<String>,
pub include_context: Option<ContextInclusion>,
#[serde(skip_serializing_if = "Option::is_none")]
pub temperature: Option<f32>,
pub max_tokens: u32,