pub struct Server { /* private fields */ }Expand description
A registered MCP server.
Registrations live in BTreeMaps so tools/list comes back in a stable
order — an agent that re-reads the list should not see it shuffle.
Implementations§
Source§impl Server
impl Server
pub fn new(name: impl Into<String>, version: impl Into<String>) -> Self
Sourcepub fn instructions(self, instructions: impl Into<String>) -> Self
pub fn instructions(self, instructions: impl Into<String>) -> Self
Advice shown to the model once, at the start of a session.
pub fn tool(self, tool: Tool) -> Self
pub fn resource(self, resource: Resource) -> Self
pub fn prompt(self, prompt: Prompt) -> Self
pub fn name(&self) -> &str
pub fn tool_names(&self) -> Vec<&str>
Sourcepub fn capabilities(&self) -> Json
pub fn capabilities(&self) -> Json
What this server advertises during the handshake.
Only the capabilities that are actually backed by a registration are
announced: a client that sees tools and gets an empty list has been
told something untrue.
Sourcepub async fn handle_text(&self, text: &str) -> Option<String>
pub async fn handle_text(&self, text: &str) -> Option<String>
Handle one complete transport frame, batches included.
None means there is nothing to send back — the frame held only
notifications, which JSON-RPC answers with silence.
Sourcepub async fn handle_value(&self, value: &Json) -> Option<Json>
pub async fn handle_value(&self, value: &Json) -> Option<Json>
Handle one decoded message, returning the answer it deserves.
Auto Trait Implementations§
impl !RefUnwindSafe for Server
impl !UnwindSafe for Server
impl Freeze for Server
impl Send for Server
impl Sync for Server
impl Unpin for Server
impl UnsafeUnpin for Server
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more