Skip to content

Commit 40deb95

Browse files
committed
fix: dont display file paths if servers empty even if same group
Signed-off-by: Liran Tal <liran.tal@gmail.com>
1 parent 4355710 commit 40deb95

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

src/bin/cli.ts

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,21 @@ async function init () {
7878
if (group.paths.length > 0) {
7979
// handle file path list of MCP Servers
8080
for (const filePathData of group.paths) {
81+
const totalMCPServers = filePathData.servers ? filePathData.servers.length : 0
82+
83+
// Skip file paths with zero servers unless --all is specified or in --files mode
84+
const shouldSkipFile = !showAll && !isCustomFilesMode && totalMCPServers === 0
85+
if (shouldSkipFile) {
86+
continue
87+
}
88+
8189
pathIndex++
8290

8391
const filePath = filePathData.filePath.replace('~', process.env.HOME || '')
8492
const filePathValid = filePathData.parsable ? 'VALID' : 'INVALID'
8593
const filePathDataType = filePathData.type.toUpperCase()
8694
const mcpServers = filePathData.servers || []
8795

88-
const totalMCPServers = filePathData.servers ? filePathData.servers.length : 0
8996
const totalMCPServersRunning = mcpServers.filter((server: MCPServerInfo) => server.status === 'running').length
9097

9198
// Accumulate summary statistics
@@ -157,12 +164,24 @@ async function init () {
157164
// Filter out providers with zero servers unless --all is specified or in --files mode
158165
const isCustomFilesMode = customFiles && customFiles.length > 0
159166
const filteredMcpFiles = Object.fromEntries(
160-
Object.entries(mcpFilesList).filter(([, group]) => {
161-
if (showAll || isCustomFilesMode) {
167+
Object.entries(mcpFilesList)
168+
.map(([groupName, group]) => {
169+
// Filter individual file paths with zero servers unless --all or --files mode
170+
const filteredPaths = group.paths.filter(filePathData => {
171+
const fileServerCount = filePathData.servers ? filePathData.servers.length : 0
172+
if (showAll || isCustomFilesMode) {
173+
return true // Keep all files
174+
}
175+
return fileServerCount > 0 // Only keep files with servers
176+
})
177+
178+
return [groupName, { ...group, paths: filteredPaths }] as const
179+
})
180+
.filter((entry): entry is [string, typeof entry[1]] => {
181+
// After filtering file paths, remove groups with no remaining paths
182+
const [, group] = entry
162183
return group.paths.length > 0
163-
}
164-
return (group.stats?.serversCount ?? 0) > 0
165-
})
184+
})
166185
)
167186

168187
const output = {

0 commit comments

Comments
 (0)