pub struct McpServer { /* private fields */ }Expand description
A synchronous MCP server that handles JSON-RPC 2.0 messages.
Holds loaded code graphs and dispatches tool/resource/prompt requests to the appropriate handler.
Implementations§
Source§impl McpServer
impl McpServer
Sourcepub fn load_graph(&mut self, name: String, graph: CodeGraph)
pub fn load_graph(&mut self, name: String, graph: CodeGraph)
Load a code graph into the server under the given name.
Sourcepub fn unload_graph(&mut self, name: &str) -> Option<CodeGraph>
pub fn unload_graph(&mut self, name: &str) -> Option<CodeGraph>
Remove a loaded code graph.
Sourcepub fn get_graph(&self, name: &str) -> Option<&CodeGraph>
pub fn get_graph(&self, name: &str) -> Option<&CodeGraph>
Get a reference to a loaded graph by name.
Sourcepub fn graph_names(&self) -> Vec<&str>
pub fn graph_names(&self) -> Vec<&str>
List all loaded graph names.
Sourcepub fn is_initialized(&self) -> bool
pub fn is_initialized(&self) -> bool
Check if the server has been initialised.
Sourcepub fn handle_raw(&mut self, raw: &str) -> String
pub fn handle_raw(&mut self, raw: &str) -> String
Handle a raw JSON-RPC message string.
Parses the message, dispatches to the appropriate handler, and returns the serialised JSON-RPC response.
Sourcepub fn handle_request(&mut self, request: JsonRpcRequest) -> JsonRpcResponse
pub fn handle_request(&mut self, request: JsonRpcRequest) -> JsonRpcResponse
Handle a parsed JSON-RPC request.
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