MCPcopy Create free account
hub / github.com/arctic-cli/interface / saveMcpConfig

Function saveMcpConfig

packages/arctic/src/cli/cmd/mcp.ts:345–372  ·  view source on GitHub ↗
(mcpConfig: Config.Mcp)

Source from the content-addressed store, hash-verified

343 const isLocal = args.local
344
345 const saveMcpConfig = async (mcpConfig: Config.Mcp) => {
346 const config = await Config.get()
347 if (config.mcp?.[name]) {
348 prompts.log.warn(`Overwriting existing MCP server: ${name}`)
349 }
350
351 if (isLocal) {
352 // save to project config
353 await Config.update({
354 mcp: {
355 [name]: mcpConfig,
356 },
357 })
358 } else {
359 // save to global config
360 const globalConfigPath = path.join(Global.Path.config, "arctic.json")
361 const globalConfigText = await Bun.file(globalConfigPath).text().catch(() => "{}")
362 const globalConfig = JSON.parse(globalConfigText)
363
364 if (!globalConfig.mcp) {
365 globalConfig.mcp = {}
366 }
367 globalConfig.mcp[name] = mcpConfig
368 globalConfig.$schema = "https://usearctic.sh/config.json"
369
370 await Bun.write(globalConfigPath, JSON.stringify(globalConfig, null, 2))
371 }
372 }
373
374 // local MCP server (stdio)
375 if (rawCommand.length > 0) {

Callers 1

fnFunction · 0.85

Calls 3

textMethod · 0.65
getMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected