docs: Add comprehensive documentation for modes, services, and plugins
Co-authored-by: aider (openai/andrew/openrouter/sonoma-sky-alpha) <aider@aider.chat>
This commit is contained in:
@@ -5,15 +5,43 @@ use crate::modes::server::common::AppState;
|
||||
use super::tools::{KeepTools, ToolError};
|
||||
|
||||
#[derive(Clone)]
|
||||
/// Server handler for MCP (Model Context Protocol) requests.
|
||||
///
|
||||
/// Routes requests to appropriate tools and handles responses.
|
||||
pub struct KeepMcpServer {
|
||||
state: AppState,
|
||||
}
|
||||
|
||||
impl KeepMcpServer {
|
||||
/// Creates a new `KeepMcpServer` instance.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `state` - The application state containing DB and config.
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// A new `KeepMcpServer`.
|
||||
pub fn new(state: AppState) -> Self {
|
||||
Self { state }
|
||||
}
|
||||
|
||||
/// Handles an MCP request by routing to the appropriate tool.
|
||||
///
|
||||
/// Supports methods like save_item, get_item, etc.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `method` - The MCP method name.
|
||||
/// * `params` - Optional JSON parameters.
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// JSON string response on success, or ToolError.
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// Returns ToolError::UnknownTool for unsupported methods.
|
||||
pub async fn handle_request(&self, method: &str, params: Option<Value>) -> Result<String, ToolError> {
|
||||
debug!("MCP: Handling request '{}' with params: {:?}", method, params);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user