Add lead capture to a site with Claude Code
Sign in to 1DB once from your terminal, then ask Claude Code to connect any site’s forms: it adds the site, writes the keys, wires the form and sends a test lead.
Updated
If you build sites with Claude Code, connecting their forms to 1DB is a sentence: “set up 1db for northfieldpallets.com.” This guide covers the one-time setup, what the agent does when you ask, and the last step it can’t do for you.
Set up once per computer
In your own terminal (not in a project script or CI), run:
npx @1db/cli setupIt opens your browser to sign in and approve access for one of your 1DB organizations, then adds 1DB’s MCP server to Claude Code for every project on this computer. Restart Claude Code and it has 1DB’s tools. You need Node 18 or newer.
The token this creates lives in ~/.config/1db/config.json, readable only by you. It never goes into a project. Projects only ever get a site’s ingest key, which can send leads and nothing else.
Ask for a site
Open the site’s project in Claude Code and ask:
set up 1db for northfieldpallets.comThe agent then:
- Adds the site to 1DB. It scans the domain’s homepage and DNS for the site’s name, framework and host, creates the website with a contact form, and gets its ingest key. Asking again for the same domain returns the existing site instead of making a second one.
- Writes the keys to
.env.localasDB_API_ENDPOINT,DB_API_KEYandDB_FORM_SLUG. That file is git-ignored, and values a project already has are left alone. - Wires the form. It follows an integration guide for the site’s framework, usually a server route that posts to 1DB, with per-field errors and a
submission_idagainst double submits. - Sends a test lead to prove it works, and reads it back.
Test leads are real leads tagged with the source 1db-test. They show in the dashboard and run your email alerts, webhooks, HubSpot sync and forwarding, so you see the whole path work.
Ask for more
The same tools cover what usually comes next. Some things to ask:
- “add a quote request form for pallets to northfieldpallets.com”
- “email new leads from the quote form to sales@northfieldpallets.com”
- “show me the last five leads from northfieldpallets.com”
- “forward leads to https://api.partner.com/leads with this API key”
What a token may do depends on the scopes you approved at sign-in: managing sites and forms, reading leads, changing where leads are sent, and deleting. Anything outside them is refused, and deletes always need the site or form’s slug typed back as confirmation.
The step that’s yours: going live
.env.local only exists on your machine. Before the live site can send leads:
- Add
DB_API_ENDPOINT,DB_API_KEYandDB_FORM_SLUGto your host’s production environment variables. - Redeploy.
- Submit the form on the live site, then check it arrived:
npx @1db/cli leads northfieldpallets.comA site that already sends leads
Don’t ask the agent to rewrite it. From the project folder, run:
npx @1db/cli check --sendIt compares the project’s DB_* values with 1DB, sends one test lead with them, and lists only what’s wrong, so you, or the agent, fix just that.
Without Claude Code
Every tool is also a CLI command (npx @1db/cli help lists them) and an HTTP endpoint under /v1/agent/. Other MCP clients can use the server at https://www.1-db.com/api/mcp with the token as a bearer header. The AI agents docs have the full reference.