Skip to content

Commit 81b8dab

Browse files
committed
vibecoded by gemini code assist
1 parent 75c919b commit 81b8dab

File tree

1 file changed

+17
-30
lines changed

1 file changed

+17
-30
lines changed

codeflash/cli_cmds/cmd_init.py

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,46 +1265,33 @@ def prompt_claude_mcp_setup() -> None:
12651265

12661266
def add_mcp_server_to_claude_config() -> None:
12671267
"""Add the Codeflash MCP server to Claude Code configuration."""
1268-
# Try to find Claude Code config directory
1269-
home_dir = Path.home()
1270-
claude_config_dirs = [
1271-
home_dir / ".config" / "claude-code",
1272-
home_dir / ".claude-code",
1273-
home_dir / "Library" / "Application Support" / "claude-code", # macOS
1274-
]
1275-
1276-
claude_config_dir = None
1277-
for config_dir in claude_config_dirs:
1278-
if config_dir.exists():
1279-
claude_config_dir = config_dir
1280-
break
1281-
1282-
# If no existing config directory found, create one
1283-
if not claude_config_dir:
1284-
claude_config_dir = home_dir / ".config" / "claude-code"
1285-
claude_config_dir.mkdir(parents=True, exist_ok=True)
1286-
console.print(f"📁 Created Claude Code config directory: {claude_config_dir}")
1287-
1288-
config_file = claude_config_dir / "mcp_servers.json"
1289-
1290-
# Get the absolute path to myserver.py
1291-
myserver_path = Path.cwd() / "myserver.py"
1268+
claude_config_dir = Path.cwd()
1269+
config_file = claude_config_dir / ".mcp.json"
12921270

12931271
# Create MCP server configuration
1294-
server_config = {"codeflash": {"command": "python", "args": [str(myserver_path.absolute())], "env": {}}}
1272+
# TODO we assume uv exists,
1273+
codeflash_server_entry = {
1274+
"codeflash": {
1275+
"type": "stdio",
1276+
"command": "uv",
1277+
"args": ["run", "--directory", str(claude_config_dir), "myserver.py"],
1278+
"env": {},
1279+
}
1280+
}
12951281

12961282
# Read existing config or create new one
12971283
if config_file.exists():
12981284
try:
12991285
with config_file.open("r", encoding="utf8") as f:
1300-
existing_config = json.load(f)
1301-
existing_config.update(server_config)
1302-
updated_config = existing_config
1286+
updated_config = json.load(f)
1287+
if "mcpServers" not in updated_config:
1288+
updated_config["mcpServers"] = {}
1289+
updated_config["mcpServers"].update(codeflash_server_entry)
13031290
except (json.JSONDecodeError, OSError) as e:
13041291
logger.warning(f"Could not read existing MCP config: {e}")
1305-
updated_config = server_config
1292+
updated_config = {"mcpServers": codeflash_server_entry}
13061293
else:
1307-
updated_config = server_config
1294+
updated_config = {"mcpServers": codeflash_server_entry}
13081295

13091296
# Write the updated configuration
13101297
try:

0 commit comments

Comments
 (0)