use crate::mcp_server::server_runtime_core::RuntimeCoreInternalHandler;
use crate::mcp_traits::McpServer;
use crate::mcp_traits::{McpServerHandler, ToMcpServerHandlerCore};
use crate::schema::*;
use async_trait::async_trait;
use std::sync::Arc;
#[async_trait]
pub trait ServerHandlerCore: Send + Sync + 'static {
async fn on_initialized(&self, _runtime: Arc<dyn McpServer>) {}
async fn handle_request(
&self,
request: RequestFromClient,
runtime: Arc<dyn McpServer>,
) -> std::result::Result<ResultFromServer, RpcError>;
async fn handle_notification(
&self,
notification: NotificationFromClient,
runtime: Arc<dyn McpServer>,
) -> std::result::Result<(), RpcError>;
async fn handle_error(
&self,
error: &RpcError,
runtime: Arc<dyn McpServer>,
) -> std::result::Result<(), RpcError>;
}
impl<T: ServerHandlerCore + 'static> ToMcpServerHandlerCore for T {
fn to_mcp_server_handler(self) -> Arc<dyn McpServerHandler + 'static> {
Arc::new(RuntimeCoreInternalHandler::new(Box::new(self)))
}
}