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

@upstate-web/d1-readonly-mcp

v0.1.0

Published

MCP server that exposes read-only SQL queries against Cloudflare D1 — with write-blocking. Lets AI coding agents read your database safely without risking DROP TABLE, INSERT, UPDATE, DELETE, ALTER, or any other mutation.

Downloads

74

Readme

@upstate-web/d1-readonly-mcp

MCP server for safe, agent-accessible D1 queries. The only D1 MCP server that blocks writes.

License: MIT

The Problem

You want Claude Code (or any AI coding agent) to query your Cloudflare D1 database — but you don't want it to run DROP TABLE, INSERT, UPDATE, DELETE, or any other mutation. Every D1 user faces this: "How do I let my agent read the database without letting it destroy the database?"

The Solution

d1-readonly-mcp is a Model Context Protocol server that exposes a single tool: query_d1(sql). It runs SELECT queries against your D1 database via the wrangler CLI — and blocks all write operations before they reach D1.

Write blocking

The server uses a regex pattern that catches 15+ SQL write operations before passing the query to wrangler:

INSERT | UPDATE | DELETE | DROP | ALTER | CREATE | REPLACE |
TRUNCATE | MERGE | UPSERT | PRAGMA | ATTACH | DETACH |
REINDEX | VACUUM | BEGIN | COMMIT | ROLLBACK

If a query matches any of these, it returns a typed error — the query never touches your database.

Install

npm install -g @upstate-web/d1-readonly-mcp

Or run via npx:

npx @upstate-web/d1-readonly-mcp

Prerequisites

  • Node.js >= 18
  • wrangler CLI installed and authenticated (npx wrangler login or CLOUDFLARE_API_TOKEN env var)
  • A Cloudflare D1 database

Configuration

Set the database name via environment variable:

export D1_DATABASE="your-database-name"   # defaults to "agency-db"

Use with Claude Code

claude mcp add d1-readonly -- npx @upstate-web/d1-readonly-mcp

Or with a custom database name:

claude mcp add d1-readonly \
  --env D1_DATABASE=my-db \
  -- npx @upstate-web/d1-readonly-mcp

Then in a Claude Code session, the tool appears as query_d1. Example:

Claude: "query_d1: SELECT COUNT(*) FROM users WHERE created_at > '2026-01-01'"

The tool returns the result set as JSON. Write queries return an error.

Smoke Test

# Start the server on stdio
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"0"}}}
{"jsonrpc":"2.0","method":"notifications/initialized"}
{"jsonrpc":"2.0","id":2,"method":"tools/list"}
{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"query_d1","arguments":{"sql":"SELECT 1"}}}' | D1_DATABASE=your-db npx @upstate-web/d1-readonly-mcp

Companion Packages

License

MIT.