MTG Assistant Gateway
Provides OAuth/OpenID Connect identity provider integration for sign-in, with setup notes for using Authelia as the authentication provider (not yet tested end-to-end).
Allows users to sign in to the MCP server through the operator's Authentik identity provider using OAuth/OpenID Connect, with setup guidance for groups, providers, applications, bindings, adding people, and troubleshooting.
Provides OAuth/OpenID Connect identity provider integration for sign-in, with setup notes for using Google as the authentication provider.
Provides OAuth/OpenID Connect identity provider integration for sign-in, with setup notes for using Keycloak as the authentication provider (not yet tested end-to-end).
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MTG Assistant GatewayGoldfish my Archidekt deck and show the average win turn"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MTG Assistant Gateway
Overview · Quick start · Documentation · Features · How it works · Security · Repository · Development · License
A self-hosted Model Context Protocol (MCP) server for Magic: The Gathering. You run it in Docker, on one machine with Compose or on a Swarm, for you and whoever you invite. Each person adds one URL to Claude or ChatGPT and signs in with their own account. From there their assistant can look up cards and Commander data, goldfish a deck, and edit their own Archidekt decks. It never changes a deck until that person has said yes to the exact change.
Contents
Related MCP server: architecture-map MCP server
Overview
Two kinds of people use it.
The operator deploys it and decides who gets in.
Users connect their assistant and link their Archidekt account.
What it runs on: two Docker containers (amd64 or arm64, so a Raspberry Pi is fine), behind any HTTPS reverse proxy, with any OpenID Connect identity provider handling sign-in.
Deploy with Docker Compose on one machine, or a Docker Swarm stack (Portainer optional).
Tested end to end with Swarm, Authentik and an nginx proxy in CI. Caddy, Traefik, nginx and Nginx Proxy Manager configs are included; Keycloak, Authelia, Zitadel, Pocket ID and others have setup notes but haven't been tested with the gateway yet.
The picture: docs/ARCHITECTURE.md.
Which assistants: Claude (web, desktop, iOS, Android) and ChatGPT (web), plus any MCP client that does OAuth. What works where, and the limits, are in docs/CONNECT.md.
On a phone: the pages work in any browser. There is also an Android app that each gateway hands out itself, adding a camera scan screen with torch brightness (docs/ANDROID.md).
What it talks to: Archidekt for decks, Scryfall for cards, and a private Mystic Forge container for research and simulation. Mystic Forge pulls from EDHREC, Commander Spellbook and the Comprehensive Rules.
Accountability: every tool call is tied to whoever signed in, and every deck change lands in an audit log.
Quick start
Running a gateway
You need a machine with Docker, a domain name, and an OpenID Connect identity provider you control (Authentik, Keycloak, Authelia, ...).
Pick a guide and work through it top to bottom:
One machine: docs/DEPLOY-COMPOSE.md. Plain
docker compose, with an optional Caddy that gets the HTTPS certificate for you.Docker Swarm, with or without Portainer: docs/DEPLOY.md.
Both go in the order you'll need things: identity provider, secrets, settings, start, proxy, then a quick check that it all works. Identity provider details are in docs/IDP-AUTHENTIK.md and docs/IDP-OTHERS.md; proxy details in docs/REVERSE-PROXY.md.
Optional: if you use Claude Code, the
mtg-gateway-operatorplugin walks you through the same steps and generates the secrets for you. See docs/PLUGIN.md.Keep docs/OPERATIONS.md handy for running it: updates, backups, adding and removing people, and turning deck writes on or off.
To invite someone, give them an account in your identity provider, then send them your gateway's address and docs/ONBOARDING.md.
Using a gateway someone gave you
Follow docs/ONBOARDING.md. It takes about ten minutes and all you need is a browser and the AI app you already use.
The quickest way in is the install page on the gateway itself:
https://<gateway>/install. More on that in docs/PLUGIN.md.
Documentation
Guide | For | What's in it |
Users | Getting access, connecting your assistant, linking Archidekt, how edits get approved, privacy, leaving | |
Users | Step-by-step connection for each Claude and ChatGPT app, which devices work, and fixes for sign-in errors | |
Users and operators | The one-link plugin for Claude Code, Claude, ChatGPT and Codex, plus the operator plugin | |
Users | The MTG skill and the ChatGPT instructions that teach the assistant the safe way to work | |
Contributors and app builders | The JSON API and the companion pages: authentication, every endpoint, proposal kinds, the page routes the Android app wraps | |
Users and operators | Turning a pile of physical cards into a decklist with your phone camera or a photo | |
Users and operators | The MTG Assistant Gateway Android app: getting it from your gateway, the phone-camera scan screen, building, signing and distributing it without an app store | |
Everyone | How the pieces fit, what you can swap, how sign-in and deck edits work, the security model | |
Operators | A full deploy on one machine with Docker Compose | |
Operators | A full deploy on Docker Swarm (Portainer optional), plus every environment variable | |
Operators | What the proxy must do, with Caddy, Traefik, nginx and Nginx Proxy Manager examples | |
Operators | Authentik, field by field: group, provider, application, binding, adding people, checks and troubleshooting | |
Operators | The identity provider checklist, and notes for Keycloak, Authelia, Zitadel, Pocket ID, Kanidm, Entra ID and Google | |
Operators | Following | |
Operators | Logs, updates, people, which AI clients may connect, backups, rotating secrets, revoking access, deck writes, the audit log | |
Operators | Symptoms and fixes, from a container that won't start to a sign-in that fails | |
Everyone | Licences of the components the gateway is built on | |
Contributors | The end-to-end test setup: a real Swarm stack, Authentik and a scripted client |
Screenshots of the browser pages are in docs/screenshots/.
Features
Sign in. Users sign in from Claude or ChatGPT with OAuth, through the operator's identity provider. The
whoamitool shows who's signed in.Research. Card search, prices, rulings, the Comprehensive Rules, EDHREC, Commander Spellbook combos, precons, deck validation, public Archidekt decks and goldfish simulation.
These come from Mystic Forge. The gateway only passes through tools on an allowlist, and always as the signed-in user.
Mystic Forge features that keep per-user state (watchlists, its own saved reports, interactive games) stay hidden until the gateway can track who owns them. Saved reports are covered by the gateway's own deck reports below.
Deck import. Three ways to read a deck. Counts leave out the maybeboard and sideboard.
get_deckreads any public or unlisted Archidekt deck from a link;parse_decklistreads a pasted list;parse_deck_exportreads an Archidekt CSV export.
Your decks. Link your Archidekt account once on the
/accountpage. After that,list_my_decks(filter by name, format or folder) andget_my_deckcan read your decks, private ones included. The gateway refreshes the stored Archidekt session on its own when it is about to expire or Archidekt rejects it, so a link lasts until Archidekt refuses the refresh too; each refresh is audited.Deck statistics and bracket estimate.
deck_statscomputes the mana curve, colour pips against mana sources, types, rarities, lands, average mana value, price total, format legality problems, salt, game changers, tutors, extra turns and mass land denial from Archidekt's own card data, plus a Commander bracket estimate (2 to 4) from those flags. It is an estimate, not an official bracket, and the tools say so.Deck reports and history.
run_deck_reportstores the statistics together with a decklist validation and a goldfish simulation (when Mystic Forge is up) so a deck's numbers can be followed over time withlist_deck_reportsandget_deck_report, or on the/historypage next to the deck's proposals and snapshots.Compare decks.
compare_deckslists the cards added, removed and changed between any two of: an Archidekt deck, a snapshot (get_snapshotshows one in full) or a pasted list, with the change in the statistics.Safe writes. Every edit starts as a proposal:
propose_deck_changes(edit a deck) andpropose_new_deck(build one from a card list, a pasted list or a CSV) save the exact diff and a review link.The user says yes, either in chat (if the operator allows
apply_proposal) or with the Apply button on the review page.For an edit, the gateway checks the deck hasn't changed since the proposal, saves a snapshot, puts a private backup copy of the deck in the user's "MTG Gateway backups" folder on Archidekt, makes the change, then reads the deck back to confirm it.
Undo is the same flow in reverse:
list_snapshots, thenpropose_restore_snapshot, which puts every card back as it was (printing, foil, quantity, categories, commander, sideboard and maybeboard).A pending proposal the user no longer wants is closed with
reject_proposalor the Reject button.Every step is audited and limited to the signed-in user.
Companion pages.
/decks,/historyand/activityare a phone-friendly deck view and editor behind the same sign-in: browse and open decks, see statistics, run a report, edit quantities, categories and additions as one proposal, and look back over proposals, snapshots and reports. They also serve as the pages an Android app can wrap.Admin page. Members of
MTG_ADMIN_GROUPget/admin: who has signed in, their activity, per-day usage counts, and buttons to disable or enable an account, revoke its tokens and sessions, or unlink Archidekt. Unset, the page does not exist. Details in docs/OPERATIONS.md.JSON API. Everything the tools and pages do is also under
/api/v1for app builders, with the same sign-in and the same proposal flow. See docs/API.md.Card scanning. The
/scanpage reads physical cards with your phone camera. Text recognition runs on the phone, no third-party app needed.resolve_cardsturns card names read from photos into exact cards.One-link setup. The gateway serves its own assistant plugin and an install page at
/install.
Status
The gateway is in testing: versions below 1.0.0 can still change in small ways between releases (docs/VERSIONS.md).
Area | State |
Sign-in, research, deck import, account linking, proposals, scanning | Built. Tested against fakes, recorded Archidekt and Scryfall responses, and a real Swarm stack with Authentik in CI |
Applying edits, creating decks, backups and restores on Archidekt | Built, and run live against a throwaway Archidekt account (create, add, remove, quantities, categories, commander, backup folder and copy). The code default is off ( |
Client and device coverage | See docs/CONNECT.md, which labels each claim as verified, reported or unverified |
Deck statistics, stored deck reports and history, compare, companion pages, admin page, JSON API | Built and covered by the test suite against fakes. The companion pages and admin page have not yet had the same live Swarm run-through as the rest; treat that as unverified |
Watchlists, price history | Not yet (Mystic Forge's own saved goldfish reports stay hidden too; the gateway's stored deck reports replace them) |
How it works
The full picture, with diagrams, is in docs/ARCHITECTURE.md. In short:
Claude / ChatGPT / browser ──HTTPS──▶ reverse proxy ──▶ mtg-gateway ──internal network──▶ Mystic Forge
├─ OAuth 2.1 authorization server for MCP clients
│ (client registration or metadata documents, PKCE, refresh, revoke)
├─ login handed off to your identity provider (OIDC)
├─ MCP endpoint at /mcp; JSON API at /api/v1
├─ browser pages /account, /proposals, /scan, /decks, /history, /activity, /admin, /install
├─ Archidekt adapter (paced, per-user sessions) ──▶ archidekt.com
└─ SQLite on local disk, nightly backup exportThe gateway is its own OAuth server.
An AI client either registers itself, or identifies itself with a Client ID Metadata Document URL. The gateway fetches that document under tight network rules.
The client sends the user to
/authorize. If the client identified itself with a metadata document, the user first sees a page naming the client and where the sign-in returns to.The gateway then sends the browser to your identity provider and, once that's done, hands the client its own opaque tokens.
One identity per person. A single confidential OIDC client at your identity provider covers every AI client, so each person is the same user across Claude, ChatGPT and the browser pages.
No site details in the code. Everything deployment-specific comes from environment variables and Docker secrets.
Security model
Who can sign in is decided in your identity provider, through the application binding and groups. The gateway also requires a specific group (
MTG_REQUIRED_GROUP) and refuses to start without one unless you opt out withMTG_ALLOW_ANY_IDP_USER=true.Tokens:
/mcponly accepts tokens the gateway issued itself, so a token straight from the identity provider is rejected.Tokens and registered clients' secrets are stored hashed.
Refresh tokens rotate, and reusing an old one kills the whole chain.
Authorization codes are single-use and tied to PKCE.
Clients can only register
httpsreturn addresses, orhttpon localhost.
Archidekt passwords are used once to get a session and never stored.
The session is encrypted with a key that lives in a Docker secret.
That protects the database and backups. It doesn't protect against whoever runs the server, and users are told so.
Deck changes need the user's own yes. Text found in decks or tool output is never treated as an instruction to edit.
Mystic Forge has no published ports and no login of its own. Only the gateway can reach it.
Repository layout
Path | What's there |
| Application code |
| Tests against a fake identity provider, a fake Archidekt and recorded live responses; |
| The assistant plugins (for users and for operators) and the repository's plugin marketplace. |
| Gateway and Mystic Forge container images (multi-arch, run as |
| The Swarm stack file and its example settings; |
| The MTG Assistant Gateway Android app (Kotlin, framework only) with its SDK-free build script; see docs/ANDROID.md |
| The guides listed under Documentation, plus screenshots |
| Tests, end-to-end tests, container smoke test, image publishing to GHCR |
Development
python -m venv .venv && . .venv/bin/activate
pip install -c constraints.txt -e ".[dev]"
ruff check src tests && ruff format --check src tests && pytest -qContributions are welcome: see CONTRIBUTING.md and the code of conduct. Please report security problems privately, as described in SECURITY.md. Notable changes are in the CHANGELOG.
License
PolyForm Noncommercial 1.0.0: use it, change it and share it for anything noncommercial. Mystic Forge is a separate project under its own MIT licence. Everything else the gateway is built on is listed in docs/THIRD-PARTY-NOTICES.md.
This server cannot be deployed
Maintenance
Related MCP Connectors
Let Claude or ChatGPT search, read and send your WhatsApp messages over MCP. OAuth sign-in.
Connect any AI agent to 1,000+ apps and 27,000+ actions through one remote MCP server (OAuth).
MCP server for Argo RPG Platform — connects AI assistants to campaign data via OAuth2
MCP server connecting AI agents to 100+ apps (Gmail, Slack, Notion, GitHub) via one-click OAuth.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables interaction with Google Sheets, Docs, Slides, and Drive through a remote MCP server hosted on Cloudflare Workers, with OAuth authentication and Claude-native connect.-
- AlicenseNot gradedqualityBmaintenanceEnables MCP-compatible AI agents to read and write architecture-map projects and diagrams with per-project access controls via OAuth 2.1/PKCE.11 npm1ISC
- FlicenseNot gradedqualityCmaintenanceAn OAuth-secured remote MCP server (22 tools) that lets Claude, ChatGPT, and Codex search All-In Summit attendee profiles, explore the live agenda, check sessions and meetings, detect scheduling conflicts, and export a calendar. Account-changing actions are only prepared for review, with the user confirming each request in the browser before any event API call is made.-
- AlicenseNot gradedqualityBmaintenanceProvides a single MCP server endpoint that lets AI agents connect to many real third-party services through OAuth, with user approvals, activity logs, scoped read/write grants, and one-tap access removal.5 npmAGPL 3.0