Package properties (#3)

Dependency upgrades
Comment cleanup
This commit is contained in:
Peder Holdgaard Pedersen 2025-01-03 13:34:16 +01:00 • committed by GitHub
commit 7ccdeb20eb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 46 additions and 21 deletions

View file

@ -10,14 +10,14 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="Moq" Version="4.20.72" /> <PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="xunit" Version="2.4.2" /> <PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5"> <PackageReference Include="xunit.runner.visualstudio" Version="3.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.0"> <PackageReference Include="coverlet.collector" Version="6.0.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>

View file

@ -8,7 +8,7 @@ using System.Diagnostics;
using System.Text.Json; using System.Text.Json;
using McpDotNet.Utils.Json; using McpDotNet.Utils.Json;
/// </inheritdoc> /// <inheritdoc/>
internal class McpClient : IMcpClient internal class McpClient : IMcpClient
{ {
private readonly IMcpTransport _transport; private readonly IMcpTransport _transport;
@ -21,13 +21,13 @@ internal class McpClient : IMcpClient
private CancellationTokenSource? _cts; private CancellationTokenSource? _cts;
private readonly JsonSerializerOptions _jsonOptions = new JsonSerializerOptions().ConfigureForMcp(); private readonly JsonSerializerOptions _jsonOptions = new JsonSerializerOptions().ConfigureForMcp();
/// </inheritdoc> /// <inheritdoc/>
public bool IsInitialized => _isInitialized; public bool IsInitialized => _isInitialized;
/// </inheritdoc> /// <inheritdoc/>
public ServerCapabilities? ServerCapabilities { get; private set; } public ServerCapabilities? ServerCapabilities { get; private set; }
/// </inheritdoc> /// <inheritdoc/>
public Implementation? ServerInfo { get; private set; } public Implementation? ServerInfo { get; private set; }
/// <summary> /// <summary>
@ -44,7 +44,7 @@ internal class McpClient : IMcpClient
_nextRequestId = 1; _nextRequestId = 1;
} }
/// </inheritdoc> /// <inheritdoc/>
public async Task ConnectAsync(CancellationToken cancellationToken = default) public async Task ConnectAsync(CancellationToken cancellationToken = default)
{ {
if (_isInitialized) if (_isInitialized)
@ -122,7 +122,7 @@ internal class McpClient : IMcpClient
} }
} }
/// </inheritdoc> /// <inheritdoc/>
public async Task PingAsync(CancellationToken cancellationToken) public async Task PingAsync(CancellationToken cancellationToken)
{ {
await SendRequestAsync<dynamic>( await SendRequestAsync<dynamic>(
@ -134,7 +134,7 @@ internal class McpClient : IMcpClient
).ConfigureAwait(false); ).ConfigureAwait(false);
} }
/// </inheritdoc> /// <inheritdoc/>
public async Task<ListToolsResponse> ListToolsAsync(CancellationToken cancellationToken) public async Task<ListToolsResponse> ListToolsAsync(CancellationToken cancellationToken)
{ {
return await SendRequestAsync<ListToolsResponse>( return await SendRequestAsync<ListToolsResponse>(
@ -147,7 +147,7 @@ internal class McpClient : IMcpClient
).ConfigureAwait(false); ).ConfigureAwait(false);
} }
/// </inheritdoc> /// <inheritdoc/>
public async Task<CallToolResponse> CallToolAsync(string toolName, Dictionary<string, object>? arguments = null, public async Task<CallToolResponse> CallToolAsync(string toolName, Dictionary<string, object>? arguments = null,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
@ -215,7 +215,7 @@ internal class McpClient : IMcpClient
} }
} }
/// </inheritdoc> /// <inheritdoc/>
public async Task<T> SendRequestAsync<T>(JsonRpcRequest request, CancellationToken cancellationToken) where T : class public async Task<T> SendRequestAsync<T>(JsonRpcRequest request, CancellationToken cancellationToken) where T : class
{ {
if (!_transport.IsConnected) if (!_transport.IsConnected)
@ -273,7 +273,7 @@ internal class McpClient : IMcpClient
await _transport.SendMessageAsync(notification, cancellationToken).ConfigureAwait(false); await _transport.SendMessageAsync(notification, cancellationToken).ConfigureAwait(false);
} }
/// </inheritdoc> /// <inheritdoc/>
public void OnNotification(string method, Func<JsonRpcNotification,Task> handler) public void OnNotification(string method, Func<JsonRpcNotification,Task> handler)
{ {
var handlers = _notificationHandlers.GetOrAdd(method, _ => new()); var handlers = _notificationHandlers.GetOrAdd(method, _ => new());

View file

@ -17,6 +17,7 @@ public readonly struct RequestId : IEquatable<RequestId>
} }
public static RequestId FromString(string value) => new(value); public static RequestId FromString(string value) => new(value);
public static RequestId FromNumber(long value) => new(value); public static RequestId FromNumber(long value) => new(value);
public bool IsString => _value is string; public bool IsString => _value is string;

