Skip to content

Commit 479c95c

Browse files
committed
Update all Server comments
1 parent 485720c commit 479c95c

19 files changed

+171
-1422
lines changed

src/ModelContextProtocol.AspNetCore/McpEndpointRouteBuilderExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
namespace Microsoft.AspNetCore.Builder;
1919

2020
/// <summary>
21-
/// Extension methods for <see cref="IEndpointRouteBuilder"/> to add MCP endpoints.
21+
/// Provides extension methods for <see cref="IEndpointRouteBuilder"/> to add MCP endpoints.
2222
/// </summary>
2323
public static class McpEndpointRouteBuilderExtensions
2424
{

src/ModelContextProtocol/Client/IMcpClient.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,6 @@ namespace ModelContextProtocol.Client;
55
/// <summary>
66
/// Represents an instance of a Model Context Protocol (MCP) client that connects to and communicates with an MCP server.
77
/// </summary>
8-
/// <remarks>
9-
/// <para>
10-
/// The MCP client provides a standardized way to interact with AI tool servers, allowing applications to:
11-
/// <list type="bullet">
12-
/// <item>Connect to MCP-compliant servers</item>
13-
/// <item>Discover and use available tools, prompts, and resources</item>
14-
/// <item>Execute tool calls and prompt completions</item>
15-
/// <item>Subscribe to and receive notifications from resources</item>
16-
/// </list>
17-
/// </para>
18-
/// <para>
19-
/// An <see cref="IMcpClient"/> instance is typically created using <see cref="McpClientFactory"/> and should be disposed of properly when finished.
20-
/// </para>
21-
/// </remarks>
228
public interface IMcpClient : IMcpEndpoint
239
{
2410
/// <summary>

src/ModelContextProtocol/Server/IMcpServer.cs

Lines changed: 2 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -3,52 +3,8 @@
33
namespace ModelContextProtocol.Server;
44

55
/// <summary>
6-
/// Represents a server that can communicate with a client using the Model Context Protocol (MCP).
6+
/// Represents an instance of a Model Context Protocol (MCP) server that connects to and communicates with an MCP client.
77
/// </summary>
8-
/// <remarks>
9-
/// <para>
10-
/// The IMcpServer interface provides core functionality for handling client requests,
11-
/// managing capabilities, and enabling bidirectional communication using the MCP protocol.
12-
/// </para>
13-
/// <para>
14-
/// Servers can be created using <see cref="McpServerFactory"/> or configured via dependency injection
15-
/// with <see cref="Microsoft.Extensions.DependencyInjection.IMcpServerBuilder"/>.
16-
/// </para>
17-
/// <para>
18-
/// Example usage in a basic console application:
19-
/// <code>
20-
/// // Create transport and options
21-
/// var transport = new StdioTransport();
22-
/// var options = new McpServerOptions
23-
/// {
24-
/// ServerCapabilities = new()
25-
/// {
26-
/// ToolsCollection = new()
27-
/// {
28-
/// McpServerTool.Create((string message) => $"Echo: {message}",
29-
/// new() { Name = "Echo", Description = "Echoes a message back to the client." })
30-
/// }
31-
/// }
32-
/// };
33-
///
34-
/// // Create and run the server
35-
/// await using var server = McpServerFactory.Create(transport, options);
36-
/// await server.RunAsync();
37-
/// </code>
38-
/// </para>
39-
/// <para>
40-
/// Example usage in a background service:
41-
/// <code>
42-
/// public class MyBackgroundService(IMcpServer server) : BackgroundService
43-
/// {
44-
/// protected override async Task ExecuteAsync(CancellationToken stoppingToken)
45-
/// {
46-
/// await server.RunAsync(stoppingToken);
47-
/// }
48-
/// }
49-
/// </code>
50-
/// </para>
51-
/// </remarks>
528
public interface IMcpServer : IMcpEndpoint
539
{
5410
/// <summary>
@@ -64,15 +20,6 @@ public interface IMcpServer : IMcpEndpoint
6420
/// Server implementations can check these capabilities to determine which features
6521
/// are available when interacting with the client.
6622
/// </para>
67-
/// <para>
68-
/// Example checking for sampling capability:
69-
/// <code>
70-
/// if (server.ClientCapabilities?.Sampling != null)
71-
/// {
72-
/// // Client supports sampling capabilities
73-
/// }
74-
/// </code>
75-
/// </para>
7623
/// </remarks>
7724
ClientCapabilities? ClientCapabilities { get; }
7825

@@ -88,34 +35,15 @@ public interface IMcpServer : IMcpEndpoint
8835
/// Server implementations can use this information for logging, tracking client versions,
8936
/// or implementing client-specific behaviors.
9037
/// </para>
91-
/// <para>
92-
/// Example usage:
93-
/// <code>
94-
/// if (server.ClientInfo != null)
95-
/// {
96-
/// logger.LogInformation($"Connected to {server.ClientInfo.Name} version {server.ClientInfo.Version}");
97-
/// }
98-
/// </code>
99-
/// </para>
10038
/// </remarks>
10139
Implementation? ClientInfo { get; }
10240

10341
/// <summary>
10442
/// Gets the options used to construct this server.
10543
/// </summary>
10644
/// <remarks>
107-
/// <para>
10845
/// These options define the server's capabilities, protocol version, and other configuration
109-
/// settings that were used to initialize the server. They represent the negotiated settings
110-
/// that are active for the current server session.
111-
/// </para>
112-
/// <para>
113-
/// Example of accessing server options:
114-
/// <code>
115-
/// var protocolVersion = server.ServerOptions.ProtocolVersion;
116-
/// var supportsTools = server.ServerOptions.Capabilities?.Tools != null;
117-
/// </code>
118-
/// </para>
46+
/// settings that were used to initialize the server.
11947
/// </remarks>
12048
McpServerOptions ServerOptions { get; }
12149

src/ModelContextProtocol/Server/IMcpServerPrimitive.cs

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,6 @@ namespace ModelContextProtocol.Server;
33
/// <summary>
44
/// Represents an MCP server primitive, like a tool or a prompt.
55
/// </summary>
6-
/// <remarks>
7-
/// <para>
8-
/// MCP server primitives are the building blocks of MCP servers, providing functionality
9-
/// that can be exposed to clients. The two main types of primitives are tools (which perform actions)
10-
/// and prompts (which provide pre-defined text templates).
11-
/// </para>
12-
/// <para>
13-
/// In the Model Context Protocol architecture, primitives are fundamental components that
14-
/// enable communication between AI models and applications. They provide a standardized way
15-
/// to expose functionality that models can utilize during inference, allowing for dynamic
16-
/// interactions between the model and external systems.
17-
/// </para>
18-
/// <para>
19-
/// IMcpServerPrimitive is implemented by <see cref="McpServerTool"/> and <see cref="McpServerPrompt"/>,
20-
/// which provide concrete implementations for tools and prompts respectively. These primitives
21-
/// are registered with the MCP server and made available to client applications.
22-
/// </para>
23-
/// <para>
24-
/// Example primitive implementations can be found in the samples, such as:
25-
/// <code>
26-
/// [McpServerToolType]
27-
/// public class MyTools
28-
/// {
29-
/// [McpServerTool(Name = "echo")]
30-
/// public static string Echo(IMcpServer server, string message)
31-
/// {
32-
/// return $"Echo: {message}";
33-
/// }
34-
/// }
35-
/// </code>
36-
/// </para>
37-
/// </remarks>
386
public interface IMcpServerPrimitive
397
{
408
/// <summary>Gets the name of the primitive.</summary>

src/ModelContextProtocol/Server/McpServer.cs

Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,9 @@ internal sealed class McpServer : McpEndpoint, IMcpServer
3939
/// <param name="transport">Transport to use for the server representing an already-established session.</param>
4040
/// <param name="options">Configuration options for this server, including capabilities.
4141
/// Make sure to accurately reflect exactly what capabilities the server supports and does not support.</param>
42-
/// <param name="loggerFactory">Logger factory to use for logging. Provides logging capabilities to the server
43-
/// for diagnostic and troubleshooting purposes. If null, a NullLogger will be used with no output.</param>
42+
/// <param name="loggerFactory">Logger factory to use for logging</param>
4443
/// <param name="serviceProvider">Optional service provider to use for dependency injection</param>
4544
/// <exception cref="McpException">The server was incorrectly configured.</exception>
46-
/// <remarks>
47-
/// This constructor is internal. Use <see cref="McpServerFactory.Create"/> to create a server instance.
48-
/// </remarks>
4945
public McpServer(ITransport transport, McpServerOptions options, ILoggerFactory? loggerFactory, IServiceProvider? serviceProvider)
5046
: base(loggerFactory)
5147
{
@@ -99,22 +95,6 @@ public McpServer(ITransport transport, McpServerOptions options, ILoggerFactory?
9995
InitializeSession(transport);
10096
}
10197

102-
/// <summary>
103-
/// Gets or sets the capabilities supported by this server.
104-
/// </summary>
105-
/// <remarks>
106-
/// <para>
107-
/// These capabilities are advertised to the client during the initialize handshake.
108-
/// </para>
109-
/// <para>
110-
/// The server capabilities define what features the server supports, such as tools,
111-
/// prompts, resources, logging, completions, and other protocol-specific functionality.
112-
/// </para>
113-
/// <para>
114-
/// This property is typically set during server initialization based on the
115-
/// configured <see cref="McpServerOptions.Capabilities"/>.
116-
/// </para>
117-
/// </remarks>
11898
public ServerCapabilities? ServerCapabilities { get; set; }
11999

120100
/// <inheritdoc />
@@ -130,17 +110,6 @@ public McpServer(ITransport transport, McpServerOptions options, ILoggerFactory?
130110
public IServiceProvider? Services { get; }
131111

132112
/// <inheritdoc />
133-
/// <inheritdoc/>
134-
/// <remarks>
135-
/// <para>
136-
/// For servers, the endpoint name is formatted as "Server ({ServerInfo.Name} {ServerInfo.Version})".
137-
/// </para>
138-
/// <para>
139-
/// This property returns the internal <see cref="_endpointName"/> field, which is initialized during construction
140-
/// and may be updated if client information becomes available during the session.
141-
/// It's used in all logging operations to identify this specific server endpoint.
142-
/// </para>
143-
/// </remarks>
144113
public override string EndpointName => _endpointName;
145114

146115
/// <inheritdoc />
@@ -165,18 +134,6 @@ public async Task RunAsync(CancellationToken cancellationToken = default)
165134
}
166135
}
167136

168-
/// <inheritdoc/>
169-
/// <summary>
170-
/// Asynchronously releases resources used by the MCP server without any synchronization.
171-
/// </summary>
172-
/// <returns>A task that represents the asynchronous dispose operation.</returns>
173-
/// <remarks>
174-
/// This method:
175-
/// <list type="bullet">
176-
/// <item><description>Unregisters tool and prompt collection change event handlers</description></item>
177-
/// <item><description>Calls the base class implementation to clean up common endpoint resources</description></item>
178-
/// </list>
179-
/// </remarks>
180137
public override async ValueTask DisposeUnsynchronizedAsync()
181138
{
182139
if (_toolsChangedDelegate is not null &&
@@ -233,7 +190,7 @@ private void SetCompletionHandler(McpServerOptions options)
233190
return;
234191
}
235192

236-
var completeHandler = completionsCapability.CompleteHandler ??
193+
var completeHandler = completionsCapability.CompleteHandler ??
237194
throw new McpException("Completions capability was enabled, but Complete handler was not specified.");
238195

239196
// This capability is not optional, so return an empty result if there is no handler.

0 commit comments

Comments
 (0)