Enable .NET SDK code analyzers (#41)

This commit is contained in:
Stephen Toub 2025-03-08 11:18:09 -05:00 • committed by GitHub
commit 587e05f057
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 301 additions and 151 deletions

View file

@ -5,7 +5,7 @@ namespace TestServerWithHosting.Tools;
[McpToolType]
public static class EchoTool
{
[McpTool(Description = "Echoes the input back to the client.")]
[McpTool(description: "Echoes the input back to the client.")]
public static string Echo([McpParameter(true)] string message)
{
return "hello " + message;

View file

@ -16,8 +16,11 @@ public class SampleLlmTool
_server = server ?? throw new ArgumentNullException(nameof(server));
}
[McpTool(Name = "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, CancellationToken cancellationToken)
[McpTool(name: "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,
CancellationToken cancellationToken)
{
var samplingParams = CreateRequestSamplingParams(prompt ?? string.Empty, "sampleLLM", maxTokens);
var sampleResult = await _server.RequestSamplingAsync(samplingParams, cancellationToken);