@@ -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 ,
@@ -254,8 +255,11 @@ impl McpManagerHandle {
254255 }
255256 }
256257
257- pub async fn recv ( & mut self ) -> Result < McpServerActorEvent , RecvError > {
258- self . mcp_main_loop_to_handle_server_event_rx . recv ( ) . await
258+ pub async fn recv ( & mut self ) -> Result < McpServerEvent , RecvError > {
259+ self . mcp_main_loop_to_handle_server_event_rx
260+ . recv ( )
261+ . await
262+ . map ( |evt| evt. into ( ) )
259263 }
260264}
261265
@@ -464,3 +468,49 @@ pub enum McpManagerError {
464468 #[ error( "{}" , . 0 ) ]
465469 Custom ( String ) ,
466470}
471+
472+ /// MCP events relevant to agent operations.
473+ /// Provides abstraction over [McpServerActorEvent] to avoid leaking implementation details.
474+ #[ derive( Debug , Clone , Serialize , Deserialize ) ]
475+ pub enum McpServerEvent {
476+ /// The MCP server has launched successfully
477+ Initialized {
478+ server_name : String ,
479+ /// Time taken to launch the server
480+ serve_duration : Duration ,
481+ /// Time taken to list all tools.
482+ ///
483+ /// None if the server does not support tools, or there was an error fetching tools.
484+ list_tools_duration : Option < Duration > ,
485+ /// Time taken to list all prompts
486+ ///
487+ /// None if the server does not support prompts, or there was an error fetching prompts.
488+ list_prompts_duration : Option < Duration > ,
489+ } ,
490+ /// The MCP server failed to initialize successfully
491+ InitializeError { server_name : String , error : String } ,
492+ /// An OAuth authentication request from the MCP server
493+ OauthRequest { server_name : String , oauth_url : String } ,
494+ }
495+
496+ impl From < McpServerActorEvent > for McpServerEvent {
497+ fn from ( value : McpServerActorEvent ) -> Self {
498+ match value {
499+ McpServerActorEvent :: Initialized {
500+ server_name,
501+ serve_duration,
502+ list_tools_duration,
503+ list_prompts_duration,
504+ } => Self :: Initialized {
505+ server_name,
506+ serve_duration,
507+ list_tools_duration,
508+ list_prompts_duration,
509+ } ,
510+ McpServerActorEvent :: InitializeError { server_name, error } => Self :: InitializeError { server_name, error } ,
511+ McpServerActorEvent :: OauthRequest { server_name, oauth_url } => {
512+ Self :: OauthRequest { server_name, oauth_url }
513+ } ,
514+ }
515+ }
516+ }
0 commit comments