Skip to main content

CONNECT YOUR TEAM'S AI APPS TO SWAMP SERVE

This guide shows you how to let your team's AI apps (Claude, Claude Code, Codex, ChatGPT and Gemini) find, run and follow workflows on your serve. Each member signs in from their app as themselves, and the app can do only what that member's grants allow, capped by a ceiling you set per app.

Members connect from their side with Connect Your AI App to a Team Serve. For why it works this way, see AI apps over MCP.

Prerequisites

  • A serve in auth mode oauth, started with a collective API key, as in Deploy with Headless OAuth. A member's sign-in is a link to their Swamp account, and swamp-club links people only to a serve whose OAuth client a collective owns. A serve that registered itself from your own account answers 409 links_require_collective_client.
  • That collective on a trial or a paid plan. Otherwise a sign-in is refused with links_require_plan.
  • A public HTTPS address for the serve, for Claude and ChatGPT, which reach it from their own servers. Claude Code, Codex and Antigravity run on the member's computer, so a serve they can reach is enough.

A serve in auth mode token also answers /mcp, for scripts and clients that send a serve token; see Use a serve token instead.

Turn on /mcp

/mcp is off until you turn it on. Add mcp: true to .swamp/serve.yaml:

version: 2
mcp: true

Or pass --mcp, or set SWAMP_MCP=true. swamp serve reload turns it on or off without a restart. While it is off, /mcp answers 404. Serve logs:

MCP endpoint enabled at "https://swamp.example.com/mcp"

Auth mode none checks no token, so serve refuses /mcp there:

Error: MCP is refused with --auth-mode none, which checks no token; set --auth-mode token or oauth, or turn mcp off

Make it reachable

  1. Name the public host. Serve names itself after the request's Host, and offers OAuth sign-in only at a host in --trusted-hosts. Add the public hostname, as host:port when the port is not 443:

    version: 2
    mcp: true
    trusted-hosts: [swamp.example.com]
    trust-proxy: true

    Set trust-proxy when a reverse proxy or ingress terminates TLS, so serve reads the public scheme and host from X-Forwarded-Proto and X-Forwarded-Host. Without a trusted host, swamp serve check-config warns:

    MCP clients can sign in only at a host listed in --trusted-hosts (or a loopback name when serve listens on loopback), since serve names itself after the request's Host; add the public hostname to --trusted-hosts, with --trust-proxy behind a proxy or tunnel
  2. Pass the paths through your proxy. Route /mcp, /.well-known/ and /oauth/ to serve. Apps read /.well-known/oauth-protected-resource/mcp and /.well-known/oauth-authorization-server first, then sign in through /oauth/register, /oauth/authorize and /oauth/token.

  3. Keep it running. Run serve as a system service with swamp serve daemon enable; see Run as a System Daemon. swamp serve host daemon enable does the same for a serve host (experimental).

Behind a serve host, each workspace has its own /mcp, turned on in that workspace's own serve.yaml. The root workspace answers at <host>/mcp and offers OAuth sign-in. Another workspace answers at <host>/w/<name>/mcp and takes serve tokens only.

Choose which apps can sign in

No app can sign in until you list it under mcp-oauth.clients. With no list, serve logs this at startup and at each reload that changes mcp or mcp-oauth, and check-config reports it:

No app can sign in to /mcp: mcp-oauth.clients in serve.yaml lists none. Add each app members use, such as "- builtin: claude", then run swamp serve reload

List each app your members use:

version: 2
mcp: true
trusted-hosts: [swamp.example.com]
trust-proxy: true
mcp-oauth:
  clients:
    - builtin: claude
    - builtin: claude-code
    - builtin: codex
    - builtin: chatgpt
    - builtin: gemini
      redirect-uris:
        - https://oauth-redirect.googleusercontent.com/r/<your id>

Then run swamp serve reload. Serve logs Applied: mcp-oauth.

