* Load MCP configuration from project + user level. * Project config overrides user config for same server names.
()
| 34 | * Project config overrides user config for same server names. |
| 35 | */ |
| 36 | loadConfig() { |
| 37 | const configPaths = [ |
| 38 | path.join(os.homedir(), '.config', 'smallcode', 'mcp.json'), |
| 39 | path.join(this.projectDir, '.smallcode', 'mcp.json'), |
| 40 | ]; |
| 41 | |
| 42 | for (const configPath of configPaths) { |
| 43 | if (!fs.existsSync(configPath)) continue; |
| 44 | try { |
| 45 | const content = JSON.parse(fs.readFileSync(configPath, 'utf-8')); |
| 46 | const servers = content.mcpServers || {}; |
| 47 | for (const [name, cfg] of Object.entries(servers)) { |
| 48 | if (cfg.disabled) continue; |
| 49 | this.servers.set(name, { |
| 50 | config: { |
| 51 | name, |
| 52 | command: cfg.command || '', |
| 53 | args: cfg.args || [], |
| 54 | env: cfg.env || {}, |
| 55 | autoApprove: cfg.autoApprove || [], |
| 56 | }, |
| 57 | process: null, |
| 58 | connected: false, |
| 59 | tools: [], |
| 60 | }); |
| 61 | } |
| 62 | } catch {} |
| 63 | } |
| 64 | |
| 65 | return this.servers.size; |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Connect to all configured servers and discover their tools. |
no outgoing calls
no test coverage detected