Skip to content

fix(memory): start MCP server when launched through the bin symlink - #303

Merged
codeaholicguy merged 2 commits into
codeaholicguy:mainfrom
PhucChuHoang:fix/memory-bin-symlink-main-check
Sep 30, 2026
Merged

codeaholicguy merged 2 commits into
codeaholicguy:mainfrom
PhucChuHoang:fix/memory-bin-symlink-main-check

Conversation

@PhucChuHoang

Copy link
Copy Markdown
Contributor

Summary

  • Add isMainModule(argv1, moduleUrl) in packages/memory/src/entrypoint.ts, which compares the real paths of process.argv[1] and the module file.
  • Use it in src/index.ts instead of the strict process.argv[1] === fileURLToPath(import.meta.url) check.
  • npx @ai-devkit/memory and global installs launch the ai-devkit-memory bin symlink, so the old check never matched and the server exited silently. Importing the package as a library still does not start the server.

Closes #302

Validation

  • New tests/unit/entrypoint.test.ts covers: the module file itself, a bin symlink to it (fails on the old check), a different file, undefined argv[1], and a missing path (no throw).
  • memory package: tests (167), typecheck, lint and fmt:check pass; the Husky pre-commit hook (full nx run-many -t test) passed.
  • Built dist/index.js started through a symlink now answers an MCP initialize request; import() of the built entry does not start the server.

Follow-up

  • packages/memory-dashboard/src/standalone.ts:101 uses the same pattern (import.meta.url === \file://${process.argv[1]}``), which fails through a bin symlink and for paths that need URL encoding (e.g. spaces). Left out to keep this PR scoped.

🤖 Generated with Claude Code

PhucChuHoang and others added 2 commits September 29, 2026 21:55
…odeaholicguy#302)

npx and global installs run the ai-devkit-memory bin symlink, so
process.argv[1] is the link path while import.meta.url is the resolved
file. The strict comparison never matched and the process exited without
starting the server. Compare real paths via isMainModule(), returning
false when argv[1] is missing or cannot be resolved.
@codeaholicguy

Copy link
Copy Markdown
Owner

LGTM, thanks for the contribution.

@codeaholicguy
codeaholicguy merged commit 045cedc into codeaholicguy:main Sep 30, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

memory: MCP server exits silently when started via npx @ai-devkit/memory (bin symlink fails main-module check)

2 participants