ruvnet / ruvnet/agentic-flow

agentdb mcp start crashes -32000 under npx: better-sqlite3 peerDependency not installed (static import on CLI boot path)

Open Beginner friendly
#161 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
812
Forks
175
Avg merge
2m
Merged PRs (30d)
3

Description

Summary

(agentdb@3.0.0-alpha.10 — filed here since npm view agentdb points bugs at this repo.)

Registering the agentdb MCP server the documented way — npx -y agentdb@3.0.0-alpha.10 mcp start in a Claude Code .mcp.json — crashes on a fresh npx cache, because better-sqlite3 is declared as a peerDependency and npx -y (and npm install -g) do not install peer deps. The stdio process exits before it can speak JSON-RPC, so the MCP client reports Failed to reconnect to agentdb: -32000.

Version

agentdb@3.0.0-alpha.10

Reproduction

# in an environment with no ancestor node_modules/better-sqlite3
npx -y agentdb@3.0.0-alpha.10 mcp start

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'better-sqlite3'
  imported from .../node_modules/agentdb/dist/src/cli/commands/migrate.js

Root cause

package.json declares better-sqlite3: ^11.8.1 (also sqlite3, @xenova/transformers) as peerDependencies, which npx -y / npm i -g do not install. The CLI entry dist/src/cli/agentdb-cli.js statically imports dist/src/cli/commands/migrate.js, whose top-level line is import Database from 'better-sqlite3'. So the CLI module graph fails to load before the mcp subcommand runs — even though the MCP server itself (dist/src/mcp/agentdb-mcp-server.js) uses the bundled sql.js (a regular dep) for its DB layer and never needs better-sqlite3. A static top-level import of an un-installed peer on the CLI boot path takes down every subcommand, including mcp start.

Suggested fixes (any one resolves it)

  1. Lazy-load the migrate better-sqlite3 importconst Database = (await import('better-sqlite3')).default inside migrateCommand, so the CLI boots (and mcp start runs) without the peer. Matches how @xenova/transformers is already handled (lazy await import() in EmbeddingService).
  2. Move better-sqlite3 to dependencies/optionalDependencies so npx/npm i provision it.
  3. Document global-install launch for the MCP server (npm i -g agentdb@3.0.0-alpha.10 better-sqlite3@^11.8.1, then .mcp.jsoncommand:"agentdb" not npx). That's the workaround we shipped, but a stdio MCP server that can't run under its own documented npx invocation is a footgun worth fixing in the package.

Workaround

npm i -g agentdb@3.0.0-alpha.10 better-sqlite3@^11.8.1

.mcp.json: "agentdb": { "command": "agentdb", "args": ["mcp","start"] }. Note better-sqlite3 is a NODE_MODULE_VERSION-pinned native addon → re-install after a Node major upgrade.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with package.json and the CLI boot path at dist/src/cli/agentdb-cli.js, then inspect dist/src/cli/commands/migrate.js and its top-level better-sqlite3 import. Run the documented npx agentdb@3.0.0-alpha.10 mcp start reproduction; done means the MCP process starts without better-sqlite3 installed and no longer exits before JSON-RPC.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, sqlite, typescript
Domain
cli, databases
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
70/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.