(self, session: &mut ChatSession)
| 24 | |
| 25 | impl McpArgs { |
| 26 | pub async fn execute(self, session: &mut ChatSession) -> Result<ChatState, ChatError> { |
| 27 | if !session.conversation.mcp_enabled { |
| 28 | queue!( |
| 29 | session.stderr, |
| 30 | StyledText::warning_fg(), |
| 31 | style::Print("\n"), |
| 32 | style::Print("⚠️ WARNING: "), |
| 33 | StyledText::reset(), |
| 34 | style::Print("MCP functionality has been disabled by your administrator.\n\n"), |
| 35 | )?; |
| 36 | session.stderr.flush()?; |
| 37 | return Ok(ChatState::PromptUser { |
| 38 | skip_printing_tools: true, |
| 39 | }); |
| 40 | } |
| 41 | |
| 42 | let terminal_width = session.terminal_width(); |
| 43 | let still_loading = session |
| 44 | .conversation |
| 45 | .tool_manager |
| 46 | .pending_clients() |
| 47 | .await |
| 48 | .into_iter() |
| 49 | .map(|name| format!(" - {name}\n")) |
| 50 | .collect::<Vec<_>>() |
| 51 | .join(""); |
| 52 | |
| 53 | for (server_name, msg) in session.conversation.tool_manager.mcp_load_record.lock().await.iter() { |
| 54 | let msg = msg |
| 55 | .iter() |
| 56 | .map(|record| match record { |
| 57 | LoadingRecord::Err(timestamp, content) |
| 58 | | LoadingRecord::Warn(timestamp, content) |
| 59 | | LoadingRecord::Success(timestamp, content) => format!("[{timestamp}]: {content}"), |
| 60 | }) |
| 61 | .collect::<Vec<_>>() |
| 62 | .join("\n--- tools refreshed ---\n"); |
| 63 | |
| 64 | queue!( |
| 65 | session.stderr, |
| 66 | style::Print(server_name), |
| 67 | style::Print("\n"), |
| 68 | style::Print(format!("{}\n", "▔".repeat(terminal_width))), |
| 69 | style::Print(msg), |
| 70 | style::Print("\n") |
| 71 | )?; |
| 72 | } |
| 73 | |
| 74 | if !still_loading.is_empty() { |
| 75 | queue!( |
| 76 | session.stderr, |
| 77 | style::Print("Still loading:\n"), |
| 78 | style::Print(format!("{}\n", "▔".repeat(terminal_width))), |
| 79 | style::Print(still_loading), |
| 80 | style::Print("\n") |
| 81 | )?; |
| 82 | } |
| 83 |
nothing calls this directly
no test coverage detected