feat(SEP-973): add support for icons and websiteUrl across relevant types (#432)
This commit is contained in:
parent
6fbd941a32
commit
b57aa47693
2 changed files with 611 additions and 63 deletions
|
|
@ -16,6 +16,8 @@ pub struct PromptAttribute {
|
|||
pub description: Option<String>,
|
||||
/// Arguments that can be passed to the prompt
|
||||
pub arguments: Option<Expr>,
|
||||
/// Optional icons for the prompt
|
||||
pub icons: Option<Expr>,
|
||||
}
|
||||
|
||||
pub struct ResolvedPromptAttribute {
|
||||
|
|
@ -23,6 +25,7 @@ pub struct ResolvedPromptAttribute {
|
|||
pub title: Option<String>,
|
||||
pub description: Option<String>,
|
||||
pub arguments: Expr,
|
||||
pub icons: Option<Expr>,
|
||||
}
|
||||
|
||||
impl ResolvedPromptAttribute {
|
||||
|
|
@ -32,6 +35,7 @@ impl ResolvedPromptAttribute {
|
|||
description,
|
||||
arguments,
|
||||
title,
|
||||
icons,
|
||||
} = self;
|
||||
let description = if let Some(description) = description {
|
||||
quote! { Some(#description.into()) }
|
||||
|
|
@ -43,6 +47,11 @@ impl ResolvedPromptAttribute {
|
|||
} else {
|
||||
quote! { None }
|
||||
};
|
||||
let icons = if let Some(icons) = icons {
|
||||
quote! { Some(#icons) }
|
||||
} else {
|
||||
quote! { None }
|
||||
};
|
||||
let tokens = quote! {
|
||||
pub fn #fn_ident() -> rmcp::model::Prompt {
|
||||
rmcp::model::Prompt {
|
||||
|
|
@ -50,6 +59,7 @@ impl ResolvedPromptAttribute {
|
|||
description: #description,
|
||||
arguments: #arguments,
|
||||
title: #title,
|
||||
icons: #icons,
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -98,6 +108,7 @@ pub fn prompt(attr: TokenStream, input: TokenStream) -> syn::Result<TokenStream>
|
|||
description: description.clone(),
|
||||
arguments: arguments.clone(),
|
||||
title: attribute.title,
|
||||
icons: attribute.icons,
|
||||
};
|
||||
let prompt_attr_fn = resolved_prompt_attr.into_fn(prompt_attr_fn_ident.clone())?;
|
||||
|
||||
|
|
|
|||
|
|
@ -75,6 +75,8 @@ pub struct ToolAttribute {
|
|||
pub output_schema: Option<Expr>,
|
||||
/// Optional additional tool information.
|
||||
pub annotations: Option<ToolAnnotationsAttribute>,
|
||||
/// Optional icons for the tool
|
||||
pub icons: Option<Expr>,
|
||||
}
|
||||
|
||||
pub struct ResolvedToolAttribute {
|
||||
|
|
@ -84,6 +86,7 @@ pub struct ResolvedToolAttribute {
|
|||
pub input_schema: Expr,
|
||||
pub output_schema: Option<Expr>,
|
||||
pub annotations: Expr,
|
||||
pub icons: Option<Expr>,
|
||||
}
|
||||
|
||||
impl ResolvedToolAttribute {
|
||||
|
|
@ -95,6 +98,7 @@ impl ResolvedToolAttribute {
|
|||
input_schema,
|
||||
output_schema,
|
||||
annotations,
|
||||
icons,
|
||||
} = self;
|
||||
let description = if let Some(description) = description {
|
||||
quote! { Some(#description.into()) }
|
||||
|
|
@ -111,6 +115,11 @@ impl ResolvedToolAttribute {
|
|||
} else {
|
||||
quote! { None }
|
||||
};
|
||||
let icons = if let Some(icons) = icons {
|
||||
quote! { Some(#icons) }
|
||||
} else {
|
||||
quote! { None }
|
||||
};
|
||||
let tokens = quote! {
|
||||
pub fn #fn_ident() -> rmcp::model::Tool {
|
||||
rmcp::model::Tool {
|
||||
|
|
@ -120,6 +129,7 @@ impl ResolvedToolAttribute {
|
|||
input_schema: #input_schema,
|
||||
output_schema: #output_schema,
|
||||
annotations: #annotations,
|
||||
icons: #icons,
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -240,6 +250,7 @@ pub fn tool(attr: TokenStream, input: TokenStream) -> syn::Result<TokenStream> {
|
|||
output_schema: output_schema_expr,
|
||||
annotations: annotations_expr,
|
||||
title: attribute.title,
|
||||
icons: attribute.icons,
|
||||
};
|
||||
let tool_attr_fn = resolved_tool_attr.into_fn(tool_attr_fn_ident)?;
|
||||
// modify the the input function
|
||||
|
|
|
|||
Loading…
Reference in a new issue