Blog
guide

How to Connect Cloudflare D1 to Grok Bot Using Sequel

Musthaq Ahamad
Musthaq Ahamad
How to Connect Cloudflare D1 to Grok Bot Using Sequel

Cloudflare D1 is the SQLite database that sits next to your Workers, which means it often holds the production data for an edge-deployed app. Grok Bot is xAI's bot builder, an agent that keeps context and reaches your tools through plugins. Sequel's MCP server gives that bot read access to D1, so you can ask about your data without writing a one-off Worker to dump it.

TL;DR

What you're connectingOne Cloudflare D1 database to Grok Bot
Setup timeAbout 5 minutes
Setup methodOne chat message. Grok Bot has no MCP config file
AuthCloudflare OAuth to Sequel, no API token to create
Scopes requestedd1.read, memberships.read, account-settings.read, user-details.read
Access levelRead-only, enforced by Cloudflare
Scope of a connectionExactly one D1 database

What You'll Accomplish

Once this is wired up, you can ask your bot:

  • "How many rows are in each table, and which grew fastest this month?"
  • "Show the 20 most recently created users with their signup source."
  • "What's the conversion rate from signup to first purchase, by month?"

Prerequisites

  • A Sequel account: sign up free at sequel.sh
  • A Cloudflare account with at least one D1 database
  • Permission to authorize applications on that Cloudflare account
  • A Grok account with a bot you can send messages to

Step 1: Connect Cloudflare D1 to Sequel

Sign in to sequel.sh and open Data Sources.

Sequel Data Sources page

Click New Connection and choose Cloudflare D1.

Choose a connector

StepWhat happens
Sign in with CloudflareApprove the grant on Cloudflare's consent screen. There is no token to paste or rotate
Pick a databaseSequel lists the D1 databases you authorized, grouped by account. Choose one
Test and saveSequel reads sqlite_master and PRAGMA table_info, then stores a schema summary

Sequel stores the account and database you picked, so every later query goes to that database and nowhere else.

Read-only is enforced upstream. Sequel requests d1.read and nothing else, so Cloudflare rejects writes at the API. It asks for no Workers, DNS, or zone access at all.

Step 2: Add Sequel to Grok Bot

Grok Bot has no MCP config file and no settings form to fill in. You add a server by asking the bot.

Open a chat with your bot and send this:

Add a custom MCP server called sequel at https://api.sequel.sh/mcp

Say custom server explicitly. Leave those words out and the bot searches the plugin marketplace instead of registering your endpoint.

Sequel's Grok Bot install card

The bot reads the name and URL back to you. Check both, confirm, and it posts a connect card in the chat. Click Authorize, sign in to Sequel, and approve access. The OAuth token stays on the connector side, so there is no API key to copy and nothing to keep in sync.

To confirm it registered, open Settings → Plugins → Yours. Every server on your account is listed there, including the ones you added by chat.

Grok's plugins panel

Then attach it to a task: type @ in the chat and pick sequel.

Using Grok chat rather than a bot? The steps do not carry over. On grok.com, open Plugins → New Connector → Custom, set the name to Sequel and the Server URL to https://api.sequel.sh/mcp, click Add Connector, and sign in.

Grok custom connector form

Step 3: Ask Grok Bot About Your D1 Data

Attach @sequel and ask:

How many rows are in each table, and which table grew the most this month?
Show the 20 most recently created users with their signup source and plan.
What's the conversion rate from signup to first purchase, by signup month?

What You Can Do Now

  • Inspect production without a Worker: no more writing a throwaway endpoint just to read a table.
  • Scheduled health checks: the bot can run a row-count and integrity sweep every morning and report only on changes.
  • Edge-app analytics: daily actives, retention, and funnel math straight from D1.
  • Schema discovery: "What tables exist and how do they relate?" straight from sqlite_master.
  • Cross-source joins: with Stripe connected, ask which D1 customers also hold an active subscription.

Troubleshooting

SymptomLikely fix
The bot searched the marketplace instead of adding the serverResend the message with the words "custom server" in it.
The server is not listed under Settings → Plugins → YoursThe registration did not complete. Resend the message and confirm the name and URL when the bot reads them back.
The bot answers without touching your dataYou did not attach it. Type @ in the chat and pick sequel before asking.
No databases appear in the pickerThe authorized account has no D1 databases, or you approved a different account. Reconnect and pick the right one.
Cloudflare has revoked access for this connectionThe grant was revoked or an admin disabled third-party OAuth. Reconnect from Sequel once access is restored.
"no such table"The table was created after you connected. Refresh the schema from the connection settings.

Related Guides

Try Sequel

Build your company brain.

Sequel connects the systems your company runs on and learns how your team defines every metric, so any AI agent can answer from it. Free for up to 3 seats, no credit card required.

Get started free

Frequently asked questions

How do I add Sequel to Grok Bot?

Ask the bot. Send "add a custom MCP server called sequel at https://api.sequel.sh/mcp", confirm the name and URL it reads back, then click Authorize on the connect card and sign in to Sequel. Say "custom server" explicitly so the bot adds the endpoint instead of searching the plugin marketplace.

Do I need a Sequel API key for Grok Bot?

No. Sequel is a remote MCP server with OAuth. The bot posts a connect card, you authorize in the browser, and the token stays on the connector side. There is no key to paste into a chat.

Is this the same as Grok chat or Grok Build?

No, and the steps do not carry over. Grok chat on grok.com adds servers under Plugins, New Connector, Custom. Grok Build is the terminal coding agent and uses grok mcp add. Grok Bot is the bot builder, where you add servers by asking the bot.

Do I need a Cloudflare API token?

No. Sequel connects over Cloudflare OAuth. You approve the grant on Cloudflare's consent screen and can revoke it at any time from your Cloudflare profile under Access Management.

Can Grok Bot write to my D1 database?

No. Sequel holds only the d1.read scope, so a write that somehow reached the D1 API would be rejected by Cloudflare itself, not just by Sequel.

Can one connection reach all of my D1 databases?

No, and that is deliberate. A connection is pinned to exactly one D1 database chosen at connect time. Add a second connection to query a second database.

Why is a table missing from the schema?

Tables named sqlite_* or _cf_* are filtered out on purpose. Anything else should appear after a schema refresh from the connection settings, which matters if the table was created after you connected.

Does SQLite syntax work?

Yes. D1 is SQLite, so joins, CTEs, window functions, and JSON1 all behave the way you would expect.

Written by

Musthaq Ahamad
Musthaq Ahamad

Co-founder and CEO of Sequel. Previously built developer tools and data infrastructure. Passionate about making data accessible for everyone.