Skip to content

Commit a69fb3d

Browse files
committed
Address feedback, more cleanup, fix NAOT test failure
1 parent 33e438e commit a69fb3d

114 files changed

Lines changed: 303 additions & 232 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

samples/EverythingServer/Tools/AnnotatedMessageTool.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ public static IEnumerable<ContentBlock> AnnotatedMessage(MessageType messageType
1919
{
2020
List<ContentBlock> contents = messageType switch
2121
{
22-
MessageType.Error => [new TextContentBlock()
22+
MessageType.Error => [new TextContentBlock
2323
{
2424
Text = "Error: Operation failed",
2525
Annotations = new() { Audience = [Role.User, Role.Assistant], Priority = 1.0f }
2626
}],
27-
MessageType.Success => [new TextContentBlock()
27+
MessageType.Success => [new TextContentBlock
2828
{
2929
Text = "Operation completed successfully",
3030
Annotations = new() { Audience = [Role.User], Priority = 0.7f }
3131
}],
32-
MessageType.Debug => [new TextContentBlock()
32+
MessageType.Debug => [new TextContentBlock
3333
{
3434
Text = "Debug: Cache hit ratio 0.95, latency 150ms",
3535
Annotations = new() { Audience = [Role.Assistant], Priority = 0.3f }

samples/EverythingServer/Tools/SampleLlmTool.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ private static CreateMessageRequestParams CreateRequestSamplingParams(string con
2727
Messages = [new SamplingMessage()
2828
{
2929
Role = Role.User,
30-
Content = new TextContentBlock() { Text = $"Resource {uri} context: {context}" },
30+
Content = new TextContentBlock { Text = $"Resource {uri} context: {context}" },
3131
}],
3232
SystemPrompt = "You are a helpful test server.",
3333
MaxTokens = maxTokens,

samples/QuickstartWeatherServer/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
builder.Services.AddSingleton(_ =>
1919
{
20-
var client = new HttpClient() { BaseAddress = new Uri("https://api.weather.gov") };
20+
var client = new HttpClient { BaseAddress = new Uri("https://api.weather.gov") };
2121
client.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("weather-tool", "1.0"));
2222
return client;
2323
});

samples/TestServerWithHosting/Tools/SampleLlmTool.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ private static CreateMessageRequestParams CreateRequestSamplingParams(string con
3030
Messages = [new SamplingMessage()
3131
{
3232
Role = Role.User,
33-
Content = new TextContentBlock() { Text = $"Resource {uri} context: {context}" },
33+
Content = new TextContentBlock { Text = $"Resource {uri} context: {context}" },
3434
}],
3535
SystemPrompt = "You are a helpful test server.",
3636
MaxTokens = maxTokens,

src/ModelContextProtocol.Core/AIContentExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public static IList<AIContent> ToAIContents(this IEnumerable<ResourceContents> c
183183
internal static ContentBlock ToContent(this AIContent content) =>
184184
content switch
185185
{
186-
TextContent textContent => new TextContentBlock()
186+
TextContent textContent => new TextContentBlock
187187
{
188188
Text = textContent.Text,
189189
},
@@ -209,7 +209,7 @@ internal static ContentBlock ToContent(this AIContent content) =>
209209
}
210210
},
211211

212-
_ => new TextContentBlock()
212+
_ => new TextContentBlock
213213
{
214214
Text = JsonSerializer.Serialize(content, McpJsonUtilities.DefaultOptions.GetTypeInfo(typeof(object))),
215215
}

src/ModelContextProtocol.Core/Client/McpClientExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,7 @@ internal static CreateMessageResult ToCreateMessageResult(this ChatResponse chat
957957

958958
return new()
959959
{
960-
Content = content ?? new TextContentBlock() { Text = lastMessage?.Text ?? string.Empty },
960+
Content = content ?? new TextContentBlock { Text = lastMessage?.Text ?? string.Empty },
961961
Model = chatResponse.ModelId ?? "unknown",
962962
Role = lastMessage?.Role == ChatRole.User ? Role.User : Role.Assistant,
963963
StopReason = chatResponse.FinishReason == ChatFinishReason.Length ? "maxTokens" : "endTurn",

src/ModelContextProtocol.Core/Client/McpClientOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace ModelContextProtocol.Client;
99
/// These options are typically passed to <see cref="McpClientFactory.CreateAsync"/> when creating a client.
1010
/// They define client capabilities, protocol version, and other client-specific settings.
1111
/// </remarks>
12-
public class McpClientOptions
12+
public sealed class McpClientOptions
1313
{
1414
/// <summary>
1515
/// Gets or sets information about this client implementation, including its name and version.

src/ModelContextProtocol.Core/Client/SseClientTransportOptions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ namespace ModelContextProtocol.Client;
33
/// <summary>
44
/// Provides options for configuring <see cref="SseClientTransport"/> instances.
55
/// </summary>
6-
public class SseClientTransportOptions
6+
public sealed class SseClientTransportOptions
77
{
88
/// <summary>
99
/// Gets or sets the base address of the server for SSE connections.
@@ -69,5 +69,5 @@ public required Uri Endpoint
6969
/// <remarks>
7070
/// Use this property to specify custom HTTP headers that should be sent with each request to the server.
7171
/// </remarks>
72-
public Dictionary<string, string>? AdditionalHeaders { get; set; }
72+
public IDictionary<string, string>? AdditionalHeaders { get; set; }
7373
}

src/ModelContextProtocol.Core/Client/StdioClientTransportOptions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ namespace ModelContextProtocol.Client;
33
/// <summary>
44
/// Provides options for configuring <see cref="StdioClientTransport"/> instances.
55
/// </summary>
6-
public class StdioClientTransportOptions
6+
public sealed class StdioClientTransportOptions
77
{
88
/// <summary>
99
/// Gets or sets the command to execute to start the server process.
@@ -53,7 +53,7 @@ public required string Command
5353
/// That includes removing the variables for any of this collection's entries with a null value.
5454
/// </para>
5555
/// </remarks>
56-
public Dictionary<string, string?>? EnvironmentVariables { get; set; }
56+
public IDictionary<string, string?>? EnvironmentVariables { get; set; }
5757

5858
/// <summary>
5959
/// Gets or sets the timeout to wait for the server to shut down gracefully.

src/ModelContextProtocol.Core/Client/StreamableHttpClientSessionTransport.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ private void LogJsonException(JsonException ex, string data)
244244
}
245245
}
246246

247-
internal static void CopyAdditionalHeaders(HttpRequestHeaders headers, Dictionary<string, string>? additionalHeaders, string? sessionId = null)
247+
internal static void CopyAdditionalHeaders(HttpRequestHeaders headers, IDictionary<string, string>? additionalHeaders, string? sessionId = null)
248248
{
249249
if (sessionId is not null)
250250
{

0 commit comments

Comments
 (0)