Skip to content

Conversation

ByteBaker
Copy link
Contributor

Implement type-safe schema definitions for MCP elicitation requests, replacing generic JsonObject with strongly-typed primitive schemas per the MCP 2025-06-18 specification.

Features:

  • Type-safe schema hierarchy (StringSchema, NumberSchema, IntegerSchema, BooleanSchema)
  • Builder pattern with fluent API and 20+ convenience methods
  • Build-time validation ensuring required fields exist in properties
  • Private fields enforcing invariants through validated constructors
  • Comprehensive validation support (range, length, format, enums)
  • Typed property methods for cleaner schema construction

Benefits:

  • Compile-time type safety prevents invalid schema construction
  • 60-70% reduction in boilerplate through convenience methods
  • Enforces MCP specification requirement for primitive-only properties
  • Better IDE autocomplete and type inference
  • Runtime validation catches schema errors early

Fixes #465

Motivation and Context

How Has This Been Tested?

Comprehensive tests have been added and verified to be passing.

Breaking Changes

  • CreateElicitationRequestParam.requested_schema changed from JsonObject to ElicitationSchema
  • ElicitationSchemaBuilder::build() now returns Result instead of direct value

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

@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 T-service Service layer changes labels Oct 2, 2025
) Implement type-safe schema definitions for MCP elicitation requests, replacing generic `JsonObject` with strongly-typed primitive schemas per the [MCP 2025-06-18 specification](https://spec.modelcontextprotocol.io/specification/2025-06-18/server/elicitation/). Features: - Type-safe schema hierarchy (`StringSchema`, `NumberSchema`, `IntegerSchema`, `BooleanSchema`) - Builder pattern with fluent API and 20+ convenience methods - Build-time validation ensuring required fields exist in properties - Private fields enforcing invariants through validated constructors - Comprehensive validation support (range, length, format, enums) - Typed property methods for cleaner schema construction Benefits: - Compile-time type safety prevents invalid schema construction - 60-70% reduction in boilerplate through convenience methods - Enforces MCP specification requirement for primitive-only properties - Better IDE autocomplete and type inference - Runtime validation catches schema errors early Breaking changes: - `CreateElicitationRequestParam.requested_schema` changed from `JsonObject` to `ElicitationSchema` - `ElicitationSchemaBuilder::build()` now returns `Result` instead of direct value Fixes modelcontextprotocol#465
Copy link
Contributor

@bug-ops bug-ops left a comment

Choose a reason for hiding this comment

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

Hi @ByteBaker, some adjustments need to be made to comply with the MCP specifications.

@ByteBaker
Copy link
Contributor Author

Hi @bug-ops, I had missed out on several points. Thanks for catching them. I've made a commit addressing the issues. I hope I've resolved them all this time around.

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-service Service layer changes T-test Testing related changes
2 participants