feat(mcp): elicitation support (#5965)

This commit is contained in:
Alex Hancock
2025-12-05 21:29:59 -05:00
committed by GitHub
parent 1db40709bb
commit 06155ce0ca
24 changed files with 992 additions and 22 deletions
+41
View File
@@ -111,6 +111,15 @@ pub enum ActionRequiredData {
arguments: JsonObject,
prompt: Option<String>,
},
Elicitation {
id: String,
message: String,
requested_schema: serde_json::Value,
},
ElicitationResponse {
id: String,
user_data: serde_json::Value,
},
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, ToSchema)]
@@ -192,6 +201,12 @@ impl fmt::Display for MessageContent {
ActionRequiredData::ToolConfirmation { tool_name, .. } => {
write!(f, "[ActionRequired: ToolConfirmation for {}]", tool_name)
}
ActionRequiredData::Elicitation { message, .. } => {
write!(f, "[ActionRequired: Elicitation - {}]", message)
}
ActionRequiredData::ElicitationResponse { id, .. } => {
write!(f, "[ActionRequired: ElicitationResponse for {}]", id)
}
},
MessageContent::FrontendToolRequest(r) => match &r.tool_call {
Ok(tool_call) => write!(f, "[FrontendToolRequest: {}]", tool_call.name),
@@ -274,6 +289,32 @@ impl MessageContent {
})
}
pub fn action_required_elicitation<S: Into<String>>(
id: S,
message: String,
requested_schema: serde_json::Value,
) -> Self {
MessageContent::ActionRequired(ActionRequired {
data: ActionRequiredData::Elicitation {
id: id.into(),
message,
requested_schema,
},
})
}
pub fn action_required_elicitation_response<S: Into<String>>(
id: S,
user_data: serde_json::Value,
) -> Self {
MessageContent::ActionRequired(ActionRequired {
data: ActionRequiredData::ElicitationResponse {
id: id.into(),
user_data,
},
})
}
pub fn thinking<S1: Into<String>, S2: Into<String>>(thinking: S1, signature: S2) -> Self {
MessageContent::Thinking(ThinkingContent {
thinking: thinking.into(),