1+ import { styleText } from 'node:util'
12import TransportComponent from '../components/transport.js'
23import ColumnNameComponent from '../components/column-name.js'
34import MCPServerStatusComponent from '../components/mcp-server-status.js'
@@ -100,7 +101,7 @@ export class RenderService {
100101 // { key: 'STATUS', value: '[✓ VALID] [GLOBAL] [5 MCP SERVERS]' }
101102 // ]
102103
103- static printMcpGroup ( id : number , data : any [ ] ) {
104+ static printMcpGroup ( id : number , data : any [ ] , groupMetadata : object = { } ) {
104105 if ( data . length === 0 ) return
105106
106107 console . log ( '\n' )
@@ -115,6 +116,12 @@ export class RenderService {
115116 const leftPaddingGroupLead = indexText + ' ' . repeat ( 6 - indexText . length )
116117 const leftPaddingGroupData = ' ' . repeat ( 6 )
117118
119+ // Append group metadata keys to the data array
120+ if ( Object . keys ( groupMetadata ) . length > 0 ) {
121+ const metadataRow = this . renderProgressBar ( groupMetadata . mcpServersRunning , groupMetadata . mcpServersTotal , 'Running' )
122+ data . push ( { key : 'MCP SERVERS' , value : metadataRow } )
123+ }
124+
118125 // Calculate column widths
119126 const columnWidths = headers . map ( ( header , index ) => {
120127 const dataWidth = Math . max ( ...data . map ( row => {
@@ -150,4 +157,25 @@ export class RenderService {
150157 // Print bottom separator
151158 // console.log('')
152159 }
160+
161+ // draws progress bar components like this
162+ // "███████░░░░░░░░░░░░░ 3 / 9 Running"
163+ static renderProgressBar ( count : number , total : number , label : string , width : number = 20 ) : string {
164+ if ( total === 0 ) {
165+ const emptyBar = '░' . repeat ( width )
166+ return `${ emptyBar } 0 / 0 ${ label } `
167+ }
168+
169+ const progress = Math . min ( count / total , 1 )
170+ const filledWidth = Math . round ( progress * width )
171+ const emptyWidth = width - filledWidth
172+
173+ const colorRunning = count > 0 ? 'greenBright' : 'red'
174+ const colorEmpty = count > 0 ? 'green' : 'red'
175+
176+ const filled = styleText ( [ colorRunning ] , '█' . repeat ( filledWidth ) )
177+ const empty = styleText ( [ colorEmpty ] , '░' . repeat ( emptyWidth ) )
178+
179+ return `${ filled } ${ empty } ${ count } / ${ total } ${ label } `
180+ }
153181}
0 commit comments