Clean up namespaces (#410)

No meaningful code changes, just lots of namespace shuffling to have fewer namespaces and to put things in better namespaces.
This commit is contained in:
Stephen Toub 2025-05-14 14:50:26 -04:00 • committed by GitHub
commit 106ab8064f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
163 changed files with 491 additions and 668 deletions

View file

@ -1,4 +1,4 @@
using ModelContextProtocol.Utils;
using ModelContextProtocol;
namespace System.Collections.Generic;

View file

@ -1,4 +1,4 @@
using ModelContextProtocol.Utils;
using ModelContextProtocol;
using System.Buffers;
using System.Runtime.InteropServices;

View file

@ -1,4 +1,4 @@
using ModelContextProtocol.Utils;
using ModelContextProtocol;
namespace System.Net.Http;

View file

@ -1,4 +1,4 @@
using ModelContextProtocol.Utils;
using ModelContextProtocol;
namespace System.Threading.Tasks;

View file

@ -1,4 +1,4 @@
using ModelContextProtocol.Utils;
using ModelContextProtocol;
namespace System.Threading.Tasks;

View file

@ -1,7 +1,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
namespace ModelContextProtocol.Utils;
namespace ModelContextProtocol;
/// <summary>Provides helper methods for throwing exceptions.</summary>
internal static class Throw

View file

@ -1,5 +1,5 @@
using ModelContextProtocol.AspNetCore.Stateless;
using ModelContextProtocol.Protocol.Transport;
using ModelContextProtocol.Protocol;
using ModelContextProtocol.Server;
using System.Security.Claims;

View file

@ -1,7 +1,7 @@
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using ModelContextProtocol.Protocol.Transport;
using ModelContextProtocol.Server;
namespace ModelContextProtocol.AspNetCore;

View file

@ -3,7 +3,7 @@ using Microsoft.AspNetCore.Http.Metadata;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using ModelContextProtocol.AspNetCore;
using ModelContextProtocol.Protocol.Messages;
using ModelContextProtocol.Protocol;
using System.Diagnostics.CodeAnalysis;
namespace Microsoft.AspNetCore.Builder;

View file

@ -2,10 +2,8 @@
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using ModelContextProtocol.Protocol.Messages;
using ModelContextProtocol.Protocol.Transport;
using ModelContextProtocol.Protocol;
using ModelContextProtocol.Server;
using ModelContextProtocol.Utils.Json;
using System.Collections.Concurrent;
using System.Diagnostics;

View file

@ -1,4 +1,4 @@
using ModelContextProtocol.Protocol.Types;
using ModelContextProtocol.Protocol;
using System.Text.Json.Serialization;
namespace ModelContextProtocol.AspNetCore.Stateless;

View file

@ -6,11 +6,8 @@ using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Microsoft.Net.Http.Headers;
using ModelContextProtocol.AspNetCore.Stateless;
using ModelContextProtocol.Protocol.Messages;
using ModelContextProtocol.Protocol.Transport;
using ModelContextProtocol.Protocol.Types;
using ModelContextProtocol.Protocol;
using ModelContextProtocol.Server;
using ModelContextProtocol.Utils.Json;
using System.Collections.Concurrent;
using System.Diagnostics;
using System.IO.Pipelines;

View file

@ -1,8 +1,8 @@
using Microsoft.Extensions.AI;
using ModelContextProtocol.Protocol.Types;
using ModelContextProtocol.Utils;
using ModelContextProtocol.Utils.Json;
using ModelContextProtocol.Protocol;
#if !NET
using System.Runtime.InteropServices;
#endif
using System.Text.Json;
namespace ModelContextProtocol;

View file

@ -0,0 +1,47 @@
using ModelContextProtocol.Protocol;
namespace ModelContextProtocol.Client;
/// <summary>
/// Represents a transport mechanism for Model Context Protocol (MCP) client-to-server communication.
/// </summary>
/// <remarks>
/// <para>
/// The <see cref="IClientTransport"/> interface abstracts the communication layer between MCP clients
/// and servers, allowing different transport protocols to be used interchangeably.
/// </para>
/// <para>
/// When creating an <see cref="IMcpClient"/>, <see cref="McpClientFactory"/> is typically used, and is
/// provided with the <see cref="IClientTransport"/> based on expected server configuration.
/// </para>
/// </remarks>
public interface IClientTransport
{
/// <summary>
/// Gets a transport identifier, used for logging purposes.
/// </summary>
string Name { get; }
/// <summary>
/// Asynchronously establishes a transport session with an MCP server and returns a transport for the duplex message stream.
/// </summary>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests. The default is <see cref="CancellationToken.None"/>.</param>
/// <returns>Returns an interface for the duplex message stream.</returns>
/// <remarks>
/// <para>
/// This method is responsible for initializing the connection to the server using the specific transport
/// mechanism implemented by the derived class. The returned <see cref="ITransport"/> interface
/// provides methods to send and receive messages over the established connection.
/// </para>
/// <para>
/// The lifetime of the returned <see cref="ITransport"/> instance is typically managed by the
/// <see cref="McpClient"/> that uses this transport. When the client is disposed, it will dispose
/// the transport session as well.
/// </para>
/// <para>
/// This method is used by <see cref="McpClientFactory"/> to initialize the connection.
/// </para>
/// </remarks>
/// <exception cref="InvalidOperationException">The transport connection could not be established.</exception>
Task<ITransport> ConnectAsync(CancellationToken cancellationToken = default);
}

View file

@ -1,4 +1,4 @@
using ModelContextProtocol.Protocol.Types;
using ModelContextProtocol.Protocol;
namespace ModelContextProtocol.Client;

View file

@ -1,9 +1,5 @@
using Microsoft.Extensions.Logging;
using ModelContextProtocol.Protocol.Messages;
using ModelContextProtocol.Protocol.Transport;
using ModelContextProtocol.Protocol.Types;
using ModelContextProtocol.Shared;
using ModelContextProtocol.Utils.Json;
using ModelContextProtocol.Protocol;
using System.Text.Json;
namespace ModelContextProtocol.Client;

View file

@ -1,10 +1,7 @@
using Microsoft.Extensions.AI;
using Microsoft.Extensions.Logging;
using ModelContextProtocol.Protocol.Messages;
using ModelContextProtocol.Protocol.Types;
using ModelContextProtocol.Protocol;
using ModelContextProtocol.Server;
using ModelContextProtocol.Utils;
using ModelContextProtocol.Utils.Json;
using System.Runtime.CompilerServices;
using System.Text.Json;

View file

@ -1,5 +1,3 @@
using ModelContextProtocol.Protocol.Transport;
using ModelContextProtocol.Utils;
using Microsoft.Extensions.Logging;
namespace ModelContextProtocol.Client;

View file

@ -1,4 +1,4 @@
using ModelContextProtocol.Protocol.Types;
using ModelContextProtocol.Protocol;
namespace ModelContextProtocol.Client;

View file

@ -1,4 +1,4 @@
using ModelContextProtocol.Protocol.Types;
using ModelContextProtocol.Protocol;
using System.Text.Json;
namespace ModelContextProtocol.Client;

Some files were not shown because too many files have changed in this diff Show more