diff --git a/samples/TestServerWithHosting/Tools/SampleLlmTool.cs b/samples/TestServerWithHosting/Tools/SampleLlmTool.cs index 9c8c02d..62ed56e 100644 --- a/samples/TestServerWithHosting/Tools/SampleLlmTool.cs +++ b/samples/TestServerWithHosting/Tools/SampleLlmTool.cs @@ -8,23 +8,17 @@ namespace TestServerWithHosting.Tools; /// This tool uses depenency injection and async method /// [McpServerToolType] -public class SampleLlmTool +public static class SampleLlmTool { - private readonly IMcpServer _server; - - public SampleLlmTool(IMcpServer server) - { - _server = server ?? throw new ArgumentNullException(nameof(server)); - } - [McpServerTool("sampleLLM"), Description("Samples from an LLM using MCP's sampling feature")] - public async Task SampleLLM( + public static async Task SampleLLM( + IMcpServer thisServer, [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); - var sampleResult = await _server.RequestSamplingAsync(samplingParams, cancellationToken); + var sampleResult = await thisServer.RequestSamplingAsync(samplingParams, cancellationToken); return $"LLM sampling result: {sampleResult.Content.Text}"; }