pub struct McpServer { /* private fields */ }Expand description
MCP Server implementation
Implementations§
Source§impl McpServer
impl McpServer
Sourcepub fn new(transport: Arc<dyn Transport>) -> Self
pub fn new(transport: Arc<dyn Transport>) -> Self
Create a new MCP server with custom transport
Sourcepub async fn register_tool(
&self,
name: &str,
description: &str,
input_schema: Value,
handler: Arc<dyn Fn(Value) -> Result<CallToolResult> + Send + Sync>,
)
pub async fn register_tool( &self, name: &str, description: &str, input_schema: Value, handler: Arc<dyn Fn(Value) -> Result<CallToolResult> + Send + Sync>, )
Register a tool
Sourcepub async fn register_resource(
&self,
uri: &str,
name: &str,
description: &str,
mime_type: Option<&str>,
handler: Arc<dyn Fn(String) -> Result<ReadResourceResult> + Send + Sync>,
)
pub async fn register_resource( &self, uri: &str, name: &str, description: &str, mime_type: Option<&str>, handler: Arc<dyn Fn(String) -> Result<ReadResourceResult> + Send + Sync>, )
Register a resource
Sourcepub async fn get_tool_metadata(&self, name: &str) -> Option<ToolMetadata>
pub async fn get_tool_metadata(&self, name: &str) -> Option<ToolMetadata>
Get tool metadata by name
Sourcepub async fn get_all_tool_metadata(&self) -> Vec<ToolMetadata>
pub async fn get_all_tool_metadata(&self) -> Vec<ToolMetadata>
Get all tool metadata
Sourcepub async fn get_resource_metadata(&self, uri: &str) -> Option<ResourceMetadata>
pub async fn get_resource_metadata(&self, uri: &str) -> Option<ResourceMetadata>
Get resource metadata by URI
Sourcepub async fn get_all_resource_metadata(&self) -> Vec<ResourceMetadata>
pub async fn get_all_resource_metadata(&self) -> Vec<ResourceMetadata>
Get all resource metadata
Sourcepub async fn register_prompt(
&self,
name: &str,
handler: Arc<dyn Fn(Value) -> Result<GetPromptResult> + Send + Sync>,
)
pub async fn register_prompt( &self, name: &str, handler: Arc<dyn Fn(Value) -> Result<GetPromptResult> + Send + Sync>, )
Register a prompt handler
Sourcepub async fn get_prompt_handler(
&self,
name: &str,
) -> Option<Arc<dyn Fn(Value) -> Result<GetPromptResult> + Send + Sync>>
pub async fn get_prompt_handler( &self, name: &str, ) -> Option<Arc<dyn Fn(Value) -> Result<GetPromptResult> + Send + Sync>>
Get a prompt handler by name
Sourcepub async fn list_prompts(&self) -> Vec<String>
pub async fn list_prompts(&self) -> Vec<String>
List all registered prompt names
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more