Skip to content

Commit 9da902e

Browse files
committed
Fix release binary naming and Codex CLI MCP registration
- Release workflow: build binary as `codebase-memory-mcp` (not `codebase-memory-mcp-<os>-<arch>`) inside tarballs. Users extract and get the correct name without renaming. - Codex CLI: replace broken `codex mcp add/remove` calls with direct config.toml manipulation. Codex uses [mcp_servers.<name>] sections, not CLI subcommands. - README: add explicit extract-and-move step to Quick Start.
1 parent e116ef6 commit 9da902e

3 files changed

Lines changed: 91 additions & 15 deletions

File tree

.github/workflows/release.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ jobs:
6262
run: |
6363
CGO_ENABLED=1 go build \
6464
-ldflags "-X main.version=${{ inputs.version }}" \
65-
-o codebase-memory-mcp-${{ matrix.goos }}-${{ matrix.goarch }} \
65+
-o codebase-memory-mcp \
6666
./cmd/codebase-memory-mcp/
6767
6868
- name: Create archive
69-
run: tar -czf codebase-memory-mcp-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz codebase-memory-mcp-${{ matrix.goos }}-${{ matrix.goarch }}
69+
run: tar -czf codebase-memory-mcp-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz codebase-memory-mcp
7070

7171
- uses: actions/upload-artifact@v4
7272
with:
@@ -101,12 +101,12 @@ jobs:
101101
run: |
102102
CGO_ENABLED=1 CC=gcc go build \
103103
-ldflags "-X main.version=${{ inputs.version }}" \
104-
-o codebase-memory-mcp-windows-amd64.exe \
104+
-o codebase-memory-mcp.exe \
105105
./cmd/codebase-memory-mcp/
106106
107107
- name: Create archive
108108
shell: pwsh
109-
run: Compress-Archive -Path codebase-memory-mcp-windows-amd64.exe -DestinationPath codebase-memory-mcp-windows-amd64.zip
109+
run: Compress-Archive -Path codebase-memory-mcp.exe -DestinationPath codebase-memory-mcp-windows-amd64.zip
110110

111111
- uses: actions/upload-artifact@v4
112112
with:

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,17 @@ Benchmarked on Apple M3 Pro, macOS Darwin 25.3.0:
7272
## Quick Start
7373

