File tree 1 file changed +4
-10
lines changed
samples/TestServerWithHosting/Tools
1 file changed +4
-10
lines changed Original file line number Diff line number Diff line change @@ -8,23 +8,17 @@ namespace TestServerWithHosting.Tools;
8
8
/// This tool uses depenency injection and async method
9
9
/// </summary>
10
10
[ McpServerToolType ]
11
- public class SampleLlmTool
11
+ public static class SampleLlmTool
12
12
{
13
- private readonly IMcpServer _server ;
14
-
15
- public SampleLlmTool ( IMcpServer server )
16
- {
17
- _server = server ?? throw new ArgumentNullException ( nameof ( server ) ) ;
18
- }
19
-
20
13
[ McpServerTool ( "sampleLLM" ) , Description ( "Samples from an LLM using MCP's sampling feature" ) ]
21
- public async Task < string > SampleLLM (
14
+ public static async Task < string > SampleLLM (
15
+ IMcpServer thisServer ,
22
16
[ Description ( "The prompt to send to the LLM" ) ] string prompt ,
23
17
[ Description ( "Maximum number of tokens to generate" ) ] int maxTokens ,
24
18
CancellationToken cancellationToken )
25
19
{
26
20
var samplingParams = CreateRequestSamplingParams ( prompt ?? string . Empty , "sampleLLM" , maxTokens ) ;
27
- var sampleResult = await _server . RequestSamplingAsync ( samplingParams , cancellationToken ) ;
21
+ var sampleResult = await thisServer . RequestSamplingAsync ( samplingParams , cancellationToken ) ;
28
22
29
23
return $ "LLM sampling result: { sampleResult . Content . Text } ";
30
24
}
You can’t perform that action at this time.
0 commit comments