Entry Lets in
claude claude.ai and the Claude apps, through Claude's callback. Every Claude account shares it
claude-code Claude Code on any computer, through its client metadata document and a loopback redirect
codex Codex on any computer, through its client metadata document and a loopback redirect
chatgpt ChatGPT through its fixed redirect, shared by every ChatGPT workspace
gemini Gemini, through only the redirects you list on its line
local Any app on the member's own computer: the MCP Inspector, VS Code. Any loopback redirect, any port

Except for gemini and connector redirects, an entry trusts every account of that app. The member's consent on swamp-club and their grants are the only further control. A builtin line takes no other key, except redirect-uris on gemini and chatgpt.

Gemini. The Gemini web app offers no custom MCP servers, so this entry is for a Gemini that does, and was not walked through against a serve. builtin: gemini requires redirect-uris: the exact https://oauth-redirect.googleusercontent.com/r/<id> or /a/<id> URLs Gemini shows when a member adds the serve. The last segment names whose Gemini gets the sign-in, so there is no wildcard. Ask members for the URL Gemini shows them, add it, and reload.

ChatGPT. builtin: chatgpt covers ChatGPT's fixed redirect https://chatgpt.com/connector_platform_oauth_redirect, which ChatGPT uses for any serve. A connector that shows a redirect of its own, https://chatgpt.com/connector/oauth/<id>, needs that exact URL under redirect-uris on the builtin: chatgpt line.

An app with no built-in entry. Write an entry of your own. Antigravity, which replaces Gemini CLI, identifies itself by a client metadata document and returns through antigravity.google:

mcp-oauth:
  clients:
    - name: antigravity
      display-name: Antigravity
      client-ids:
        - https://antigravity.google/oauth/client-metadata.json

Like claude, this trusts every Antigravity user's sign-in. An app that takes a client ID and secret typed by hand, such as Gemini Enterprise (not walked through against a serve), gets a pre-registered entry:

mcp-oauth:
  clients:
    - name: gemini-enterprise
      display-name: Gemini Enterprise
      client-id: acme-gemini
      client-secret-hash: "sha256:<64 hex digits>"
      redirect-uris:
        - https://vertexaisearch.cloud.google.com/oauth-redirect

name is lowercase letters, digits and hyphens. client-id is the ID members type into the app; with client-secret-hash the app must also send the secret. Compute the hash with printf %s "<secret>" | sha256sum and put sha256: in front. An entry without client-id lets an app in by redirect-uris or by client-ids, the URLs of client metadata documents.

In a pattern of your own, * stands for one path segment and a final ** for any number. Outside a loopback redirect it trusts every value there, which can name another tenant's app, so serve warns about each one:

mcp-oauth.clients entry "partner" allows "https://apps.example.com/*/callback": its * stands for any value there, which can name another tenant's app; list the exact URLs instead

Decide what each app may do

Every sign-in through an entry is held to integration mcp-<entry>, such as mcp-codex. An app does what both the member's grants and that integration's ceiling allow. By default the ceiling is approve, read, run and signal on workflow:*, which covers every MCP tool.

Narrow it for every app with default-ceiling:

mcp-oauth:
  default-ceiling:
    version: 1
    ceiling:
      - resource: "workflow:*"
        actions: [read, run, signal]
  clients:
    - builtin: claude
    - builtin: codex

Give an entry of your own a different ceiling with ceiling on its line. Built-in entries always take default-ceiling. A ceiling names only workflow: resources and the actions read, run, approve and signal.

Narrowing applies to existing sign-ins at their next request. Serve logs:

Narrowed integration "mcp-codex" to its MCP allowlist entry "codex"; its existing sign-ins are narrowed at their next request

Serve never widens a ceiling for you. After you widen one in serve.yaml, new sign-ins through that entry are refused until you widen the integration too:

swamp access integration ceiling mcp-codex \
  --ceiling approve,read,run,signal='workflow:*' \
  --server https://swamp.example.com

Lock down approval gates

With /mcp on, a member's AI app can approve or reject any gate their grants let them decide, including a gate on a run they started themselves. Serve has no rule against it, and the app asks the member only if the app itself chooses to. Pick one or both of these.

Refuse self-approval. Deny approve on a run its initiator started. This holds for every client: AI apps, the dashboard and the CLI.

