Skip to main content
Glama
README.md
# swu-mcp

Remote MCP server for Star Wars: Unlimited deck building, on Cloudflare Workers.
Card data comes from the public swu-db.com API. Read-only, no auth, no secrets.

## Deploy

Needs Node 22+ and a free Cloudflare account.

    npm install
    npx wrangler login
    npx wrangler deploy

Wrangler prints a URL like `https://swu-mcp.<your-subdomain>.workers.dev`.
The connector URL is that plus `/mcp`.

### In a dev container

Open the folder in VS Code and choose "Reopen in Container" (needs Docker and the
Dev Containers extension). `npm install` runs automatically. Then, in the container terminal:

    npx wrangler login     # port 8976 is forwarded for the browser callback
    npx wrangler deploy
    claude                 # Claude Code CLI, log in on first run

Logins are kept in named volumes, so they survive rebuilds.

To skip `wrangler login`, create a Cloudflare API token ("Edit Cloudflare Workers"
template) and set `CLOUDFLARE_API_TOKEN` and `CLOUDFLARE_ACCOUNT_ID` as environment
variables on the host (on Windows: user environment variables). Restart VS Code and
rebuild the container; `devcontainer.json` passes them through, so they never touch
a file in the repo.

## CI/CD (GitHub Actions)

`.github/workflows/ci.yml` runs on every pull request and every push to `main`:
secret detection (gitleaks), lint + type-check, unit tests, build (`wrangler deploy --dry-run`).
On pushes to `main`, if all four pass, it deploys.

One-time setup, in the GitHub repo settings:

1. Create a Cloudflare API token with the "Edit Cloudflare Workers" template.
2. Add repository secrets `CLOUDFLARE_API_TOKEN` and `CLOUDFLARE_ACCOUNT_ID`.
3. Optional: add a required reviewer to the `production` environment, to get a
   manual approval gate before each deploy. The first deploy run creates the
   environment if it doesn't exist; repository secrets work in it as-is.

Secret detection needs no setup for a repo owned by a personal account. If the repo
is owned by an organization, gitleaks-action also needs a `GITLEAKS_LICENSE` secret
(free key from gitleaks.io) and the workflow must pass it to the action.

## Add to Claude

Add a custom connector in Claude's connector settings with the `/mcp` URL. No auth fields needed.

## Tools

- `search_cards` - full swu-db query syntax (aspects, cost, traits, keywords, rules text, format)
- `get_card` - one card in full, by id (`SOR_010`) or name
- `list_sets` - set codes and release dates
- `check_deck` - Premier legality, aspect penalties, curve and breakdowns, price, SWUDB import JSON

## Local

    npm run dev        # http://localhost:8787/mcp
    npm test           # deck logic unit tests
    npm run typecheck
    npm run lint
    npm run build      # bundle without deploying

## Notes

- `check_deck` covers Premier only. It does not check rotation or suspensions, or
  base/leader text that changes deck-building rules.
- Responses from swu-db are cached for 6 hours where the Workers Cache API is active.
- The URL is public. It only proxies public card data, but anyone with the URL can call it.