View file

@ -9,7 +9,7 @@ namespace McpDotNet.Utils.Json;
/// </summary> /// </summary>
public class ContentJsonConverter : JsonConverter<IContent> public class ContentJsonConverter : JsonConverter<IContent>
{ {
/// </inheritdoc> /// <inheritdoc/>
public override IContent? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) public override IContent? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{ {
if (reader.TokenType != JsonTokenType.StartObject) if (reader.TokenType != JsonTokenType.StartObject)
@ -34,7 +34,7 @@ public class ContentJsonConverter : JsonConverter<IContent>
}; };
} }
/// </inheritdoc> /// <inheritdoc/>
public override void Write(Utf8JsonWriter writer, IContent value, JsonSerializerOptions options) public override void Write(Utf8JsonWriter writer, IContent value, JsonSerializerOptions options)
{ {
switch (value) switch (value)

View file

@ -9,7 +9,7 @@ namespace McpDotNet.Utils.Json;
/// </summary> /// </summary>
public class JsonRpcMessageConverter : JsonConverter<IJsonRpcMessage> public class JsonRpcMessageConverter : JsonConverter<IJsonRpcMessage>
{ {
/// </inheritdoc> /// <inheritdoc/>
public override IJsonRpcMessage? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) public override IJsonRpcMessage? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{ {
if (reader.TokenType != JsonTokenType.StartObject) if (reader.TokenType != JsonTokenType.StartObject)
@ -63,7 +63,7 @@ public class JsonRpcMessageConverter : JsonConverter<IJsonRpcMessage>
throw new JsonException("Invalid JSON-RPC message format"); throw new JsonException("Invalid JSON-RPC message format");
} }
/// </inheritdoc> /// <inheritdoc/>
public override void Write(Utf8JsonWriter writer, IJsonRpcMessage value, JsonSerializerOptions options) public override void Write(Utf8JsonWriter writer, IJsonRpcMessage value, JsonSerializerOptions options)
{ {
switch (value) switch (value)

View file

@ -9,7 +9,7 @@ namespace McpDotNet.Utils.Json;
/// </summary> /// </summary>
public class ResourceContentsJsonConverter : JsonConverter<IResourceContents> public class ResourceContentsJsonConverter : JsonConverter<IResourceContents>
{ {
/// </inheritdoc> /// <inheritdoc/>
public override IResourceContents? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) public override IResourceContents? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{ {
if (reader.TokenType != JsonTokenType.StartObject) if (reader.TokenType != JsonTokenType.StartObject)
@ -33,7 +33,7 @@ public class ResourceContentsJsonConverter : JsonConverter<IResourceContents>
throw new JsonException("Resource contents must have either 'text' or 'blob' property"); throw new JsonException("Resource contents must have either 'text' or 'blob' property");
} }
/// </inheritdoc> /// <inheritdoc/>
public override void Write(Utf8JsonWriter writer, IResourceContents value, JsonSerializerOptions options) public override void Write(Utf8JsonWriter writer, IResourceContents value, JsonSerializerOptions options)
{ {
switch (value) switch (value)

View file

@ -3,7 +3,31 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>
<PropertyGroup>
<!-- license and package properties -->
<PackageId>mcpdotnet</PackageId>
<Version>0.1.0-alpha1</Version>
<Authors>PederHP</Authors>
<Description>.NET client library for the Model Context Protocol (MCP)</Description>
<PackageProjectUrl>https://github.com/PederHP/mcpdotnet</PackageProjectUrl>
<RepositoryUrl>https://github.com/PederHP/mcpdotnet</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>mcp;ai;llm;client</PackageTags>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<!-- Assembly properties -->
<AssemblyName>mcpdotnet</AssemblyName>
<RootNamespace>mcpdotnet</RootNamespace>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>
<ItemGroup>
<None Include="..\..\README.md" Pack="true" PackagePath="/" />
</ItemGroup>
</Project> </Project>