Skip to content

Commit 80f08d6

Browse files
suryaiyer95claude
andcommitted
fix: fall back to global config when not in a git repo
`mcp add` and `mcp remove` now auto-detect when `cwd` is not inside a git project and write to the global config instead of trying to create `/altimate-code.json`. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d395384 commit 80f08d6

File tree

1 file changed

+8
-6
lines changed
  • packages/altimate-code/src/cli/cmd

1 file changed

+8
-6
lines changed

packages/altimate-code/src/cli/cmd/mcp.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -453,9 +453,10 @@ export const McpAddCommand = cmd({
453453
async fn() {
454454
// Non-interactive mode: all required args provided via flags
455455
if (args.name && args.type) {
456+
const useGlobal = args.global || Instance.project.vcs !== "git"
456457
const configPath = await resolveConfigPath(
457-
args.global ? Global.Path.config : Instance.worktree,
458-
args.global,
458+
useGlobal ? Global.Path.config : Instance.worktree,
459+
useGlobal,
459460
)
460461

461462
let mcpConfig: Config.Mcp
@@ -674,9 +675,10 @@ export const McpRemoveCommand = cmd({
674675
await Instance.provide({
675676
directory: process.cwd(),
676677
async fn() {
678+
const useGlobal = args.global || Instance.project.vcs !== "git"
677679
const configPath = await resolveConfigPath(
678-
args.global ? Global.Path.config : Instance.worktree,
679-
args.global,
680+
useGlobal ? Global.Path.config : Instance.worktree,
681+
useGlobal,
680682
)
681683

682684
const removed = await removeMcpFromConfig(args.name, configPath)
@@ -685,8 +687,8 @@ export const McpRemoveCommand = cmd({
685687
} else {
686688
// Try the other scope
687689
const otherPath = await resolveConfigPath(
688-
args.global ? Instance.worktree : Global.Path.config,
689-
!args.global,
690+
useGlobal ? Instance.worktree : Global.Path.config,
691+
!useGlobal,
690692
)
691693
const removedOther = await removeMcpFromConfig(args.name, otherPath)
692694
if (removedOther) {

0 commit comments

Comments
 (0)