pub struct McpServer { /* private fields */ }Expand description
MCP Server that exposes tools, resources, and prompts
Implementations§
Source§impl McpServer
impl McpServer
Sourcepub fn with_config(config: ServerConfig) -> Self
pub fn with_config(config: ServerConfig) -> Self
Create a server with custom configuration
Sourcepub fn builder() -> McpServerBuilder
pub fn builder() -> McpServerBuilder
Create a builder for the server
Sourcepub fn tool_count(&self) -> usize
pub fn tool_count(&self) -> usize
Get the number of registered tools
Sourcepub fn add_tool(&self, handler: impl ToolHandler + 'static)
pub fn add_tool(&self, handler: impl ToolHandler + 'static)
Register a tool handler
Sourcepub fn set_resource_handler(&self, handler: impl ResourceHandler + 'static)
pub fn set_resource_handler(&self, handler: impl ResourceHandler + 'static)
Register a resource handler
Sourcepub fn set_prompt_handler(&self, handler: impl PromptHandler + 'static)
pub fn set_prompt_handler(&self, handler: impl PromptHandler + 'static)
Register a prompt handler
Sourcepub async fn run_stdio(self: Arc<Self>) -> Result<(), McpError>
pub async fn run_stdio(self: Arc<Self>) -> Result<(), McpError>
Run the server with STDIO transport
Sourcepub async fn handle_request(&self, request: JsonRpcRequest) -> JsonRpcResponse
pub async fn handle_request(&self, request: JsonRpcRequest) -> JsonRpcResponse
Handle a JSON-RPC request
Source§impl McpServer
impl McpServer
Sourcepub fn http_router(self: Arc<Self>, config: HttpServerConfig) -> Router
pub fn http_router(self: Arc<Self>, config: HttpServerConfig) -> Router
Build an Axum router with HTTP endpoints for Meridian integration.
Endpoints:
GET /health— Health checkGET /tools— Plain JSON tool listPOST /mcp— JSON-RPC endpointPOST /call-tool— Simplified tool call
Source§impl McpServer
impl McpServer
Sourcepub async fn run_sse(
self: Arc<Self>,
config: SseServerConfig,
) -> Result<(), McpError>
pub async fn run_sse( self: Arc<Self>, config: SseServerConfig, ) -> Result<(), McpError>
Run the server with SSE transport
This starts an HTTP server with:
- GET /sse - SSE endpoint for server-to-client streaming
- POST /message - Endpoint for client-to-server requests
Sourcepub fn sse_router(self: Arc<Self>, config: SseServerConfig) -> Router
pub fn sse_router(self: Arc<Self>, config: SseServerConfig) -> Router
Run the server with SSE transport and return the router (for embedding in existing Axum applications)
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 UnsafeUnpin 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