7474
1. **Download** the binary for your platform from the [latest release](https://github.com/DeusData/codebase-memory-mcp/releases/latest)
75-
2. **Install**:
75+
2. **Extract and move** to a directory on your PATH:
76+
```bash
77+
tar xzf codebase-memory-mcp-*.tar.gz
78+
mv codebase-memory-mcp ~/.local/bin/ # or /usr/local/bin/
79+
```
80+
3. **Install**:
7681
```bash
7782
codebase-memory-mcp install
7883
```
79-
3. **Restart** Claude Code / Codex CLI
80-
4. Say **"Index this project"** — done.
84+
4. **Restart** Claude Code / Codex CLI
85+
5. Say **"Index this project"** — done.
8186

8287
The `install` command auto-detects Claude Code and Codex CLI, registers the MCP server, installs 4 task-specific skills, and ensures the binary is on your PATH. Use `--dry-run` to preview without making changes.
8388

cmd/codebase-memory-mcp/install.go

Lines changed: 79 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func runUninstall(args []string) int {
8787
// Codex CLI MCP deregistration + instructions
8888
if codexPath := findCLI("codex"); codexPath != "" {
8989
fmt.Printf("[Codex CLI] detected (%s)\n", codexPath)
90-
deregisterMCP(codexPath, "codex", cfg)
90+
removeCodexMCP(cfg)
9191
removeCodexInstructions(cfg)
9292
}
9393

@@ -254,23 +254,26 @@ func registerClaudeCodeMCP(binaryPath, claudePath string, cfg installConfig) {
254254
}
255255

256256
// installCodex installs MCP registration and instructions for Codex CLI.
257-
func installCodex(binaryPath, codexPath string, cfg installConfig) {
257+
func installCodex(binaryPath, _ string, cfg installConfig) {
258258
home, err := os.UserHomeDir()
259259
if err != nil {
260260
fmt.Printf(" ⚠ Cannot determine home directory: %v\n", err)
261261
return
262262
}
263263

264-
// Register MCP server
264+
// Register MCP server via config.toml
265+
configFile := filepath.Join(home, ".codex", "config.toml")
266+
mcpSection := fmt.Sprintf("\n[mcp_servers.codebase-memory-mcp]\ncommand = %q\n", binaryPath)
267+
265268
if cfg.dryRun {
266-
fmt.Printf(" [dry-run] Would run: %s mcp remove codebase-memory-mcp\n", codexPath)
267-
fmt.Printf(" [dry-run] Would run: %s mcp add codebase-memory-mcp -- %s\n", codexPath, binaryPath)
269+
fmt.Printf(" [dry-run] Would add MCP server to: %s\n", configFile)
268270
} else {
269-
_ = execCLI(codexPath, "mcp", "remove", "codebase-memory-mcp")
270-
if err := execCLI(codexPath, "mcp", "add", "codebase-memory-mcp", "--", binaryPath); err != nil {
271+
if err := os.MkdirAll(filepath.Dir(configFile), 0o750); err != nil {
272+
fmt.Printf(" ⚠ mkdir %s: %v\n", filepath.Dir(configFile), err)
273+
} else if err := upsertCodexMCP(configFile, mcpSection, binaryPath); err != nil {
271274
fmt.Printf(" ⚠ MCP registration failed: %v\n", err)
272275
} else {
273-
fmt.Println(" ✓ MCP server registered")
276+
fmt.Printf(" ✓ MCP server registered: %s\n", configFile)
274277
}
275278
}
276279

@@ -293,6 +296,34 @@ func installCodex(binaryPath, codexPath string, cfg installConfig) {
293296
}
294297
}
295298

299+
// upsertCodexMCP adds or updates the codebase-memory-mcp section in config.toml.
300+
func upsertCodexMCP(configFile, mcpSection, binaryPath string) error {
301+
content, err := os.ReadFile(configFile)
302+
if err != nil && !os.IsNotExist(err) {
303+
return err
304+
}
305+
306+
text := string(content)
307+
308+
// If section already exists, replace the command line
309+
const sectionHeader = "[mcp_servers.codebase-memory-mcp]"
310+
if idx := strings.Index(text, sectionHeader); idx >= 0 {
311+
// Find the end of this section (next [ or EOF)
312+
rest := text[idx+len(sectionHeader):]
313+
endIdx := strings.Index(rest, "\n[")
314+
if endIdx < 0 {
315+
endIdx = len(rest)
316+
}
317+
newSection := fmt.Sprintf("%s\ncommand = %q\n", sectionHeader, binaryPath)
318+
text = text[:idx] + newSection + rest[endIdx:]
319+
} else {
320+
// Append new section
321+
text += mcpSection
322+
}
323+
324+
return os.WriteFile(configFile, []byte(text), 0o600)
325+
}
326+
296327
// removeClaudeSkills removes all 4 skill directories.
297328
func removeClaudeSkills(cfg installConfig) {
298329
home, err := os.UserHomeDir()
@@ -331,6 +362,46 @@ func deregisterMCP(cliPath, cliName string, cfg installConfig) {
331362
}
332363
}
333364

365+
// removeCodexMCP removes the codebase-memory-mcp section from Codex config.toml.
366+
func removeCodexMCP(cfg installConfig) {
367+
home, err := os.UserHomeDir()
368+
if err != nil {
369+
return
370+
}
371+
configFile := filepath.Join(home, ".codex", "config.toml")
372+
content, err := os.ReadFile(configFile)
373+
if err != nil {
374+
return
375+
}
376+
377+
text := string(content)
378+
const sectionHeader = "[mcp_servers.codebase-memory-mcp]"
379+
idx := strings.Index(text, sectionHeader)
380+
if idx < 0 {
381+
return
382+
}
383+
384+
if cfg.dryRun {
385+
fmt.Printf(" [dry-run] Would remove MCP section from: %s\n", configFile)
386+
return
387+
}
388+
389+
// Find end of section (next [ or EOF)
390+
rest := text[idx+len(sectionHeader):]
391+
endIdx := strings.Index(rest, "\n[")
392+
if endIdx < 0 {
393+
text = strings.TrimRight(text[:idx], "\n")
394+
} else {
395+
text = text[:idx] + rest[endIdx+1:]
396+
}
397+
398+
if err := os.WriteFile(configFile, []byte(text), 0o600); err != nil {
399+
fmt.Printf(" ⚠ update %s: %v\n", configFile, err)
400+
} else {
401+
fmt.Printf(" ✓ Removed MCP section from: %s\n", configFile)
402+
}
403+
}
404+
334405
// removeCodexInstructions removes the Codex instructions file.
335406
func removeCodexInstructions(cfg installConfig) {
336407
home, err := os.UserHomeDir()

0 commit comments

Comments
 (0)