Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 30, 2025

SEP-1034: Support default values for all primitive types in elicitation schemas

This PR implements SEP-1034 to add default value support for all primitive types in elicitation schemas.

Changes Made

  • Add Default property to StringSchema class
  • Add Default property to NumberSchema class
  • Add Default property to EnumSchema class
  • Update the Converter.Read method to deserialize default values for all types using a switch statement
  • Update the Converter.Write method to serialize default values for all types
  • Use literal true/false values for boolean defaults in converter
  • Use is not null pattern consistently for all nullable checks
  • Add comprehensive tests for string default values
  • Add comprehensive tests for number default values
  • Add comprehensive tests for enum default values
  • Build and test the changes - all tests passing (20 tests pass, 1 skipped)
  • Run code review - no issues found
  • Run security checks - no vulnerabilities found

Summary

All primitive schema types (StringSchema, NumberSchema, EnumSchema, BooleanSchema) now support default values as specified in SEP-1034. The converter correctly handles serialization and deserialization of these default values based on the JSON token type using a switch statement with literal boolean values.

Default values can be set programmatically when creating schemas, and will be properly serialized/deserialized through the JSON converter.

Example

var schema = new ElicitRequestParams
{
    Message = "Configure email",
    RequestedSchema = new()
    {
        Properties = new Dictionary<string, ElicitRequestParams.PrimitiveSchemaDefinition>
        {
            ["recipients"] = new StringSchema { Default = "team@example.com" },
            ["priority"] = new NumberSchema { Default = 1 },
            ["status"] = new EnumSchema { Enum = ["draft", "sent"], Default = "draft" }
        }
    }
};

Future: Automatic Default Value Extraction

A test has been added (currently skipped) that demonstrates automatic extraction of default values from optional parameters in positional records when using ElicitAsync<T>(). This will work once AIJsonUtilities is updated to support extracting default values from optional parameters. The test uses a positional record FormWithDefaults with optional parameters like string Name = "John Doe" and verifies that defaults are included in the generated elicitation schema.

Original prompt

This section details on the original issue you should resolve

<issue_title>SEP-1034 : Support default values for all primitive types in elicitation schemas</issue_title>
<issue_description>Is your feature request related to a problem? Please describe.

Add support for SEP-1034, which is accepted for the next version of the MCP spec.

Describe the solution you'd like

All features of SEP-1034 are supported as described.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.
</issue_description>

<agent_instructions>Per the changes in the MCP specification, update all schema types contained in ElicitRequestParams.cs to include a Default property (similar to how BooleanSchema already does this).

Additionally update the converter in the same file so that default keywords are mapped correctly to the new properties.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for default values in elicitation schemas Add default value support for all primitive types in elicitation schemas (SEP-1034) Oct 30, 2025
Copilot AI requested a review from eiriktsarpalis October 30, 2025 13:27
Copilot finished work on behalf of eiriktsarpalis October 30, 2025 13:27
…mapping tests

Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com>
Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com>
Copilot AI requested a review from eiriktsarpalis October 30, 2025 14:16
Copilot finished work on behalf of eiriktsarpalis October 30, 2025 14:16
Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com>
…m AttributeProvider

Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Oct 30, 2025

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • http://crl3.digicert.com:443/DigiCertCSRSA4096RootG5.crl
    • Triggering command: dotnet test tests/ModelContextProtocol.Tests/ModelContextProtocol.Tests.csproj /p:TargetFrameworks=net9.0 --filter FullyQualifiedName~Elicit_Typed_With_Defaults_Maps_To_Schema_Defaults (http block)
  • http://crl3.digicert.com:443/NETFoundationProjectsCodeSigningCA2.crl
    • Triggering command: dotnet test tests/ModelContextProtocol.Tests/ModelContextProtocol.Tests.csproj /p:TargetFrameworks=net9.0 --filter FullyQualifiedName~Elicit_Typed_With_Defaults_Maps_To_Schema_Defaults (http block)
  • http://crl3.digicert.com:443/sha2-assured-cs-g1.crl
    • Triggering command: dotnet test tests/ModelContextProtocol.Tests/ModelContextProtocol.Tests.csproj /p:TargetFrameworks=net9.0 --filter FullyQualifiedName~Elicit_Typed_With_Defaults_Maps_To_Schema_Defaults (http block)

If you need me to access, download, or install something from one of these locations, you can either:

…cord

Removed the manual default value extraction code from BuildRequestSchema
and SetDefaultValue helper as this should be handled by AIJsonUtilities.
Updated FormWithDefaults to be a positional record with optional parameters.
Test is now skipped until AIJsonUtilities supports extracting defaults from
optional parameters.

Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com>
Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com>
@eiriktsarpalis eiriktsarpalis merged commit 66c084c into main Oct 31, 2025
10 checks passed
@eiriktsarpalis eiriktsarpalis deleted the copilot/support-default-values-schema-types branch October 31, 2025 06:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SEP-1034 : Support default values for all primitive types in elicitation schemas

3 participants