Update tests for @modelcontextprotocol/server-everything 2026.1.26 (#1273)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
This commit is contained in:
parent
ec4c732632
commit
a502efb703
1 changed files with 107 additions and 78 deletions
|
|
@ -142,8 +142,8 @@ internal static class Program
|
|||
},
|
||||
new Tool
|
||||
{
|
||||
Name = "sampleLLM",
|
||||
Description = "Samples from an LLM using MCP's sampling feature.",
|
||||
Name = "trigger-sampling-request",
|
||||
Description = "Trigger a Request from the Server for LLM Sampling",
|
||||
InputSchema = JsonElement.Parse("""
|
||||
{
|
||||
"type": "object",
|
||||
|
|
@ -205,7 +205,7 @@ internal static class Program
|
|||
Content = [new TextContentBlock { Text = request.Server.SessionId ?? string.Empty }]
|
||||
};
|
||||
}
|
||||
else if (request.Params?.Name == "sampleLLM")
|
||||
else if (request.Params?.Name == "trigger-sampling-request")
|
||||
{
|
||||
if (request.Params?.Arguments is null ||
|
||||
!request.Params.Arguments.TryGetValue("prompt", out var prompt) ||
|
||||
|
|
@ -213,7 +213,7 @@ internal static class Program
|
|||
{
|
||||
throw new McpProtocolException("Missing required arguments 'prompt' and 'maxTokens'", McpErrorCode.InvalidParams);
|
||||
}
|
||||
var sampleResult = await request.Server.SampleAsync(CreateRequestSamplingParams(prompt.ToString(), "sampleLLM", Convert.ToInt32(maxTokens.GetRawText())),
|
||||
var sampleResult = await request.Server.SampleAsync(CreateRequestSamplingParams(prompt.ToString(), "trigger-sampling-request", Convert.ToInt32(maxTokens.GetRawText())),
|
||||
cancellationToken: cancellationToken);
|
||||
|
||||
return new CallToolResult
|
||||
|
|
@ -257,28 +257,48 @@ internal static class Program
|
|||
Prompts = [
|
||||
new Prompt
|
||||
{
|
||||
Name = "simple_prompt",
|
||||
Name = "simple-prompt",
|
||||
Description = "A prompt without arguments"
|
||||
},
|
||||
new Prompt
|
||||
{
|
||||
Name = "complex_prompt",
|
||||
Name = "args-prompt",
|
||||
Description = "A prompt with arguments",
|
||||
Arguments =
|
||||
[
|
||||
new PromptArgument
|
||||
{
|
||||
Name = "temperature",
|
||||
Description = "Temperature setting",
|
||||
Name = "city",
|
||||
Description = "Name of the city",
|
||||
Required = true
|
||||
},
|
||||
new PromptArgument
|
||||
{
|
||||
Name = "style",
|
||||
Description = "Output style",
|
||||
Name = "state",
|
||||
Description = "Name of the state",
|
||||
Required = false
|
||||
}
|
||||
]
|
||||
},
|
||||
new Prompt
|
||||
{
|
||||
Name = "completable-prompt",
|
||||
Description = "A prompt with completable arguments",
|
||||
Arguments =
|
||||
[
|
||||
new PromptArgument
|
||||
{
|
||||
Name = "department",
|
||||
Description = "Choose the department",
|
||||
Required = true
|
||||
},
|
||||
new PromptArgument
|
||||
{
|
||||
Name = "name",
|
||||
Description = "Choose a team member",
|
||||
Required = true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
|
|
@ -287,7 +307,7 @@ internal static class Program
|
|||
options.Handlers.GetPromptHandler = async (request, cancellationToken) =>
|
||||
{
|
||||
List<PromptMessage> messages = [];
|
||||
if (request.Params?.Name == "simple_prompt")
|
||||
if (request.Params?.Name == "simple-prompt")
|
||||
{
|
||||
messages.Add(new PromptMessage
|
||||
{
|
||||
|
|
@ -295,28 +315,25 @@ internal static class Program
|
|||
Content = new TextContentBlock { Text = "This is a simple prompt without arguments." },
|
||||
});
|
||||
}
|
||||
else if (request.Params?.Name == "complex_prompt")
|
||||
else if (request.Params?.Name == "args-prompt")
|
||||
{
|
||||
string temperature = request.Params.Arguments?["temperature"].ToString() ?? "unknown";
|
||||
string style = request.Params.Arguments?["style"].ToString() ?? "unknown";
|
||||
string city = request.Params.Arguments?["city"].ToString() ?? "unknown";
|
||||
string state = request.Params.Arguments?["state"].ToString() ?? "";
|
||||
string location = !string.IsNullOrEmpty(state) ? $"{city}, {state}" : city;
|
||||
messages.Add(new PromptMessage
|
||||
{
|
||||
Role = Role.User,
|
||||
Content = new TextContentBlock { Text = $"This is a complex prompt with arguments: temperature={temperature}, style={style}" },
|
||||
});
|
||||
messages.Add(new PromptMessage
|
||||
{
|
||||
Role = Role.Assistant,
|
||||
Content = new TextContentBlock { Text = "I understand. You've provided a complex prompt with temperature and style arguments. How would you like me to proceed?" },
|
||||
Content = new TextContentBlock { Text = $"What's weather in {location}?" },
|
||||
});
|
||||
}
|
||||
else if (request.Params?.Name == "completable-prompt")
|
||||
{
|
||||
string department = request.Params.Arguments?["department"].ToString() ?? "unknown";
|
||||
string name = request.Params.Arguments?["name"].ToString() ?? "unknown";
|
||||
messages.Add(new PromptMessage
|
||||
{
|
||||
Role = Role.User,
|
||||
Content = new ImageContentBlock
|
||||
{
|
||||
Data = MCP_TINY_IMAGE,
|
||||
MimeType = "image/png"
|
||||
}
|
||||
Content = new TextContentBlock { Text = $"Please promote {name} to the head of the {department} team." },
|
||||
});
|
||||
}
|
||||
else
|
||||
|
|
@ -516,8 +533,8 @@ internal static class Program
|
|||
List<string> sampleResourceIds = ["1", "2", "3", "4", "5"];
|
||||
Dictionary<string, List<string>> exampleCompletions = new()
|
||||
{
|
||||
{"style", ["casual", "formal", "technical", "friendly"]},
|
||||
{"temperature", ["0", "0.5", "0.7", "1.0"]},
|
||||
{"department", ["Engineering", "Sales", "Marketing", "Support"]},
|
||||
{"name", ["Alice", "Bob", "Charlie"]},
|
||||
};
|
||||
|
||||
options.Handlers.CompleteHandler = async (request, cancellationToken) =>
|
||||
|
|
|
|||
Loading…
Reference in a new issue