Skip to content

Commit 65777a6

Browse files
committed
feat: group files per their mcp client/app
1 parent d85d45f commit 65777a6

File tree

3 files changed

+69
-27
lines changed

3 files changed

+69
-27
lines changed

eslint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default [
2222
'security/detect-eval-with-expression': 'error',
2323
'security/detect-no-csrf-before-method-override': 'error',
2424
'security/detect-non-literal-regexp': 'error',
25-
'security/detect-object-injection': 'warn',
25+
'security/detect-object-injection': 'off',
2626
'security/detect-possible-timing-attacks': 'error',
2727
'security/detect-pseudoRandomBytes': 'error',
2828
'space-before-function-paren': 'off',

src/bin/cli.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,24 @@ async function init () {
1313

1414
const formatter = new FormatterService()
1515

16-
if (mcpFilesList.length > 0) {
17-
console.log('MCP files found:')
18-
mcpFilesList.forEach(filePath => {
19-
console.log(`- ${formatter.filePathToTerminal(filePath)}`)
20-
})
21-
} else {
16+
if (Object.keys(mcpFilesList).length === 0) {
2217
console.log('No MCP files found.')
18+
return
19+
}
20+
21+
for (const groupName of Object.keys(mcpFilesList)) {
22+
const group = mcpFilesList[groupName]
23+
console.log(`\n${group.friendlyName} (${group.name}):`)
24+
if (group.paths.length >= 0) {
25+
group.paths.forEach(filePathData => {
26+
const filePath = filePathData.filePath.replace('~', process.env.HOME || '')
27+
console.log(`- ${formatter.filePathToTerminal(filePath)} (${filePathData.type})`)
28+
})
29+
} else {
30+
console.log('No files found in this group.')
31+
}
2332
}
2433
}
2534

26-
init()
35+
await init()
36+
console.log()

src/main.ts

Lines changed: 51 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,63 @@
11
import fs from 'node:fs/promises'
22

3-
export class MCPFiles {
4-
private mcpFilePaths: string[] = [
3+
interface MCPFilePath {
4+
filePath: string
5+
type: 'relative' | 'global'
6+
}
57

6-
'~/Library/Application Support/Claude/claude_desktop_config.json',
7-
'.cursor/mcp.json',
8-
'~/.cursor/mcp.json',
8+
interface MCPFileGroups {
9+
name: string
10+
friendlyName: string
11+
paths: MCPFilePath[]
12+
}
913

10-
]
14+
type MCPFilePathGroupsRecord = Record<string, MCPFileGroups>
1115

12-
constructor (mcpFilePaths?: string[]) {
13-
if (mcpFilePaths) {
14-
this.mcpFilePaths = mcpFilePaths
16+
export class MCPFiles {
17+
private mcpFilePathGroups: MCPFilePathGroupsRecord = {
18+
claude: {
19+
name: 'claude',
20+
friendlyName: 'Claude Desktop',
21+
paths: [
22+
{ filePath: '~/Library/Application Support/Claude/claude_desktop_config.json', type: 'global' },
23+
]
24+
},
25+
cursor: {
26+
name: 'cursor',
27+
friendlyName: 'Cursor',
28+
paths: [
29+
{ filePath: '.cursor/mcp.json', type: 'relative' },
30+
{ filePath: '~/.cursor/mcp.json', type: 'global' },
31+
]
1532
}
1633
}
1734

18-
async findFiles (): Promise<string[]> {
19-
const files: string[] = []
20-
for (const filePath of this.mcpFilePaths) {
21-
try {
22-
const resolvedPath = filePath.replace('~', process.env.HOME || '')
23-
await fs.access(resolvedPath)
24-
files.push(resolvedPath)
25-
} catch (error) {
26-
// File does not exist, continue to next
35+
constructor (mcpFilePathGroups?: MCPFilePathGroupsRecord) {
36+
this.mcpFilePathGroups = mcpFilePathGroups || this.mcpFilePathGroups
37+
}
38+
39+
async findFiles (): Promise<T> {
40+
const mcpFilesPathsData = {}
41+
42+
for (const groupName of Object.keys(this.mcpFilePathGroups)) {
43+
const clientsGroup = this.mcpFilePathGroups[groupName]
44+
mcpFilesPathsData[groupName] = {
45+
name: clientsGroup.name,
46+
friendlyName: clientsGroup.friendlyName,
47+
paths: []
48+
}
49+
50+
for (const filePathData of clientsGroup.paths) {
51+
const resolvedPath = filePathData.filePath.replace('~', process.env.HOME || '')
52+
try {
53+
await fs.access(resolvedPath)
54+
mcpFilesPathsData[groupName].paths.push(filePathData)
55+
} catch (error) {
56+
// File does not exist, continue to next
57+
}
2758
}
2859
}
29-
return files
60+
61+
return mcpFilesPathsData
3062
}
3163
}

0 commit comments

Comments
 (0)