Use DescriptionAttribute and HasDefaultValue in server builder extensions (#46)
This commit is contained in:
parent
e187ebacc4
commit
33d2b0d762
2 changed files with 27 additions and 61 deletions
|
|
@ -1,12 +1,13 @@
|
|||
using McpDotNet.Server;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace TestServerWithHosting.Tools;
|
||||
|
||||
[McpToolType]
|
||||
public static class EchoTool
|
||||
{
|
||||
[McpTool(description: "Echoes the input back to the client.")]
|
||||
public static string Echo([McpParameter(true)] string message)
|
||||
[McpTool, Description("Echoes the input back to the client.")]
|
||||
public static string Echo(string message)
|
||||
{
|
||||
return "hello " + message;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using McpDotNet.Protocol.Types;
|
||||
using McpDotNet.Server;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace TestServerWithHosting.Tools;
|
||||
|
||||
|
|
@ -16,10 +17,10 @@ public class SampleLlmTool
|
|||
_server = server ?? throw new ArgumentNullException(nameof(server));
|
||||
}
|
||||
|
||||
[McpTool(name: "sampleLLM", description: "Samples from an LLM using MCP's sampling feature")]
|
||||
[McpTool("sampleLLM"), Description("Samples from an LLM using MCP's sampling feature")]
|
||||
public async Task<string> SampleLLM(
|
||||
[McpParameter(true, description: "The prompt to send to the LLM")] string prompt,
|
||||
[McpParameter(true, description: "Maximum number of tokens to generate")] int maxTokens,
|
||||
[Description("The prompt to send to the LLM")] string prompt,
|
||||
[Description("Maximum number of tokens to generate")] int maxTokens,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var samplingParams = CreateRequestSamplingParams(prompt ?? string.Empty, "sampleLLM", maxTokens);
|
||||
|
|
|
|||
Loading…
Reference in a new issue