Skip to content

Commit 9c0d741

Browse files
committed
fix: typescript complaints
1 parent a2ac0c5 commit 9c0d741

File tree

3 files changed

+45
-9
lines changed

3 files changed

+45
-9
lines changed

src/bin/cli.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22
import { MCPFiles } from '../main.ts'
33
import { RenderService } from '../services/render-service.ts'
44

5+
interface MCPServerInfo {
6+
name: string
7+
command: string
8+
args?: string[]
9+
transport?: 'stdio' | 'sse'
10+
env?: Record<string, string>
11+
status?: 'running' | 'stopped'
12+
}
13+
514
// Start the CLI with a new line for better readability
615
console.log()
716

@@ -31,7 +40,7 @@ async function init () {
3140
const mcpServers = filePathData.servers || []
3241

3342
const totalMCPServers = filePathData.servers ? filePathData.servers.length : 0
34-
const totalMCPServersRunning = mcpServers.filter(server => server.status === 'running').length
43+
const totalMCPServersRunning = mcpServers.filter((server: MCPServerInfo) => server.status === 'running').length
3544

3645
const mcpGroupData = [
3746
{ key: 'PROVIDER', value: group.friendlyName },
@@ -54,5 +63,4 @@ async function init () {
5463
}
5564
}
5665

57-
await init()
58-
console.log()
66+
init()

src/main.ts

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,31 @@ interface MCPServerInfo {
1313

1414
interface MCPFilePath {
1515
filePath: string
16-
type: 'local' | 'global',
16+
type: 'local' | 'global'
17+
parsable?: boolean
1718
servers?: MCPServerInfo[]
1819
}
1920

2021
interface MCPFileGroups {
2122
name: string
2223
friendlyName: string
2324
paths: MCPFilePath[]
25+
stats?: {
26+
serversCount?: number
27+
}
28+
}
29+
30+
interface MCPFileGroupsResult {
31+
name: string
32+
friendlyName: string
33+
paths: MCPFilePath[]
34+
stats: {
35+
serversCount?: number
36+
}
2437
}
2538

2639
type MCPFilePathGroupsRecord = Record<string, MCPFileGroups>
40+
type MCPFileGroupsResultRecord = Record<string, MCPFileGroupsResult>
2741

2842
export class MCPFiles {
2943
private mcpFilePathGroups: MCPFilePathGroupsRecord = {
@@ -48,8 +62,8 @@ export class MCPFiles {
4862
this.mcpFilePathGroups = mcpFilePathGroups || this.mcpFilePathGroups
4963
}
5064

51-
async findFiles (): Promise<T> {
52-
const mcpFilesPathsData = {}
65+
async findFiles (): Promise<MCPFileGroupsResultRecord> {
66+
const mcpFilesPathsData: MCPFileGroupsResultRecord = {}
5367

5468
for (const groupName of Object.keys(this.mcpFilePathGroups)) {
5569
const clientsGroup = this.mcpFilePathGroups[groupName]
@@ -73,7 +87,14 @@ export class MCPFiles {
7387
const mcpServersFromConfig = await MCPConfigLinter.getMCPServers()
7488
// let's iterate over the mcpServer Record and access the server objects
7589
for (const serverName of Object.keys(mcpServersFromConfig)) {
76-
const serverConfig = { ...mcpServersFromConfig[serverName], name: serverName }
90+
const serverConfigRaw = mcpServersFromConfig[serverName] as any
91+
const serverConfig = {
92+
name: serverName,
93+
command: serverConfigRaw.command || '',
94+
args: serverConfigRaw.args,
95+
transport: serverConfigRaw.transport,
96+
env: serverConfigRaw.env
97+
}
7798
const MCPServerManager = new MCPServerManagerService(serverConfig)
7899

79100
mcpServersData.push({

src/services/render-service.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ import MCPServerNameComponent from '../components/mcp-server-name.js'
66
import FilePathComponent from '../components/file-path.js'
77
import MCPServersConfigParsableComponent from '../components/mcp-servers-config-parsable.js'
88

9+
interface GroupMetadata {
10+
mcpServersRunning?: number
11+
mcpServersTotal?: number
12+
}
13+
914
export class RenderService {
1015
// Example mocked data for rendering the servers information
1116
// const mcpServersDataMock = [
@@ -101,7 +106,7 @@ export class RenderService {
101106
// { key: 'STATUS', value: '[✓ VALID] [GLOBAL] [5 MCP SERVERS]' }
102107
// ]
103108

104-
static printMcpGroup (id: number, data: any[], groupMetadata: object = {}) {
109+
static printMcpGroup (id: number, data: any[], groupMetadata: GroupMetadata = {}) {
105110
if (data.length === 0) return
106111

107112
console.log('\n')
@@ -118,7 +123,9 @@ export class RenderService {
118123

119124
// Append group metadata keys to the data array
120125
if (Object.keys(groupMetadata).length > 0) {
121-
const metadataRow = this.renderProgressBar(groupMetadata.mcpServersRunning, groupMetadata.mcpServersTotal, 'Running')
126+
const runningCount = groupMetadata.mcpServersRunning || 0
127+
const totalCount = groupMetadata.mcpServersTotal || 0
128+
const metadataRow = this.renderProgressBar(runningCount, totalCount, 'Running')
122129
data.push({ key: 'MCP SERVERS', value: metadataRow })
123130
}
124131

0 commit comments

Comments
 (0)