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

binding-doctor

v1.0.0

Published

Reconcile Cloudflare bindings between code, wrangler.toml, and your account. CLI + MCP server.

Readme

Binding Doctor

Wrangler ships your code. Doctor wires your stack.

bdr is a CLI and an MCP server that reconciles Cloudflare bindings between your code, your wrangler.toml, and your account. It lets an AI agent (Claude Code, Codex, etc.) take a Worker from env.CHAT_DB to a deployed app without ever asking you to copy a database ID.

$ bdr diff
BINDING         KIND     DECL  REF  LIVE  STATUS
--------------  -------  ----  ---  ----  ----------------
CHAT_DB         unknown  —     yes  —     missing-declared
SESSIONS_KV     unknown  —     yes  —     missing-declared
UPLOADS_BUCKET  unknown  —     yes  —     missing-declared

$ bdr apply --yes
  create d1   CHAT_DB        → my-app-chat-db-8i6x   (9c48b532-…)
  create kv   SESSIONS_KV    → my-app-sessions-kv-3h0f (0230f531…)
  create r2   UPLOADS_BUCKET → my-app-uploads-bucket-s000

Wrote 3 bindings to wrangler.toml.
Migrations [CHAT_DB]: applied 0001_init.sql

Re-run = no-op. Delete a resource in the dashboard? bdr apply heals it.


What it does

  1. Parses wrangler.toml / wrangler.jsonc for declared bindings (d1_databases, r2_buckets, kv_namespaces, queues, vectorize).
  2. Scans src/**/*.{ts,tsx,js,mjs} for env.X references.
  3. Lists live resources in your Cloudflare account.
  4. Diffs the three sources of truth.
  5. Applies the diff: creates missing resources, writes IDs back to your wrangler config (with .bak), runs pending migrations/*.sql against new D1 dbs.

Idempotent. One command. No manual ID copying.

Install

Zero-install (recommended)

npx -p binding-doctor bdr diff

bdr and bdr-mcp both resolve via npx from the npm registry.

Global install

npm install -g binding-doctor
bdr diff

Credentials

Create an API token at https://dash.cloudflare.com/profile/api-tokens with these scopes: D1:Edit · R2:Edit · Workers KV Storage:Edit · Queues:Edit · Vectorize:Edit · Account Settings:Read.

Drop into .env in your Worker project:

CLOUDFLARE_API_TOKEN=...
CLOUDFLARE_ACCOUNT_ID=...

CLI

bdr diff [dir]            # three-way binding diff
bdr plan [dir]            # preview actions
bdr apply [dir] --yes     # create + writeback + run migrations
bdr migrate [dir]         # run pending D1 migrations only

MCP — wire into Claude Code

Add to .claude/mcp.json (or your client's MCP config):

{
  "mcpServers": {
    "binding-doctor": {
      "command": "npx",
      "args": ["-y", "-p", "binding-doctor", "bdr-mcp"],
      "env": {
        "CLOUDFLARE_API_TOKEN": "...",
        "CLOUDFLARE_ACCOUNT_ID": "..."
      }
    }
  }
}

Or, if globally installed:

{
  "mcpServers": {
    "binding-doctor": {
      "command": "bdr-mcp",
      "env": {
        "CLOUDFLARE_API_TOKEN": "...",
        "CLOUDFLARE_ACCOUNT_ID": "..."
      }
    }
  }
}

Tools exposed: bdr_diff, bdr_plan, bdr_apply, bdr_migrate.

The agent's loop becomes: write code → bdr_apply → ship. Zero human ID copying.

Why local, not remote

The MCP runs on your machine because it reads your local wrangler.toml and scans your source tree — your code is the desired state. A hosted Worker can't see your filesystem. (See BLOG.md for the design rationale.)

Binding kind inference

When code references a binding not declared anywhere, kind is inferred from suffix:

| Suffix matches | Kind | | --- | --- | | _DB, _D1, DB | D1 | | _BUCKET, _R2, _STORAGE | R2 | | _KV, _CACHE, _SESSIONS, _STATE | KV | | _QUEUE, _JOBS, _EVENTS | Queue | | _VEC, _VECTORIZE, _INDEX, _EMBEDDINGS | Vectorize |

Unknown kinds emit a warning instead of silently picking wrong.

Demo

bash demo/run.sh

Why this exists

Cloudflare's Agents Week 2026 shipped most of the agentic stack: API MCP, Skills plugin, Stripe-funded auto-provisioning, Project Think. But when an agent generates a Worker that references env.CHAT_DB, the human still copy-pastes a D1 UUID. There is no git status for bindings; no reconciler.

Wrangler is the build tool. bdr is the reconciler. It treats your code as the desired state and your account as the actual state, and closes the gap idempotently.

License

MIT.