Guide

Self-host todz

Run your own todz server on Cloudflare and point the macOS app and your agents at it. The server is one Worker with a D1 database and one Durable Object per project (ADR 0044).

What you need

1. Fork, install and check

Fork the repository, then, before renaming anything:

pnpm install
pnpm verify all

The gate also needs gitleaks; its doctor names anything missing. Run it now, because some tests pin todz's own production names, for example tools/repository-shape/src/api-source.test.ts and apps/api/test/email-sender.test.ts. After step 2 those pins fail until you update them to your names.

2. Rename

Edit apps/api/wrangler.jsonc:

Keep the rest as it is. In particular, vars.SIGN_IN_PROVIDER stays email, vars.EMAIL_SENDER stays cloudflare, and workers_dev and preview_urls stay false. Never pass --var to wrangler deploy, and never set variables in the dashboard: a fake provider, or a sender that only logs the link, opens sign-in to anyone.

In apps/api/src/email-sender.ts, set SENDER_ADDRESS and REPLY_TO_ADDRESS to your own addresses.

3. Create the database and apply the migrations

pnpm --filter @todz/api exec wrangler d1 create todz-directory

Put the printed id in d1_databases[0].database_id, then:

pnpm --filter @todz/api exec wrangler d1 migrations apply todz-directory --remote

4. Deploy

pnpm --filter @todz/api exec wrangler deploy

Cloudflare creates the DNS records and the certificates for api.example.com, example.com and www.example.com; none of the three may already have an A, AAAA or CNAME record. Check three things:

5. Email sending

Enable sending for your domain and add the records Cloudflare lists. The zone id is on the domain's Overview page in the dashboard.

pnpm --filter @todz/api exec wrangler email sending enable example.com --zone-id <your zone id>
pnpm --filter @todz/api exec wrangler email sending dns get example.com --zone-id <your zone id>

6. Turnstile

Sign-in stays closed (sign_in_unavailable) until Turnstile is set up (ADR 0045). In the Cloudflare dashboard, create a Turnstile widget for example.com in Managed mode. Put its site key in vars.TURNSTILE_SITE_KEY in apps/api/wrangler.jsonc, deploy again, and store its secret:

pnpm --filter @todz/api exec wrangler secret put TURNSTILE_SECRET_KEY

Wrangler asks for the value, which keeps it out of your shell history. Never pipe it in, never export it, and never write it into wrangler.jsonc.

7. Point the macOS app at your server

In apps/macos/project.yml:

Then build:

xcodegen generate --spec apps/macos/project.yml
xcodebuild build -project apps/macos/Todz.xcodeproj -scheme Todz -configuration Release -derivedDataPath apps/macos/build

Sign in with your email, then open Connect an agent in the sidebar.

8. Point an MCP client at your server

Connect an agent shows a ready command with your server and a new key. For Claude Code it has this shape:

claude mcp add --transport http todz 'https://api.example.com/mcp' --header 'Authorization: Bearer <key>'

A key belongs to one project, and the server reads the project from it (docs/product). The command puts the key in your shell history. Run it with a leading space if your shell skips those, or use the Cursor form, which keeps the key in its JSON configuration.

Updating

Pull from upstream, then run:

pnpm --filter @todz/api exec wrangler d1 migrations apply todz-directory --remote
pnpm --filter @todz/api exec wrangler deploy

Migrations only move forward. Never roll back to a version from before the sign-in guard, whether with wrangler rollback or the dashboard's Deployments page. To close sign-in, delete the secret (the runbook):

pnpm --filter @todz/api exec wrangler secret delete TURNSTILE_SECRET_KEY

Back to top