Update content according to latest spec (#513)
* Update content according to latest spec * Add Title to a bunch of types * Add _meta to lots of types * Address feedback, more cleanup, fix NAOT test failure
This commit is contained in:
parent
28d65470f4
commit
2bcff315f8
1 changed files with 1700 additions and 853 deletions
|
|
@ -46,11 +46,7 @@ public class Program
|
|||
Messages = [new SamplingMessage()
|
||||
{
|
||||
Role = Role.User,
|
||||
Content = new Content()
|
||||
{
|
||||
Type = "text",
|
||||
Text = $"Resource {uri} context: {context}"
|
||||
}
|
||||
Content = new TextContentBlock { Text = $"Resource {uri} context: {context}" },
|
||||
}],
|
||||
SystemPrompt = "You are a helpful test server.",
|
||||
MaxTokens = maxTokens,
|
||||
|
|
@ -173,16 +169,16 @@ public class Program
|
|||
{
|
||||
throw new McpException("Missing required argument 'message'", McpErrorCode.InvalidParams);
|
||||
}
|
||||
return new CallToolResponse()
|
||||
return new CallToolResult()
|
||||
{
|
||||
Content = [new Content() { Text = "Echo: " + message.ToString(), Type = "text" }]
|
||||
Content = [new TextContentBlock { Text = $"Echo: {message}" }]
|
||||
};
|
||||
}
|
||||
else if (request.Params.Name == "echoSessionId")
|
||||
{
|
||||
return new CallToolResponse()
|
||||
return new CallToolResult()
|
||||
{
|
||||
Content = [new Content() { Text = request.Server.SessionId, Type = "text" }]
|
||||
Content = [new TextContentBlock { Text = request.Server.SessionId ?? string.Empty }]
|
||||
};
|
||||
}
|
||||
else if (request.Params.Name == "sampleLLM")
|
||||
|
|
@ -196,9 +192,9 @@ public class Program
|
|||
var sampleResult = await request.Server.SampleAsync(CreateRequestSamplingParams(prompt.ToString(), "sampleLLM", Convert.ToInt32(maxTokens.ToString())),
|
||||
cancellationToken);
|
||||
|
||||
return new CallToolResponse()
|
||||
return new CallToolResult()
|
||||
{
|
||||
Content = [new Content() { Text = $"LLM sampling result: {sampleResult.Content.Text}", Type = "text" }]
|
||||
Content = [new TextContentBlock { Text = $"LLM sampling result: {(sampleResult.Content as TextContentBlock)?.Text}" }]
|
||||
};
|
||||
}
|
||||
else
|
||||
|
|
@ -308,8 +304,8 @@ public class Program
|
|||
{
|
||||
Name = "complex_prompt",
|
||||
Description = "A prompt with arguments",
|
||||
Arguments = new()
|
||||
{
|
||||
Arguments =
|
||||
[
|
||||
new PromptArgument()
|
||||
{
|
||||
Name = "temperature",
|
||||
|
|
@ -322,7 +318,7 @@ public class Program
|
|||
Description = "Output style",
|
||||
Required = false
|
||||
}
|
||||
}
|
||||
],
|
||||
}
|
||||
]
|
||||
};
|
||||
|
|
@ -339,11 +335,7 @@ public class Program
|
|||
messages.Add(new PromptMessage()
|
||||
{
|
||||
Role = Role.User,
|
||||
Content = new Content()
|
||||
{
|
||||
Type = "text",
|
||||
Text = "This is a simple prompt without arguments."
|
||||
}
|
||||
Content = new TextContentBlock { Text = "This is a simple prompt without arguments." },
|
||||
});
|
||||
}
|
||||
else if (request.Params.Name == "complex_prompt")
|
||||
|
|
@ -353,27 +345,18 @@ public class Program
|
|||
messages.Add(new PromptMessage()
|
||||
{
|
||||
Role = Role.User,
|
||||
Content = new Content()
|
||||
{
|
||||
Type = "text",
|
||||
Text = $"This is a complex prompt with arguments: temperature={temperature}, style={style}"
|
||||
}
|
||||
Content = new TextContentBlock { Text = $"This is a complex prompt with arguments: temperature={temperature}, style={style}" },
|
||||
});
|
||||
messages.Add(new PromptMessage()
|
||||
{
|
||||
Role = Role.Assistant,
|
||||
Content = new Content()
|
||||
{
|
||||
Type = "text",
|
||||
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 = "I understand. You've provided a complex prompt with temperature and style arguments. How would you like me to proceed?" },
|
||||
});
|
||||
messages.Add(new PromptMessage()
|
||||
{
|
||||
Role = Role.User,
|
||||
Content = new Content()
|
||||
Content = new ImageContentBlock()
|
||||
{
|
||||
Type = "image",
|
||||
Data = MCP_TINY_IMAGE,
|
||||
MimeType = "image/png"
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue