Skip to main content
Version: 0.3.x (0.3.0)

Class ValueObjectMcpServerOptionsExtensions

Namespace: AdCodicem.ValueObjects.ModelContextProtocol
Assembly: AdCodicem.ValueObjects.ModelContextProtocol.dll

Adds the check of value-object arguments to server options the application builds or changes itself.

public static class ValueObjectMcpServerOptionsExtensions

Inheritance​

object ← ValueObjectMcpServerOptionsExtensions

Inherited Members​

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()

Methods​

AddValueObjectValidation(McpServerOptions)​

Places the check of the value-object arguments of the tools created last among the call-tool filters of the options, once, so that it runs inside every filter already there.

public static McpServerOptions AddValueObjectValidation(this McpServerOptions options)

Parameters​

options McpServerOptions

The options of the server, before the server is created from them.

Returns​

McpServerOptions

The options.

Remarks​

The WithValueObjectTools methods of add the check themselves, once the options are configured. Call this method where nothing does, on the options of a server created without dependency injection:

var options = new McpServerOptions { ToolCollection = [ValueObjectMcpServerTool.Create(method)] };
await using var server = McpServer.Create(transport, options.AddValueObjectValidation());

or after adding a call-tool filter of the application's own where the options are changed later, in HttpServerTransportOptions.ConfigureSessionOptions for instance, which runs for each session after the options are configured: the check, already there, moves after that filter. The server builds its pipeline when it is created, from the filters the options hold then. The SDK refuses call-tool filters beside an explicit CallToolWithAlternateHandler, and throws when the server is created.

Exceptions​

ArgumentNullException

options is null.