Skip to content

Conversation

@pbezglasny
Copy link

@pbezglasny pbezglasny commented Nov 12, 2025

Implemented #524 Elicitation Enum Schema Improvements and Standards Compliance.

Motivation and Context

SEP-1330: Elicitation Enum Schema Improvements introduce new schema for enum type for elicitation. This PR implements its specifications: single/multi select options with/without titles.

Details:

  • Introduced new model struct to match required schema
  • Old response move to Legacy struct
  • Added builder to configure enum schema
  • Updated schema inference in ElicitationSchema::from_json_schema, now it understands enum fields of struct. Now it's possible to use next structs for elicitation request:
        #[derive(Debug, Serialize, Deserialize, JsonSchema, Default)]
        enum TitledEnum {
            #[schemars(title = "Title for the first value")]
            #[default]
            FirstValue,
            #[schemars(title = "Title for the second value")]
            SecondValue,
        }

        #[derive(Debug, Serialize, Deserialize, JsonSchema)]
        enum UntitledEnum {
            First,
            Second,
            Third,
        }

        fn default_untitled_multi_select() -> Vec<UntitledEnum> {
            vec![UntitledEnum::Second, UntitledEnum::Third]
        }

        #[derive(Debug, Serialize, Deserialize, JsonSchema)]
        #[schemars(description = "User information")]
        struct UserInfo {
            #[schemars(description = "User's name")]
            pub name: String,
            pub single_select_untitled: UntitledEnum,
            #[schemars(
                title = "Single Select Titled",
                description = "Description for single select enum",
                default
            )]
            pub single_select_titled: TitledEnum,
            #[serde(default = "default_untitled_multi_select")]
            pub multi_select_untitled: Vec<UntitledEnum>,
            #[schemars(
                title = "Multi Select Titled",
                description = "Multi Select Description"
            )]
            pub multi_select_titled: Vec<TitledEnum>,
        }

This code will serialized to specification format.

  • Updated elicitation_stdio.rs example with enum field.

How Has This Been Tested?

Tested with mcpinspector. It correctly understands single select option for enum. But does not work with multi-select options.

Breaking Changes

Yes. By default elicitation

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

Closes #524

Copilot AI review requested due to automatic review settings November 12, 2025 16:03
@github-actions github-actions bot added T-test Testing related changes T-config Configuration file changes T-core Core library changes T-examples Example code changes T-model Model/data structure changes labels Nov 12, 2025
Copilot finished reviewing on behalf of pbezglasny November 12, 2025 16:07
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements SEP-1330 Elicitation Enum Schema Improvements, introducing a comprehensive schema system for single and multi-select enums with optional human-readable titles. The implementation maintains backward compatibility through a LegacyEnumSchema while providing a new builder-based API for constructing enum schemas compliant with the updated MCP specification.

Key Changes:

  • Introduced four new enum schema variants: UntitledSingleSelectEnumSchema, TitledSingleSelectEnumSchema, UntitledMultiSelectEnumSchema, and TitledMultiSelectEnumSchema
  • Added EnumSchemaBuilder with fluent API for configuring enum schemas with support for single/multi-select modes, titles, descriptions, and default values
  • Enhanced schema inference in from_json_schema to automatically detect and transform enum fields from JSON schemas, including reference resolution and property normalization

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
examples/servers/src/elicitation_stdio.rs Enhanced elicitation example with UserType enum demonstrating titled single-select functionality; updated error handling and output streams
crates/rmcp/src/model/elicitation_schema.rs Core implementation of new enum schema types, builder pattern, and schema inference logic with reference resolution and property normalization
crates/rmcp/tests/test_elicitation.rs Updated test to use new EnumSchema::builder() API instead of direct vector-based enum creation
crates/rmcp/tests/test_message_schema/server_json_rpc_message_schema.json JSON schema definitions for new enum schema variants, supporting both current and legacy formats
crates/rmcp/tests/test_message_schema/server_json_rpc_message_schema_current.json Updated current schema with new enum type definitions matching the implementation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@pbezglasny pbezglasny marked this pull request as draft November 12, 2025 16:10
@pbezglasny pbezglasny requested a review from Copilot November 12, 2025 16:31
Copilot finished reviewing on behalf of pbezglasny November 12, 2025 16:33
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 8 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@pbezglasny pbezglasny force-pushed the feat/sep-1330-elicitation-enum-schema branch from c5f342a to faeba48 Compare November 12, 2025 17:24
@pbezglasny pbezglasny marked this pull request as ready for review November 12, 2025 17:28
@pbezglasny pbezglasny closed this Nov 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-config Configuration file changes T-core Core library changes T-examples Example code changes T-model Model/data structure changes T-test Testing related changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement SEP-1330: Elicitation Enum Schema Improvements

1 participant