MCPcopy Create free account
hub / github.com/MatterAIOrg/OrbCode / loadMcpConfig

Function loadMcpConfig

src/mcp/config.ts:174–198  ·  view source on GitHub ↗
(cwd = process.cwd())

Source from the content-addressed store, hash-verified

172 * higher-precedence scopes override earlier ones on name collisions.
173 */
174export function loadMcpConfig(cwd = process.cwd()): ResolvedMcpConfig {
175 const servers: Record<string, ScopedMcpServerConfig> = {}
176
177 // 1. User scope (~/.orbcode/settings.json -> mcpServers)
178 const userServers = readSettingsServers(path.join(getConfigDir(), "settings.json"))
179 for (const [name, cfg] of Object.entries(userServers)) {
180 servers[name] = { ...cfg, scope: "user" as McpScope }
181 }
182
183 // 2. Project scope (.mcp.json, root -> cwd so cwd wins)
184 for (const dir of ancestorDirs(cwd).reverse()) {
185 const projectServers = readMcpJson(path.join(dir, ".mcp.json"))
186 for (const [name, cfg] of Object.entries(projectServers)) {
187 servers[name] = { ...cfg, scope: "project" as McpScope }
188 }
189 }
190
191 // 3. Local scope (.orbcode/settings.json -> mcpServers) — highest precedence
192 const localServers = readSettingsServers(path.join(cwd, ".orbcode", "settings.json"))
193 for (const [name, cfg] of Object.entries(localServers)) {
194 servers[name] = { ...cfg, scope: "local" as McpScope }
195 }
196
197 return { servers }
198}
199
200/** Write a `.mcp.json` file in the cwd (project scope). */
201export function writeProjectMcpJson(cwd: string, servers: Record<string, McpServerConfig>): void {

Callers 3

runListFunction · 0.85
startMethod · 0.85
findServerScopeFunction · 0.85

Calls 4

readSettingsServersFunction · 0.85
getConfigDirFunction · 0.85
readMcpJsonFunction · 0.85
ancestorDirsFunction · 0.70

Tested by

no test coverage detected