MCPcopy Index your code
hub / github.com/anomalyco/opencode / resolveConfigPath

Function resolveConfigPath

packages/opencode/src/cli/cmd/mcp.ts:394–410  ·  view source on GitHub ↗
(baseDir: string, global = false)

Source from the content-addressed store, hash-verified

392})
393
394async function resolveConfigPath(baseDir: string, global = false) {
395 // Check for existing config files (prefer .jsonc over .json, check .opencode/ subdirectory too)
396 const candidates = [path.join(baseDir, "opencode.json"), path.join(baseDir, "opencode.jsonc")]
397
398 if (!global) {
399 candidates.push(path.join(baseDir, ".opencode", "opencode.json"), path.join(baseDir, ".opencode", "opencode.jsonc"))
400 }
401
402 for (const candidate of candidates) {
403 if (await Filesystem.exists(candidate)) {
404 return candidate
405 }
406 }
407
408 // Default to opencode.json if none exist
409 return candidates[0]
410}
411
412async function addMcpToConfig(name: string, mcpConfig: ConfigMCPV1.Info, configPath: string) {
413 let text = "{}"

Callers 1

mcp.tsFile · 0.85

Calls 2

pushMethod · 0.80
existsMethod · 0.45

Tested by

no test coverage detected