diff --git a/src/mcpdotnet.Tests/mcpdotnet.Tests.csproj b/src/mcpdotnet.Tests/mcpdotnet.Tests.csproj index aeab76a..7140ca0 100644 --- a/src/mcpdotnet.Tests/mcpdotnet.Tests.csproj +++ b/src/mcpdotnet.Tests/mcpdotnet.Tests.csproj @@ -10,14 +10,14 @@ - + - - + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/src/mcpdotnet/Client/McpClient.cs b/src/mcpdotnet/Client/McpClient.cs index 6a6dc98..fc9bc09 100644 --- a/src/mcpdotnet/Client/McpClient.cs +++ b/src/mcpdotnet/Client/McpClient.cs @@ -8,7 +8,7 @@ using System.Diagnostics; using System.Text.Json; using McpDotNet.Utils.Json; -/// +/// internal class McpClient : IMcpClient { private readonly IMcpTransport _transport; @@ -21,13 +21,13 @@ internal class McpClient : IMcpClient private CancellationTokenSource? _cts; private readonly JsonSerializerOptions _jsonOptions = new JsonSerializerOptions().ConfigureForMcp(); - /// + /// public bool IsInitialized => _isInitialized; - /// + /// public ServerCapabilities? ServerCapabilities { get; private set; } - /// + /// public Implementation? ServerInfo { get; private set; } /// @@ -44,7 +44,7 @@ internal class McpClient : IMcpClient _nextRequestId = 1; } - /// + /// public async Task ConnectAsync(CancellationToken cancellationToken = default) { if (_isInitialized) @@ -122,7 +122,7 @@ internal class McpClient : IMcpClient } } - /// + /// public async Task PingAsync(CancellationToken cancellationToken) { await SendRequestAsync( @@ -134,7 +134,7 @@ internal class McpClient : IMcpClient ).ConfigureAwait(false); } - /// + /// public async Task ListToolsAsync(CancellationToken cancellationToken) { return await SendRequestAsync( @@ -147,7 +147,7 @@ internal class McpClient : IMcpClient ).ConfigureAwait(false); } - /// + /// public async Task CallToolAsync(string toolName, Dictionary? arguments = null, CancellationToken cancellationToken = default) { @@ -215,7 +215,7 @@ internal class McpClient : IMcpClient } } - /// + /// public async Task SendRequestAsync(JsonRpcRequest request, CancellationToken cancellationToken) where T : class { if (!_transport.IsConnected) @@ -273,7 +273,7 @@ internal class McpClient : IMcpClient await _transport.SendMessageAsync(notification, cancellationToken).ConfigureAwait(false); } - /// + /// public void OnNotification(string method, Func handler) { var handlers = _notificationHandlers.GetOrAdd(method, _ => new()); diff --git a/src/mcpdotnet/Protocol/Messages/RequestId.cs b/src/mcpdotnet/Protocol/Messages/RequestId.cs index 0a53c8a..8ce3349 100644 --- a/src/mcpdotnet/Protocol/Messages/RequestId.cs +++ b/src/mcpdotnet/Protocol/Messages/RequestId.cs @@ -17,6 +17,7 @@ public readonly struct RequestId : IEquatable } public static RequestId FromString(string value) => new(value); + public static RequestId FromNumber(long value) => new(value); public bool IsString => _value is string; diff --git a/src/mcpdotnet/Utils/Json/ContentJsonConverter.cs b/src/mcpdotnet/Utils/Json/ContentJsonConverter.cs index 79859e8..ac2a2c5 100644 --- a/src/mcpdotnet/Utils/Json/ContentJsonConverter.cs +++ b/src/mcpdotnet/Utils/Json/ContentJsonConverter.cs @@ -9,7 +9,7 @@ namespace McpDotNet.Utils.Json; /// public class ContentJsonConverter : JsonConverter { - /// + /// public override IContent? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { if (reader.TokenType != JsonTokenType.StartObject) @@ -34,7 +34,7 @@ public class ContentJsonConverter : JsonConverter }; } - /// + /// public override void Write(Utf8JsonWriter writer, IContent value, JsonSerializerOptions options) { switch (value) diff --git a/src/mcpdotnet/Utils/Json/JsonRpcMessageConverter.cs b/src/mcpdotnet/Utils/Json/JsonRpcMessageConverter.cs index f4712d7..dfbb62f 100644 --- a/src/mcpdotnet/Utils/Json/JsonRpcMessageConverter.cs +++ b/src/mcpdotnet/Utils/Json/JsonRpcMessageConverter.cs @@ -9,7 +9,7 @@ namespace McpDotNet.Utils.Json; /// public class JsonRpcMessageConverter : JsonConverter { - /// + /// public override IJsonRpcMessage? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { if (reader.TokenType != JsonTokenType.StartObject) @@ -63,7 +63,7 @@ public class JsonRpcMessageConverter : JsonConverter throw new JsonException("Invalid JSON-RPC message format"); } - /// + /// public override void Write(Utf8JsonWriter writer, IJsonRpcMessage value, JsonSerializerOptions options) { switch (value) diff --git a/src/mcpdotnet/Utils/Json/ResourceContentsJsonConverter.cs b/src/mcpdotnet/Utils/Json/ResourceContentsJsonConverter.cs index d323506..c80787a 100644 --- a/src/mcpdotnet/Utils/Json/ResourceContentsJsonConverter.cs +++ b/src/mcpdotnet/Utils/Json/ResourceContentsJsonConverter.cs @@ -9,7 +9,7 @@ namespace McpDotNet.Utils.Json; /// public class ResourceContentsJsonConverter : JsonConverter { - /// + /// public override IResourceContents? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { if (reader.TokenType != JsonTokenType.StartObject) @@ -33,7 +33,7 @@ public class ResourceContentsJsonConverter : JsonConverter throw new JsonException("Resource contents must have either 'text' or 'blob' property"); } - /// + /// public override void Write(Utf8JsonWriter writer, IResourceContents value, JsonSerializerOptions options) { switch (value) diff --git a/src/mcpdotnet/mcpdotnet.csproj b/src/mcpdotnet/mcpdotnet.csproj index fa71b7a..55b7288 100644 --- a/src/mcpdotnet/mcpdotnet.csproj +++ b/src/mcpdotnet/mcpdotnet.csproj @@ -3,7 +3,31 @@ net8.0 enable - enable + enable + + + mcpdotnet + 0.1.0-alpha1 + PederHP + .NET client library for the Model Context Protocol (MCP) + https://github.com/PederHP/mcpdotnet + https://github.com/PederHP/mcpdotnet + git + mcp;ai;llm;client + README.md + MIT + + mcpdotnet + mcpdotnet + true + true + snupkg + + + + + +