Table of Contents

Class McpServerToolCreateOptions

Namespace
ModelContextProtocol.Server
Assembly
ModelContextProtocol.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 set 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 will be used.

Destructive

Gets or sets whether the tool may perform destructive updates to its environment.

public bool? Destructive { get; set; }

Property Value

bool?

Remarks

If true, the tool may perform destructive updates to its environment. If false, the tool performs only additive updates. This property is most relevant when the tool modifies its environment (ReadOnly = false).

The default is true.

Idempotent

Gets or sets whether calling the tool repeatedly with the same arguments will have no additional effect on its environment.

public bool? Idempotent { get; set; }

Property Value

bool?

Remarks

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

The default is false.

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 will be used. If that's not present, a name based on the method's name will be used.

OpenWorld

Gets or sets whether this tool may interact with an "open world" of external entities.

public bool? OpenWorld { get; set; }

Property Value

bool?

Remarks

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

The default is true.

ReadOnly

Gets or sets whether this tool does not modify its environment.

public bool? ReadOnly { get; set; }

Property Value

bool?

Remarks

If true, the tool only performs read operations without changing state. If false, the tool may make modifications to its environment.

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

The default is false.

SerializerOptions

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

public JsonSerializerOptions? SerializerOptions { get; set; }

Property Value

JsonSerializerOptions

Remarks

Defaults to DefaultOptions if left unspecified.

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 satisifed 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.