pub struct Prompt {
pub name: String,
pub descr: Option<String>,
pub args: Option<Vec<PromptArgument>>,
pub title: Option<String>,
pub icons: Option<Vec<Icon>>,
pub meta: Option<Value>,
/* private fields */
}Expand description
A prompt or prompt template that the server offers.
See the schema for details
Fields§
§name: StringThe name of the prompt or prompt template.
descr: Option<String>An optional description of what this prompt provides
args: Option<Vec<PromptArgument>>A list of arguments to use for templating the prompt.
title: Option<String>Intended for UI and end-user contexts - optimized to be human-readable and easily understood, even by those unfamiliar with domain-specific terminology.
If not provided, the name should be used for display (except for Tool,
where annotations.title should be given precedence over using name, if present).
icons: Option<Vec<Icon>>Optional set of sized icons that the client can display in a user interface.
Clients that support rendering icons MUST support at least the following MIME types:
image/png- PNG images (safe, universal compatibility)image/jpeg(andimage/jpg) - JPEG images (safe, universal compatibility)
Clients that support rendering icons SHOULD also support:
image/svg+xml- SVG images (scalable but requires security precautions)image/webp- WebP images (modern, efficient format)
meta: Option<Value>Metadata reserved by MCP for protocol-level metadata.
Implementations§
Source§impl Prompt
impl Prompt
Sourcepub fn new<F, R, Args>(name: impl Into<String>, handler: F) -> Selfwhere
F: PromptHandler<Args, Output = R>,
R: TryInto<GetPromptResult> + Send + 'static,
R::Error: Into<Error>,
Args: FromHandlerArgs<GetPromptRequestParams> + Send + Sync + 'static,
pub fn new<F, R, Args>(name: impl Into<String>, handler: F) -> Selfwhere
F: PromptHandler<Args, Output = R>,
R: TryInto<GetPromptResult> + Send + 'static,
R::Error: Into<Error>,
Args: FromHandlerArgs<GetPromptRequestParams> + Send + Sync + 'static,
Creates a new Prompt
Sourcepub fn with_title(&mut self, title: impl Into<String>) -> &mut Self
pub fn with_title(&mut self, title: impl Into<String>) -> &mut Self
Sets a Prompt title
Sourcepub fn with_description(&mut self, descr: impl Into<String>) -> &mut Self
pub fn with_description(&mut self, descr: impl Into<String>) -> &mut Self
Sets a Prompt description
Sourcepub fn with_args<T, A>(&mut self, args: T) -> &mut Self
pub fn with_args<T, A>(&mut self, args: T) -> &mut Self
Sets arguments for the Prompt
The list is both what a peer sees in prompts/list and what the
handler’s arguments are extracted by: the n-th argument here names
the value the handler’s n-th value-carrying parameter reads. Setting
it therefore cannot leave the published arguments and the handler
disagreeing.
Parameters served from request metadata – crate::types::Meta,
Context, a DI-injected Dc<T> – are not arguments and are not
listed here. An Option<T> parameter is: list it with
PromptArgument::optional or PromptArgument::named so peers know
they may leave it out.
§Example
use neva::{App, types::Role};
let mut app = App::new();
app.map_prompt("analyze", |lang: String, code: String| async move {
(format!("Analyze this {lang} code: {code}"), Role::User)
})
.with_args(["lang", "code"]);
Sourcepub fn with_icons(&mut self, icons: impl IntoIterator<Item = Icon>) -> &mut Self
pub fn with_icons(&mut self, icons: impl IntoIterator<Item = Icon>) -> &mut Self
Sets the Prompt icons
Sourcepub fn with_roles<T, I>(&mut self, roles: T) -> &mut Self
pub fn with_roles<T, I>(&mut self, roles: T) -> &mut Self
Sets a list of roles that are allowed to get the prompt
Sourcepub fn with_permissions<T, I>(&mut self, permissions: T) -> &mut Self
pub fn with_permissions<T, I>(&mut self, permissions: T) -> &mut Self
Sets a list of permissions that are allowed to get the prompt