Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 628
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
4acf13cce4a03ae1a995c174af7ef4819a5c5fb31c242a8abc080d406867d5c01dd3e8c649de10be52a13b18efc82962423d6a9d55be0f43edc5beda8c9b5e3c98177fd54781a7211f3bebdf93File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -40,6 +40,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>, | ||
Contributor 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
ContributorAuthor 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. Contributor 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 | ||
| @@ -59,6 +75,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>, | ||
| } | ||
| /// | ||
| @@ -253,6 +272,7 @@ builder! { | ||
| experimental: ExperimentalCapabilities, | ||
| roots: RootsCapabilities, | ||
| sampling: JsonObject, | ||
| elicitation: ElicitationCapability, | ||
| } | ||
| } | ||
| @@ -267,6 +287,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.
Uh oh!
There was an error while loading. Please reload this page.