@@ -110,6 +110,7 @@ pub mod types;
110110
111111use std:: collections:: HashMap ;
112112use std:: path:: PathBuf ;
113+ use std:: time:: Duration ;
113114
114115use actor:: {
115116 McpServerActor ,
@@ -251,8 +252,11 @@ impl McpManagerHandle {
251252 }
252253 }
253254
254- pub async fn recv ( & mut self ) -> Result < McpServerActorEvent , RecvError > {
255- self . mcp_main_loop_to_handle_server_event_rx . recv ( ) . await
255+ pub async fn recv ( & mut self ) -> Result < McpServerEvent , RecvError > {
256+ self . mcp_main_loop_to_handle_server_event_rx
257+ . recv ( )
258+ . await
259+ . map ( |evt| evt. into ( ) )
256260 }
257261}
258262
@@ -461,3 +465,49 @@ pub enum McpManagerError {
461465 #[ error( "{}" , . 0 ) ]
462466 Custom ( String ) ,
463467}
468+
469+ /// MCP events relevant to agent operations.
470+ /// Provides abstraction over [McpServerActorEvent] to avoid leaking implementation details.
471+ #[ derive( Debug , Clone , Serialize , Deserialize ) ]
472+ pub enum McpServerEvent {
473+ /// The MCP server has launched successfully
474+ Initialized {
475+ server_name : String ,
476+ /// Time taken to launch the server
477+ serve_duration : Duration ,
478+ /// Time taken to list all tools.
479+ ///
480+ /// None if the server does not support tools, or there was an error fetching tools.
481+ list_tools_duration : Option < Duration > ,
482+ /// Time taken to list all prompts
483+ ///
484+ /// None if the server does not support prompts, or there was an error fetching prompts.
485+ list_prompts_duration : Option < Duration > ,
486+ } ,
487+ /// The MCP server failed to initialize successfully
488+ InitializeError { server_name : String , error : String } ,
489+ /// An OAuth authentication request from the MCP server
490+ OauthRequest { server_name : String , oauth_url : String } ,
491+ }
492+
493+ impl From < McpServerActorEvent > for McpServerEvent {
494+ fn from ( value : McpServerActorEvent ) -> Self {
495+ match value {
496+ McpServerActorEvent :: Initialized {
497+ server_name,
498+ serve_duration,
499+ list_tools_duration,
500+ list_prompts_duration,
501+ } => Self :: Initialized {
502+ server_name,
503+ serve_duration,
504+ list_tools_duration,
505+ list_prompts_duration,
506+ } ,
507+ McpServerActorEvent :: InitializeError { server_name, error } => Self :: InitializeError { server_name, error } ,
508+ McpServerActorEvent :: OauthRequest { server_name, oauth_url } => {
509+ Self :: OauthRequest { server_name, oauth_url }
510+ } ,
511+ }
512+ }
513+ }
0 commit comments