Integrations

How to connect Cloudflare D1 to AI agents?

Connect Cloudflare D1 to Sequel and query it in plain English, from the Sequel app or any AI tool wired up to the MCP server. D1 is Cloudflare's serverless SQLite database, and Sequel reaches it over Cloudflare's D1 API, so there is nothing to install and no tunnel or IP allowlist to configure.

The interesting part is usually not D1 on its own. D1 holds your product data, while the rest of the answer lives in billing, CRM, and analytics. Once D1 is connected you can ask one question that spans all of them and let Sequel work out which source answers which part.

What you'll need

  • A Cloudflare account with at least one D1 database.
  • Permission to authorize applications on that account. If your account administrator has turned off third-party OAuth access under Manage Account → Members → Settings, you will need them to re-enable it.

One connection, one database

A Sequel connection is pinned to exactly one D1 database, chosen when you connect. Sequel has no way to list or query any other database on your account through that connection. To query a second database, add a second connection.

Connect it

Open a new connection

In the Sequel dashboard, go to Connections → New connection and choose Cloudflare D1.

Sign in with Cloudflare

You'll be sent to Cloudflare's consent screen. Approve the connection to give Sequel read access to your D1 databases. There is no API token to create, paste, or rotate, and you can revoke access at any time.

Pick a database

Sequel lists the D1 databases you just authorized, grouped by account. Choose the one this connection should use.

Sequel stores the account and database you picked, so subsequent queries always go to that database and nowhere else.

Test and save

Sequel reads your table and column definitions from sqlite_master and PRAGMA table_info, then writes a short summary of what the database contains. A green check means it's live.

Try it

Once connected, ask things like:

  • "How many rows are in each table?"
  • "Show me the 20 most recently created users."
  • "Plot daily order volume for the last 30 days."
  • "What's the conversion rate from signup to first purchase, by month?"
  • "Which customers in D1 also have an active Stripe subscription?"

Because D1 is SQLite, joins, CTEs, window functions, and JSON1 queries all work the way you'd expect.

How Sequel reads your schema

Sequel introspects the database once at connect time, and again when you refresh the schema:

  • Tables come from sqlite_master, excluding SQLite's own sqlite_* tables and D1's internal _cf_* bookkeeping tables.
  • Columns come from PRAGMA table_info, which supplies the type, NOT NULL status, default value, and primary-key flag for each one.

That schema is summarized and stored with the connection, so the agent knows your real column names before it writes any SQL.

What Sequel can and can't do

Sequel requests four read-only scopes and nothing else:

ScopeWhat it's for
d1.readRead your D1 databases and run SELECT queries
memberships.readList which Cloudflare accounts you belong to
account-settings.readResolve those accounts for the database picker
user-details.readIdentify the signed-in user

Read-only is enforced by Cloudflare, not just by convention on our side. Because Sequel holds only d1.read, a write that somehow reached the D1 API would be rejected by Cloudflare itself. Sequel requests no Workers, DNS, or zone access at all.

You can revoke the grant at any time from your Cloudflare profile under Access Management.

Troubleshooting

SymptomLikely fix
No databases in the pickerThe authorized account has no D1 databases yet, or you approved a different account than you expected. Create a database, or reconnect and pick the right account.
"Cloudflare has revoked access for this connection"The grant was revoked, or an administrator disabled third-party OAuth for the account. Reconnect from Sequel once access is restored.
Consent screen won't let you approveYour account administrator has blocked public OAuth app access under Manage Account → Members → Settings.
"no such table"The table may have been created after you connected. Refresh the schema from the connection settings.
A table is missing from the schemaTables named sqlite_* or _cf_* are filtered out deliberately. Anything else should appear after a schema refresh.
A write query failsExpected. Sequel holds only the d1.read scope, so Cloudflare rejects writes.