Skip to content

feat: add npm/npx distribution for codedb MCP usage #501

@idea404

Description

@idea404

Goal

Enable users to configure codedb in MCP clients with npx for zero-install setup:

{
  "codedb": {
    "type": "local",
    "command": ["npx", "-y", "@justrach/codedb"],
    "args": ["mcp"],
    "enabled": true
  }
}

Rationale

Many MCP clients (opencode, Claude Code, Cursor) document local servers through npx, especially for zero-install setup. codedb is currently a native Zig binary, which requires users to install it manually and hardcode an absolute binary path in their MCP config.

An npm package can be a thin JS launcher around the native binary. It does not require rewriting codedb in JavaScript.

Requirements

  • Publish @justrach/codedb with a bin entry named codedb
  • JS wrapper must preserve:
    • process.cwd()
    • stdio (stdout reserved for JSON-RPC in MCP mode)
    • args
    • environment
  • Wrapper must not write logs to stdout before MCP starts
  • Provide platform binaries through either:
    • optional platform packages (preferred — @justrach/codedb-darwin-arm64, etc.)
    • or postinstall download from GitHub Releases
  • Keep version aligned with codedb release version

Suggested layout

npm/
  package.json
  bin/
    codedb.js        # thin launcher, execs native binary
  postinstall.js     # or rely on optionalDependencies

Platform packages approach (recommended)

Top-level package.json:

{
  "name": "@justrach/codedb",
  "version": "0.2.5820",
  "bin": { "codedb": "./bin/codedb.js" },
  "optionalDependencies": {
    "@justrach/codedb-darwin-arm64": "0.2.5820",
    "@justrach/codedb-darwin-x64": "0.2.5820",
    "@justrach/codedb-linux-x64": "0.2.5820",
    "@justrach/codedb-linux-arm64": "0.2.5820"
  }
}

Launcher (bin/codedb.js)

#!/usr/bin/env node
const { spawnSync } = require("node:child_process");
const path = require("node:path");

const exe = process.platform === "win32" ? "codedb.exe" : "codedb";
const bin = path.join(__dirname, "..", "vendor", `${process.platform}-${process.arch}`, exe);

const result = spawnSync(bin, process.argv.slice(2), {
  stdio: "inherit",
  cwd: process.cwd(),
  env: process.env
});
process.exit(result.status ?? 1);

Acceptance criteria

  1. This works from any directory:

    npx -y @justrach/codedb mcp
  2. This works in opencode/Claude Code MCP config:

    {
      "codedb": {
        "type": "local",
        "command": ["npx", "-y", "@justrach/codedb"],
        "args": ["mcp"],
        "enabled": true
      }
    }
  3. codedb_status reports files from the current repo, not the npm cache directory

Scope estimate

Size Conditions
Small GitHub Actions already builds per-platform release binaries, maintainer has npm org access, package name available, no Windows initially
Medium Need release asset naming convention, npm workspace setup, CI publish workflow, multi-platform optional packages
Large Need full cross-platform binary build pipeline, signing/checksums, installer migration

Notes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions