Table of Contents

Class McpServerToolTypeAttribute

Namespace
ModelContextProtocol.Server
Assembly
ModelContextProtocol.dll

Used to attribute a type containing methods that should be exposed as McpServerTools.

[AttributeUsage(AttributeTargets.Class)]
public sealed class McpServerToolTypeAttribute : Attribute
Inheritance
McpServerToolTypeAttribute
Inherited Members

Remarks

This attribute is used to mark a class containing methods that should be automatically discovered and registered as McpServerTools. When combined with discovery methods like WithToolsFromAssembly(IMcpServerBuilder, Assembly?, JsonSerializerOptions?), it enables automatic registration of tools without explicitly listing each tool class. The attribute is not necessary when a reference to the type is provided directly to a method like WithTools<TToolType>(IMcpServerBuilder, JsonSerializerOptions?).

Within a class marked with this attribute, individual methods that should be exposed as tools must be marked with the McpServerToolAttribute.