csharp-sdk/src/ModelContextProtocol/Server/McpToolAttribute.cs
2025-03-19 15:02:38 +02:00

20 lines
648 B
C#

namespace ModelContextProtocol.Server;
/// <summary>
/// Attribute to mark a method as an MCP tool.
/// </summary>
[AttributeUsage(AttributeTargets.Method)]
public sealed class McpToolAttribute : Attribute
{
/// <summary>Gets the name of the tool.</summary>
/// <remarks>If not provided, the method name will be used.</remarks>
public string? Name { get; }
/// <summary>
/// Attribute to mark a method as an MCP tool.
/// </summary>
/// <param name="name">The name of the tool. If not provided, the class name will be used.</param>
public McpToolAttribute(string? name = null)
{
Name = name;
}
}