-
Notifications
You must be signed in to change notification settings - Fork 299
feat: Add MCP Elicitation support #332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 18 commits
4acf13c
ce4a03a
e1a995c
174af7e
f4819a5
c5fb31c
242a8ab
c080d40
6867d5c
01dd3e8
c649de1
0be52a1
3b18efc
8296242
3d6a9d5
5be0f43
edc5bed
a8c9b5e
3c98177
fd54781
a7211f3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,22 @@ pub struct RootsCapabilities { | |
pub list_changed: Option<bool>, | ||
} | ||
|
||
/// Capability for handling elicitation requests from servers. | ||
/// | ||
/// Elicitation allows servers to request interactive input from users during tool execution. | ||
/// This capability indicates that a client can handle elicitation requests and present | ||
/// appropriate UI to users for collecting the requested information. | ||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)] | ||
#[serde(rename_all = "camelCase")] | ||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] | ||
pub struct ElicitationCapability { | ||
/// Whether the client supports JSON Schema validation for elicitation responses. | ||
/// When true, the client will validate user input against the requested_schema | ||
/// before sending the response back to the server. | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub schema_validation: Option<bool>, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. didn't see this option in the spec -- what's the motivation for adding it? only related bit I found in the spec was
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @jamadeo, the optional nature of
The MCP 2025-06-18 specification states:
This deliberate use of
However, the implementation should:
This approach balances protocol compliance with real-world flexibility, which seems to align with MCP's pragmatic design philosophy. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I think that's the right interpretation of should vs must. Mostly I just meant is it valid to put it in the capabilities object itself. (I'm not familiar enough with what's permitted there.) |
||
} | ||
|
||
/// | ||
/// # Builder | ||
/// ```rust | ||
|
@@ -58,6 +74,9 @@ pub struct ClientCapabilities { | |
pub roots: Option<RootsCapabilities>, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub sampling: Option<JsonObject>, | ||
/// Capability to handle elicitation requests from servers for interactive user input | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub elicitation: Option<ElicitationCapability>, | ||
} | ||
|
||
/// | ||
|
@@ -252,6 +271,7 @@ builder! { | |
experimental: ExperimentalCapabilities, | ||
roots: RootsCapabilities, | ||
sampling: JsonObject, | ||
elicitation: ElicitationCapability, | ||
} | ||
} | ||
|
||
|
@@ -266,6 +286,21 @@ impl<const E: bool, const S: bool> | |
} | ||
} | ||
|
||
#[cfg(feature = "elicitation")] | ||
impl<const E: bool, const R: bool, const S: bool> | ||
ClientCapabilitiesBuilder<ClientCapabilitiesBuilderState<E, R, S, true>> | ||
{ | ||
/// Enable JSON Schema validation for elicitation responses. | ||
/// When enabled, the client will validate user input against the requested_schema | ||
/// before sending responses back to the server. | ||
pub fn enable_elicitation_schema_validation(mut self) -> Self { | ||
if let Some(c) = self.elicitation.as_mut() { | ||
c.schema_validation = Some(true); | ||
} | ||
self | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod test { | ||
use super::*; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,6 +74,7 @@ variant_extension! { | |
PingRequest | ||
CreateMessageRequest | ||
ListRootsRequest | ||
CreateElicitationRequest | ||
} | ||
} | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.