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

Function runMigrate

src/commands/mcp.ts:317–416  ·  view source on GitHub ↗

`orbcode mcp migrate [--all] [--dry-run]` — copy MCP servers from Claude * Code / Claude Desktop into `~/.orbcode/settings.json` (user scope). * Without `--all`, prints a preview and exits 0. `--dry-run` is a read-only * preview even with `--all`. Name conflicts are silently skipped.

(args: string[])

Source from the content-addressed store, hash-verified

315 * Without `--all`, prints a preview and exits 0. `--dry-run` is a read-only
316 * preview even with `--all`. Name conflicts are silently skipped. */
317function runMigrate(args: string[]): number {
318 let migrateAll = false
319 let dryRun = false
320 for (const arg of args) {
321 if (arg === "--all" || arg === "-a") migrateAll = true
322 else if (arg === "--dry-run" || arg === "-n") dryRun = true
323 else if (arg === "--help" || arg === "-h") {
324 console.log("orbcode mcp migrate [--all] [--dry-run]\n")
325 console.log("Import MCP servers from Claude Code / Claude Desktop into")
326 console.log("~/.orbcode/settings.json (user scope).")
327 console.log("")
328 console.log(" --all, -a import every detected server (default: preview only)")
329 console.log(" --dry-run, -n show what would be imported, never write")
330 return 0
331 } else {
332 console.error(`Unknown flag: ${arg}. Try: orbcode mcp migrate --help`)
333 return 1
334 }
335 }
336
337 const sources = discoverSources()
338 if (sources.length === 0) {
339 console.log("No MCP server sources found on this machine.")
340 console.log("")
341 console.log("Searched:")
342 console.log(" - ~/.claude/settings.json (Claude Code, user scope)")
343 console.log(" - ~/.claude.json -> root mcpServers (Claude Code, user scope)")
344 console.log(" - ~/.claude.json -> projects.<cwd>.mcpServers (Claude Code, this project)")
345 console.log(" - Claude Desktop config (claude_desktop_config.json)")
346 return 0
347 }
348
349 const entries = listMigrationEntries()
350 if (entries.length === 0) {
351 console.log("Found MCP server source files, but none contain server entries.")
352 return 0
353 }
354
355 // Always show what we found, so the user knows where the data is coming from.
356 console.log("Detected MCP server sources:")
357 for (const source of sources) {
358 const count = Object.keys(source.servers).length
359 console.log(` ${source.label.padEnd(28)} ${count} server${count === 1 ? "" : "s"}`)
360 console.log(` ${source.configPath}`)
361 }
362 console.log("")
363
364 // If `--all` was passed, copy everything. Otherwise preview and exit.
365 const toApply = migrateAll ? entries : []
366
367 // Always classify skipped (name conflicts) so the user sees the dry-run
368 // impact, not just the would-be additions.
369 const { skipped } = applyMigrationDryRun(entries)
370
371 if (!migrateAll) {
372 console.log("Preview — no files modified. Pass --all to apply.")
373 console.log("")
374 console.log("Servers that would be imported:")

Callers 1

runMcpCommandFunction · 0.85

Calls 5

discoverSourcesFunction · 0.85
listMigrationEntriesFunction · 0.85
applyMigrationDryRunFunction · 0.85
describeEntryFunction · 0.85
applyMigrationFunction · 0.85

Tested by

no test coverage detected