@@ -9,6 +9,7 @@ type Props = {
99
1010type FlatItem =
1111 | { kind : "server" ; status : McpServerStatus ; serverIndex : number }
12+ | { kind : "error" ; error : string ; serverName : string }
1213 | { kind : "tool" ; name : string ; serverName : string }
1314 | { kind : "prompt" ; name : string ; serverName : string }
1415 | { kind : "resource" ; name : string ; serverName : string } ;
@@ -18,6 +19,10 @@ function buildFlatItems(statuses: McpServerStatus[]): FlatItem[] {
1819 for ( let i = 0 ; i < statuses . length ; i ++ ) {
1920 const status = statuses [ i ] ;
2021 items . push ( { kind : "server" , status, serverIndex : i } ) ;
22+ // 为失败的服务添加错误消息
23+ if ( status . status === "failed" && status . error ) {
24+ items . push ( { kind : "error" , error : status . error , serverName : status . name } ) ;
25+ }
2126 if ( status . status === "ready" ) {
2227 for ( const tool of status . tools ) {
2328 items . push ( { kind : "tool" , name : tool , serverName : status . name } ) ;
@@ -99,11 +104,17 @@ export function McpStatusList({ statuses, onCancel }: Props): React.ReactElement
99104
100105 if ( statuses . length === 0 ) {
101106 return (
102- < Box flexDirection = "column" >
103- < Text color = "yellow" > Manage MCP servers</ Text >
104- < Text color = "yellow" > 0 servers</ Text >
105- < Text color = "yellow" > No MCP servers configured.</ Text >
106- < Text color = "yellow" > Add MCP servers to your settings to get started.</ Text >
107+ < Box flexDirection = "column" marginLeft = { 1 } paddingX = { 1 } gap = { 1 } borderStyle = "round" borderDimColor >
108+ < Box flexDirection = "column" >
109+ < Text color = "#229ac3" bold >
110+ Manage MCP servers
111+ </ Text >
112+ < Text dimColor > 0 servers</ Text >
113+ </ Box >
114+ < Box flexDirection = "column" >
115+ < Text dimColor > No MCP servers configured.</ Text >
116+ < Text dimColor > Add MCP servers to your settings to get started.</ Text >
117+ </ Box >
107118 < Text dimColor > Esc to close</ Text >
108119 </ Box >
109120 ) ;
@@ -149,6 +160,9 @@ export function McpStatusList({ statuses, onCancel }: Props): React.ReactElement
149160 if ( item . kind === "server" ) {
150161 return < ServerRow key = { `server-${ item . status . name } ` } status = { item . status } selected = { isSelected } /> ;
151162 }
163+ if ( item . kind === "error" ) {
164+ return < ErrorRow key = { `error-${ item . serverName } ` } error = { item . error } /> ;
165+ }
152166 return (
153167 < CapabilityRow
154168 key = { `${ item . kind } -${ item . name } ` }
@@ -209,11 +223,28 @@ function CapabilityRow({
209223} ) : React . ReactElement {
210224 const prefix = kind === "tool" ? "🔧" : kind === "prompt" ? "📝" : "📦" ;
211225 return (
212- < Box height = { 1 } >
226+ < Box height = { 1 } marginLeft = { 2 } >
213227 < Text color = "#229ac3" > { selected ? "› " : " " } </ Text >
214228 < Text dimColor >
215229 { prefix } { name }
216230 </ Text >
217231 </ Box >
218232 ) ;
219233}
234+
235+ function ErrorRow ( { error } : { error : string } ) : React . ReactElement {
236+ // 将错误消息按行分割,每行单独显示
237+ const lines = error . split ( "\n" ) . filter ( ( line ) => line . trim ( ) . length > 0 ) ;
238+
239+ return (
240+ < Box flexDirection = "column" marginLeft = { 2 } marginTop = { 0 } marginBottom = { 1 } >
241+ { lines . map ( ( line , index ) => (
242+ < Box key = { index } >
243+ < Text color = "red" dimColor >
244+ { line }
245+ </ Text >
246+ </ Box >
247+ ) ) }
248+ </ Box >
249+ ) ;
250+ }
0 commit comments