1use serde::{Deserialize, Serialize};
4
5use super::AppEvent;
6use crate::ports::McpErrorInfo;
7
8#[derive(Debug, Clone, Serialize, Deserialize)]
12#[serde(rename_all = "camelCase")]
13pub struct McpServerSummary {
14 pub id: i64,
16 pub name: String,
18 pub server_type: String,
20}
21
22impl McpServerSummary {
23 pub fn new(id: i64, name: impl Into<String>, server_type: impl Into<String>) -> Self {
25 Self {
26 id,
27 name: name.into(),
28 server_type: server_type.into(),
29 }
30 }
31}
32
33impl AppEvent {
34 pub const fn mcp_server_added(server: McpServerSummary) -> Self {
36 Self::McpServerAdded { server }
37 }
38
39 pub const fn mcp_server_removed(server_id: i64) -> Self {
41 Self::McpServerRemoved { server_id }
42 }
43
44 pub fn mcp_server_started(server_id: i64, server_name: impl Into<String>) -> Self {
46 Self::McpServerStarted {
47 server_id,
48 server_name: server_name.into(),
49 }
50 }
51
52 pub fn mcp_server_stopped(server_id: i64, server_name: impl Into<String>) -> Self {
54 Self::McpServerStopped {
55 server_id,
56 server_name: server_name.into(),
57 }
58 }
59
60 pub const fn mcp_server_error(error: McpErrorInfo) -> Self {
62 Self::McpServerError { error }
63 }
64}