npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

crm-d1

v0.1.0

Published

CLI + MCP server for Cloudflare D1-backed CRM, designed for AI agents and humans

Readme

crmd1

A CLI and MCP server for a Cloudflare D1-backed CRM — built for AI agents and humans alike.

npm version license node


Why crmd1

  • Serverless storage: each organization gets its own isolated Cloudflare D1 (SQLite) database — no shared infrastructure to manage.
  • Agent-native: all operations are exposed as typed MCP tools consumable by Claude, any LLM agent, or custom automation without needing a REST API.
  • Human-friendly CLI: the same operations available to agents are available interactively via crmd1 with table output and clear error messages.

Install

npm i -g crmd1

Or run without installing:

npx crmd1 --help

Quick start

1. Set environment variables

export CLOUDFLARE_API_TOKEN="your-token"
export CLOUDFLARE_ACCOUNT_ID="your-account-id"

Or store them in a .env file in the working directory.

2. Create an organization and initialize the database

crmd1 org create acme
crmd1 org use acme
crmd1 db init

3. Add contacts and search

crmd1 contact create --email [email protected] --first-name Alice --last-name Smith
crmd1 search "@b.com"

4. Full example

crmd1 company create --name "Acme Corp" --domain acme.com
crmd1 contact create --email [email protected] --company-id <id>
crmd1 deal create --title "Enterprise deal" --value 50000 --contact-id <id>
crmd1 activity log --type call --note "Intro call done" --contact-id <id>
crmd1 task create --title "Send proposal" --due 2026-06-01 --contact-id <id>
crmd1 contact list --limit 20

Use as MCP server

Add crmd1-mcp to your MCP client configuration. Example for Claude Desktop or any generic MCP client:

{
  "mcpServers": {
    "crmd1": {
      "command": "npx",
      "args": ["-y", "crmd1-mcp"],
      "env": {
        "CLOUDFLARE_API_TOKEN": "...",
        "CLOUDFLARE_ACCOUNT_ID": "..."
      }
    }
  }
}

The server communicates over stdio using the MCP protocol. Restart your client after editing the config.


Tools exposed (37 total)

Org & DB

  • org_create — create a new organization (provisions a D1 database)
  • org_list — list all organizations
  • org_use — set the active organization
  • org_current — show the active organization
  • org_delete — delete an organization
  • db_init — run schema migrations on the active org's database
  • db_query — execute a raw SQL SELECT on the active org's database
  • crm_search — full-text search across contacts, companies, deals, activities, and tasks

Contacts

  • contact_create — create a contact
  • contact_get — get a contact by ID
  • contact_list — list contacts with pagination and filters
  • contact_update — update contact fields
  • contact_delete — soft-delete a contact
  • contact_restore — restore a soft-deleted contact

Companies

  • company_create — create a company
  • company_get — get a company by ID
  • company_list — list companies with pagination and filters
  • company_update — update company fields
  • company_delete — soft-delete a company
  • company_restore — restore a soft-deleted company

Deals

  • deal_create — create a deal
  • deal_get — get a deal by ID
  • deal_list — list deals with pagination and filters
  • deal_update — update deal fields (stage, value, etc.)
  • deal_delete — soft-delete a deal
  • deal_restore — restore a soft-deleted deal

Activities

  • activity_log — log an activity (call, email, meeting, note)
  • activity_get — get an activity by ID
  • activity_list — list activities for a contact, company, or deal
  • activity_delete — delete an activity

Tasks

  • task_create — create a task
  • task_get — get a task by ID
  • task_list — list tasks with filters
  • task_update — update task fields
  • task_complete — mark a task as complete
  • task_delete — soft-delete a task
  • task_restore — restore a soft-deleted task

Multi-org

Each organization maps to one Cloudflare D1 database. The active organization is stored in the local config (~/.config/crmd1/config.json or CRMD1_CONFIG_PATH). Switch at any time:

crmd1 org use other-org

All CLI commands and MCP tool calls operate against the active organization's database.


Schema

Five core entities with full-text search via SQLite FTS5:

| Entity | Key fields | |--------|-----------| | contacts | id, first_name, last_name, email, phone, company_id | | companies | id, name, domain, industry | | deals | id, title, value, stage, contact_id, company_id | | activities | id, type, note, contact_id, company_id, deal_id | | tasks | id, title, due_date, completed_at, contact_id, deal_id |

All records carry created_at, updated_at, and deleted_at (soft delete). Pagination uses opaque cursor tokens.


Environment variables

| Variable | Required | Description | |----------|----------|-------------| | CLOUDFLARE_API_TOKEN | Yes | Cloudflare API token with D1 read/write permission | | CLOUDFLARE_ACCOUNT_ID | Yes | Cloudflare account ID | | CRMD1_ORG | No | Override the active organization name | | CRMD1_CONFIG_PATH | No | Override config file location |


Development

git clone https://github.com/mrgoonie/crmd1.git
cd crmd1
pnpm i
pnpm test
pnpm build
node dist/cli.js --help

Run tests with coverage:

pnpm test:coverage

Typecheck:

pnpm typecheck

Architecture

See docs/system-architecture.md for the full design: module boundaries, D1 adapter interface, MCP transport layer, and CLI command tree.


License

MIT. See LICENSE.