# grants/no-self-approval.yaml
grants:
  - subject: "group:release-managers"
    effect: deny
    actions: [approve]
    resource: "workflow:*"
    condition: "principal.sub == run.initiator.sub"

Keep AI apps off gates. Either deny approve to every MCP sign-in:

# grants/no-mcp-approval.yaml
grants:
  - subject: "group:release-managers"
    effect: deny
    actions: [approve]
    resource: "workflow:*"
    condition: 'client.startsWith("integration:mcp-")'

or leave approve out of default-ceiling, as in Decide what each app may do.

Apply grant files with swamp access reload; see Manage Grants with Files. A refused member's app sees not_found: No run or wait with that id that you may act on., the gate keeps waiting for someone else, and workflow_approval_list shows the run with canDecide: false.

Know the limits:

  • A deny binds only the subjects it names. There is no wildcard subject: write it once for each subject that holds run, approve or admin on the workflow, since run lets a person approve too.
  • Write denies for users or local groups. collective: and idp-group: subjects match only OAuth sign-ins. A member's minted serve token carries no collectives, so a self-approval deny written for a collective still lets that member approve their own run from the CLI.
  • The second recipe and a ceiling stop sign-ins only. A member who mints a serve token and gives it to an app acts as direct:token, which neither stops. The self-approval deny still applies.
  • Reject is decided as approve, so each recipe also refuses reject.

For the condition language, see CEL conditions.

Change or remove an app

Edit mcp-oauth.clients and run swamp serve reload. A change reaches existing sign-ins at their next request:

  • Narrowing a ceiling narrows every sign-in through that entry.
  • Removing an entry, or a redirect a sign-in used, refuses that sign-in. Its app reports invalid_client: The client was refused: this app is not on the serve's MCP client allowlist; ask the operator to add it under mcp-oauth.clients. The sign-in is not ended: list the entry again and it works.
  • To end the app for everyone now, revoke its integration with swamp access integration revoke mcp-<entry>. A revoked ID cannot be used again.

On a team of serves, a follower that still lists a removed entry answers that app's reads until its access token expires, up to an hour.

Troubleshoot sign-in

What you see Cause and fix
No app can sign in to /mcp at startup or in check-config mcp-oauth.clients lists no app. Add the apps members use and reload
The app can't find how to sign in, or /.well-known/oauth-authorization-server answers 404 The request's host is not in --trusted-hosts, the proxy does not pass /.well-known/ or /oauth/, or serve is not in auth mode oauth
A page reading "This app can't sign in here. Sign-in refused: this app is not on the serve's MCP client allowlist" The app, or the redirect it asked for, is not listed. Serve's log line MCP "authorize" refused names its client_id and redirect_uri: list the built-in, or the exact redirect for Gemini or a ChatGPT connector
A page reading "The serve's allowlist gives Codex more than integration mcp-codex allows" You widened the entry's ceiling in serve.yaml. Widen the integration with swamp access integration ceiling, or narrow the entry
The app reports invalid_client and asks the member to sign in again The entry, or the redirect the sign-in used, left the list. List it again
401 with WWW-Authenticate: Bearer on every call, after the app had worked The sign-in ended: the member used This wasn't me, you ended it with swamp access delegation end, you revoked the app's integration, or its refresh token was reused. The member signs in again
A sign-in refused with links_require_collective_client swamp-club refuses to link people to a serve whose OAuth client no collective owns. Start serve with a collective API key
A sign-in refused with links_require_plan The serve's collective has no trial or plan
An approval over MCP answers not_found: No run or wait with that id that you may act on. A deny or the ceiling refuses approve to that member's app. workflow_approval_list shows canDecide: false
Apps on one hostname are sent to another hostname's sign-in A shared cache in front of serve ignores Vary. The metadata documents are private, max-age=300 and vary on Host and the forwarded headers: don't cache /.well-known/oauth-* at the proxy

Every refused registration or sign-in is in serve's audit log as mcp_oauth.register_refused or mcp_oauth.authorize_refused, with the app's client_id and redirect_uri.