docs: add McpServerOptionsSetup code comment (#77)
This commit is contained in:
parent
c3988737c9
commit
1a5732b158
1 changed files with 12 additions and 0 deletions
|
|
@ -6,19 +6,31 @@ using ModelContextProtocol.Utils;
|
||||||
|
|
||||||
namespace ModelContextProtocol.Configuration;
|
namespace ModelContextProtocol.Configuration;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Configures the McpServerOptions using provided server handlers.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="serverHandlers">The server handlers configuration options.</param>
|
||||||
internal sealed class McpServerOptionsSetup(IOptions<McpServerHandlers> serverHandlers) : IConfigureOptions<McpServerOptions>
|
internal sealed class McpServerOptionsSetup(IOptions<McpServerHandlers> serverHandlers) : IConfigureOptions<McpServerOptions>
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Configures the given McpServerOptions instance by setting server information
|
||||||
|
/// and applying custom server handlers.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="options">The options instance to be configured.</param>
|
||||||
public void Configure(McpServerOptions options)
|
public void Configure(McpServerOptions options)
|
||||||
{
|
{
|
||||||
Throw.IfNull(options);
|
Throw.IfNull(options);
|
||||||
|
|
||||||
var assemblyName = Assembly.GetEntryAssembly()?.GetName();
|
var assemblyName = Assembly.GetEntryAssembly()?.GetName();
|
||||||
|
|
||||||
|
// Set server information based on the entry assembly
|
||||||
options.ServerInfo = new Implementation
|
options.ServerInfo = new Implementation
|
||||||
{
|
{
|
||||||
Name = assemblyName?.Name ?? "McpServer",
|
Name = assemblyName?.Name ?? "McpServer",
|
||||||
Version = assemblyName?.Version?.ToString() ?? "1.0.0",
|
Version = assemblyName?.Version?.ToString() ?? "1.0.0",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Apply custom server handlers
|
||||||
serverHandlers.Value.OverwriteWithSetHandlers(options);
|
serverHandlers.Value.OverwriteWithSetHandlers(options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue