feat: add prompts support to mcp-client, ahere to MCP spec for prompts

- add new endpoints `list_prompts` and `get_prompt` in the MCP client
- update prompt model in mcp-core to make `description` and `arguments`
  optional, following MCP spec
This commit is contained in:
Kalvin Chau 2025-02-19 15:04:26 -08:00
commit 08b73f3001

View file

@ -305,18 +305,21 @@ pub trait Router: Send + Sync + 'static {
};
// Validate required arguments
for arg in &prompt.arguments {
if arg.required
&& (!arguments.contains_key(&arg.name)
|| arguments
.get(&arg.name)
.and_then(Value::as_str)
.is_none_or(str::is_empty))
{
return Err(RouterError::InvalidParams(format!(
"Missing required argument: '{}'",
arg.name
)));
if let Some(args) = &prompt.arguments {
for arg in args {
if arg.required.is_some()
&& arg.required.unwrap()
&& (!arguments.contains_key(&arg.name)
|| arguments
.get(&arg.name)
.and_then(Value::as_str)
.is_none_or(str::is_empty))
{
return Err(RouterError::InvalidParams(format!(
"Missing required argument: '{}'",
arg.name
)));
}
}
}