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:
Andrew Phillips
2025-09-10 14:29:16 -03:00
parent d44f3fbb5b
commit 88c7290a7b
6 changed files with 146 additions and 12 deletions

View File

@@ -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);