Table of Contents

Class McpServerToolCreateOptions

Namespace
ModelContextProtocol.Server
Assembly
ModelContextProtocol.Core.dll

Provides options for controlling the creation of an McpServerTool.

public sealed class McpServerToolCreateOptions
Inheritance
McpServerToolCreateOptions
Inherited Members

Remarks

These options allow for customizing the behavior and metadata of tools created with McpServerTool.Create. They provide control over naming, description, tool properties, and dependency injection integration.

When creating tools programmatically rather than using attributes, these options provide the same level of configuration flexibility.

Properties

Description

Gets or sets the description to use for the McpServerTool.

public string? Description { get; set; }

Property Value

string

Remarks

If null, but a DescriptionAttribute is applied to the method, the description from that attribute is used.

Destructive

Gets or sets a value that indicates whether the tool might perform destructive updates to its environment.

public bool? Destructive { get; set; }

Property Value

bool?

true if the tool might perform destructive updates to its environment. false if the tool performs only additive updates. The default is true.

Remarks

This property is most relevant when the tool modifies its environment (ReadOnly = false).

Icons

Gets or sets the icons for this tool.

public IList<Icon>? Icons { get; set; }

Property Value

IList<Icon>

Remarks

This property can be used by clients to display the tool's icon in a user interface.

Idempotent

Gets or sets a value that indicates whether calling the tool repeatedly with the same arguments has no additional effect on its environment.

public bool? Idempotent { get; set; }

Property Value

bool?

true if calling the tool repeatedly with the same arguments has no additional effect on the environment; false if it does. The default is false.

Remarks

This property is most relevant when the tool modifies its environment (ReadOnly = false).

Meta

Gets or sets metadata reserved by MCP for protocol-level metadata.

public JsonObject? Meta { get; set; }

Property Value

JsonObject

Remarks

This JsonObject is used to seed the Meta property. Any metadata from McpMetaAttribute instances on the method will be added to this object, but properties already present in this JsonObject will not be overwritten.

Implementations must not make assumptions about its contents.

Metadata

Gets or sets the metadata associated with the tool.

public IReadOnlyList<object>? Metadata { get; set; }

Property Value

IReadOnlyList<object>

Remarks

Metadata includes information such as attributes extracted from the method and its declaring class. If not provided, metadata will be automatically generated for methods created via reflection.

Name

Gets or sets the name to use for the McpServerTool.

public string? Name { get; set; }

Property Value

string

Remarks

If null, but an McpServerToolAttribute is applied to the method, the name from the attribute is used. If that's not present, a name based on the method's name is used.

OpenWorld

Gets or sets a value that indicates whether this tool can interact with an "open world" of external entities.

public bool? OpenWorld { get; set; }

Property Value

bool?

true if the tool can interact with an unpredictable or dynamic set of entities (like web search). false if the tool's domain of interaction is closed and well-defined (like memory access). The default is true.

ReadOnly

Gets or sets a value that indicates whether this tool does not modify its environment.

public bool? ReadOnly { get; set; }

Property Value

bool?

If true, the tool only performs read operations without changing state. If false, the tool might make modifications to its environment. The default is false.

Remarks

Read-only tools do not have side effects beyond computational resource usage. They don't create, update, or delete data in any system.

SchemaCreateOptions

Gets or sets the JSON schema options when creating an Microsoft.Extensions.AI.AIFunction from a method.

public AIJsonSchemaCreateOptions? SchemaCreateOptions { get; set; }

Property Value

AIJsonSchemaCreateOptions

The default is Microsoft.Extensions.AI.AIJsonSchemaCreateOptions.Default.

SerializerOptions

Gets or sets the JSON serializer options to use when marshalling data to/from JSON.

public JsonSerializerOptions? SerializerOptions { get; set; }

Property Value

JsonSerializerOptions

The default is DefaultOptions.

Services

Gets or sets optional services used in the construction of the McpServerTool.

public IServiceProvider? Services { get; set; }

Property Value

IServiceProvider

Remarks

These services will be used to determine which parameters should be satisfied from dependency injection. As such, what services are satisfied via this provider should match what's satisfied via the provider passed in at invocation time.

Title

Gets or sets a human-readable title for the tool that can be displayed to users.

public string? Title { get; set; }

Property Value

string

Remarks

The title provides a more descriptive, user-friendly name for the tool than the tool's programmatic name. It is intended for display purposes and to help users understand the tool's purpose at a glance.

Unlike the tool name (which follows programmatic naming conventions), the title can include spaces, special characters, and be phrased in a more natural language style.

UseStructuredContent

Gets or sets a value that indicates whether the tool should report an output schema for structured content.

public bool UseStructuredContent { get; set; }

Property Value

bool

The default is false.

Remarks

When enabled, the tool will attempt to populate the OutputSchema and provide structured content in the StructuredContent property.