CardPass Relay
README.md
# CardPass relay
A small remote [MCP](https://modelcontextprotocol.io) server that lets Claude (claude.ai,
Claude Desktop, Claude mobile, Claude Code) add, search and edit cards in
**CardPass**, an Android app that asks a few flashcards before opening distracting apps.
It is open source so anyone can check what it can and cannot read.
## Tools
| Tool | What it does |
|---|---|
| `add_card(front, back, deck?, image_url?)` | Queues a new card for the phone, returns its id |
| `update_card(id, front?, back?, deck?)` | Queues a change to a card created in CardPass |
| `search_cards(query?, limit?)` | Searches the user's own cards (not imported Anki decks) |
## Connecting
1. Add `https://cardpass-justin.duckdns.org/mcp` as a custom connector in Claude
(or `claude mcp add --transport http cardpass https://cardpass-justin.duckdns.org/mcp`).
2. The sign-in page shows a QR code: point the phone's camera at it and tap **Allow**
in CardPass. On the phone itself, tap **Open CardPass** instead.
Sign-in is standard OAuth 2.1 (dynamic client registration, PKCE S256, rotating
refresh tokens); approving on the phone is the authorization step. No account,
no password.
## Privacy model
- At first pairing the phone generates a 256-bit key **K** and a device secret.
- Every OAuth token the relay issues is `<random id>.<K>`. The relay stores only
`sha256(id)`, `sha256(K)` and `sha256(device secret)`, never K itself.
- `add_card` / `update_card` encrypt the operation with K (AES-256-GCM) as it arrives;
only ciphertext is stored, until the phone fetches and acknowledges it.
- The phone uploads a copy of its own cards already encrypted with K, so
`search_cards` can decrypt it in memory during a request, then forget it.
- So **at rest the relay cannot read cards**. Plaintext exists only in memory while
handling a request that carries K. Whoever holds a token (the Claude client you
connected) can read your own cards; that is what search needs.
- The relay still sees metadata: device id, sizes, timestamps.
- Claude itself (Anthropic) necessarily sees the cards it writes or reads.
## Running
```sh
uv sync
RELAY_URL=https://your.host RELAY_DB=data/relay.db uv run cardpass-relay # listens on 127.0.0.1:8787
uv run pytest # end-to-end tests: OAuth, pairing, tools, phone sync
```
Put it behind HTTPS (e.g. nginx + Let's Encrypt). Run a single worker: pending
authorization codes keep K in memory only.
`tools/fake_phone.py` stands in for the phone to try the relay without the app.
## License
MIT
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues