pub struct McpServer { /* private fields */ }Expand description
Our MCP server implementation.
Implementations§
Source§impl McpServer
impl McpServer
Sourcepub fn instructions(self, instructions: impl ToString) -> Self
pub fn instructions(self, instructions: impl ToString) -> Self
Set the server instructions that are provided to the client.
Sourcepub fn tool_fn<P, R, F, H>(
self,
name: impl ToString,
description: impl ToString,
func: F,
to_future_hack: H,
) -> Selfwhere
P: JsonSchema + DeserializeOwned + 'static + Send,
R: JsonSchema + Serialize + 'static + Send,
F: AsyncFn(P, McpContext) -> Result<R, Error> + Send + Sync + 'static,
H: Fn(&F, P, McpContext) -> BoxFuture<'_, Result<R, Error>> + Send + Sync + 'static,
pub fn tool_fn<P, R, F, H>(
self,
name: impl ToString,
description: impl ToString,
func: F,
to_future_hack: H,
) -> Selfwhere
P: JsonSchema + DeserializeOwned + 'static + Send,
R: JsonSchema + Serialize + 'static + Send,
F: AsyncFn(P, McpContext) -> Result<R, Error> + Send + Sync + 'static,
H: Fn(&F, P, McpContext) -> BoxFuture<'_, Result<R, Error>> + Send + Sync + 'static,
Convenience wrapper for defining a tool without having to create a struct.
§Parameters
name: The name of the tool.description: The description of the tool.func: The function that implements the tool. Use an async closure likeasync |args, cx| { .. }.to_future_hack: A function that converts the tool function into a future. You should always write|t, args, cx| Box::pin(t(args, cx)). This is needed to sidestep current Rust language limitations.
§Examples
Trait Implementations§
Auto Trait Implementations§
impl Freeze for McpServer
impl !RefUnwindSafe for McpServer
impl Send for McpServer
impl Sync for McpServer
impl Unpin for McpServer
impl !UnwindSafe for McpServer
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