Skip to content

Commit 6a76cf5

Browse files
authored
Merge branch 'modelcontextprotocol:main' into update_claude_model_id
2 parents 444abe8 + 66c084c commit 6a76cf5

File tree

4 files changed

+471
-6
lines changed

4 files changed

+471
-6
lines changed

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ jobs:
7979
uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # v5.0.0
8080
with:
8181
dotnet-version: |
82-
10.0.100-rc.1.25451.107
82+
10.0.x
8383
9.0.x
8484
8585
- name: Pack
@@ -108,7 +108,7 @@ jobs:
108108
- name: Setup .NET
109109
uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # v5.0.0
110110
with:
111-
dotnet-version: 10.0.100-rc.1.25451.107
111+
dotnet-version: 10.0.x
112112

113113
- name: Download build artifacts
114114
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
@@ -163,7 +163,7 @@ jobs:
163163
- name: Setup .NET
164164
uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # v5.0.0
165165
with:
166-
dotnet-version: 10.0.100-rc.1.25451.107
166+
dotnet-version: 10.0.x
167167

168168
- name: Download build artifacts
169169
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0

src/ModelContextProtocol.Core/Protocol/ElicitRequestParams.cs

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ public class Converter : JsonConverter<PrimitiveSchemaDefinition>
109109
double? minimum = null;
110110
double? maximum = null;
111111
bool? defaultBool = null;
112+
double? defaultNumber = null;
113+
string? defaultString = null;
112114
IList<string>? enumValues = null;
113115
IList<string>? enumNames = null;
114116

@@ -158,7 +160,23 @@ public class Converter : JsonConverter<PrimitiveSchemaDefinition>
158160
break;
159161

160162
case "default":
161-
defaultBool = reader.GetBoolean();
163+
// We need to handle different types for default values
164+
// Store the value based on the JSON token type
165+
switch (reader.TokenType)
166+
{
167+
case JsonTokenType.True:
168+
defaultBool = true;
169+
break;
170+
case JsonTokenType.False:
171+
defaultBool = false;
172+
break;
173+
case JsonTokenType.Number:
174+
defaultNumber = reader.GetDouble();
175+
break;
176+
case JsonTokenType.String:
177+
defaultString = reader.GetString();
178+
break;
179+
}
162180
break;
163181

164182
case "enum":
@@ -188,7 +206,8 @@ public class Converter : JsonConverter<PrimitiveSchemaDefinition>
188206
psd = new EnumSchema
189207
{
190208
Enum = enumValues,
191-
EnumNames = enumNames
209+
EnumNames = enumNames,
210+
Default = defaultString,
192211
};
193212
}
194213
else
@@ -198,6 +217,7 @@ public class Converter : JsonConverter<PrimitiveSchemaDefinition>
198217
MinLength = minLength,
199218
MaxLength = maxLength,
200219
Format = format,
220+
Default = defaultString,
201221
};
202222
}
203223
break;
@@ -208,6 +228,7 @@ public class Converter : JsonConverter<PrimitiveSchemaDefinition>
208228
{
209229
Minimum = minimum,
210230
Maximum = maximum,
231+
Default = defaultNumber,
211232
};
212233
break;
213234

@@ -265,6 +286,10 @@ public override void Write(Utf8JsonWriter writer, PrimitiveSchemaDefinition valu
265286
{
266287
writer.WriteString("format", stringSchema.Format);
267288
}
289+
if (stringSchema.Default is not null)
290+
{
291+
writer.WriteString("default", stringSchema.Default);
292+
}
268293
break;
269294

270295
case NumberSchema numberSchema:
@@ -276,10 +301,14 @@ public override void Write(Utf8JsonWriter writer, PrimitiveSchemaDefinition valu
276301
{
277302
writer.WriteNumber("maximum", numberSchema.Maximum.Value);
278303
}
304+
if (numberSchema.Default is not null)
305+
{
306+
writer.WriteNumber("default", numberSchema.Default.Value);
307+
}
279308
break;
280309

281310
case BooleanSchema booleanSchema:
282-
if (booleanSchema.Default.HasValue)
311+
if (booleanSchema.Default is not null)
283312
{
284313
writer.WriteBoolean("default", booleanSchema.Default.Value);
285314
}
@@ -296,6 +325,10 @@ public override void Write(Utf8JsonWriter writer, PrimitiveSchemaDefinition valu
296325
writer.WritePropertyName("enumNames");
297326
JsonSerializer.Serialize(writer, enumSchema.EnumNames, McpJsonUtilities.JsonContext.Default.IListString);
298327
}
328+
if (enumSchema.Default is not null)
329+
{
330+
writer.WriteString("default", enumSchema.Default);
331+
}
299332
break;
300333

301334
default:
@@ -371,6 +404,10 @@ public string? Format
371404
field = value;
372405
}
373406
}
407+
408+
/// <summary>Gets or sets the default value for the string.</summary>
409+
[JsonPropertyName("default")]
410+
public string? Default { get; set; }
374411
}
375412

376413
/// <summary>Represents a schema for a number or integer type.</summary>
@@ -399,6 +436,10 @@ public override string Type
399436
/// <summary>Gets or sets the maximum allowed value.</summary>
400437
[JsonPropertyName("maximum")]
401438
public double? Maximum { get; set; }
439+
440+
/// <summary>Gets or sets the default value for the number.</summary>
441+
[JsonPropertyName("default")]
442+
public double? Default { get; set; }
402443
}
403444

404445
/// <summary>Represents a schema for a Boolean type.</summary>
@@ -456,5 +497,9 @@ public IList<string> Enum
456497
/// <summary>Gets or sets optional display names corresponding to the enum values.</summary>
457498
[JsonPropertyName("enumNames")]
458499
public IList<string>? EnumNames { get; set; }
500+
501+
/// <summary>Gets or sets the default value for the enum.</summary>
502+
[JsonPropertyName("default")]
503+
public string? Default { get; set; }
459504
}
460505
}

0 commit comments

Comments
 (0)