This guide walks through connecting Claude Code to a Celonis MCP Server using OAuth 2.0 (the required method for all new set ups as of June 30, 2026).
There are two paths:
- Path A — Authorization Code + PKCE (Advanced / tenant-dependent, currently blocked). This method would eliminate the refresh script and restart entirely via Claude Code's native browser login, but requires your Celonis tenant's OAuth app registration to accept a
http://localhostredirect URI, which is confirmed rejected on at least one tenant (where Celonis enforces HTTPS-only redirect URIs). Only attempt this path if you've confirmed that your own tenant accepts loopback redirect URIs. - Path B — Client Credentials (Default). Works on every tenant tested so far. Requires a manual refresh script and a full Claude Code restart every time the token expires (~15 minutes).
Start with Path B unless you've already confirmed Path A works for your tenant.
- A Celonis MCP Server Asset already created in Celonis Studio, and its asset ID (a UUID)
- Access to Celonis Admin & Settings to create/view an OAuth application
- Claude Code installed, with terminal access
- For Path B:
curlandpython3available (both ship standard on macOS/Linux)
Once the MCP Server asset has been successfully published in Celonis Studio (i.e. “Create Version” → “Deploy”), it will automatically generate an MCP Server URL. Prompt the user to provide this URL — from this URL, extract the following information:
- Team — the first part of your Celonis URL (e.g.
acme-corpinacme-corp.eu-1.celonis.cloud) - Realm — one of
us-1,eu-1,eu-2,ap-1, ortry(for trial environments) - Asset ID — the UUID of your MCP Server Asset in Celonis Studio
MCP Server URL format:
https://{team}.{realm}.celonis.cloud/studio-copilot/api/v1/mcp-servers/mcp/{asset-id}Example:
https://acme-corp.eu-1.celonis.cloud/studio-copilot/api/v1/mcp-servers/mcp/12345678-abcd-1234-efgh-123456789abcUse this path only if you've confirmed your Celonis tenant's OAuth app registration accepts a http://localhost redirect URI (see A1 below). If you haven't confirmed that, use Path B instead — it's the default for a reason.
If this option works for your tenant, this path eliminates the refresh script and restart entirely. Claude Code handles login and token refresh natively — there's no .env, no refresh script, and no restart required, ever.
In Celonis, go to Admin & Settings → Applications and create (or select) an application with the Authorization Code grant type enabled.
For the redirect URI field, enter:
http://localhost:<port>/callbackwhere youb substitute a port of your choice (e.g. 8080) for <port>. This exact format — scheme http, host literally localhost (not 127.0.0.1), path /callback — comes from the Claude Code documentation for the --callback-port flag and is what you'll need to match in Step A2.
Confirmed blocked on at least one tenant. Live testing against a Celonis tenant showed the OAuth app registration UI rejects this redirect URI at registration time with an HTTPS-required error. This is a structural incompatibility, not a fixable misconfiguration: Claude Code's native OAuth flow requires a loopback redirect (per RFC 8252, the standard for native/CLI apps), and this tenant's auth server (Microsoft Entra-backed) requires HTTPS. No port or path variation will work around it. Try registering the URI above first — if Celonis's registration UI accepts it, the rest of Path A should work. If it's rejected, stop here and use Path B.
Note whether your app is a public or confidential client as confidential clients also have a Client Secret. Note down the Client ID (and Client Secret, if confidential).
You'll also need the Team, Realm, and Asset ID described in Step 1 above.
No .env file and no manual JSON editing — the config entry is created for you. Try auto-discovery first:
claude mcp add --transport http celonis <your-constructed-url-from-step-2>If Celonis's tenant doesn't expose standards-based OAuth discovery metadata, auto-discovery will fail. Your fallback is to use explicit flags:
claude mcp add --transport http --client-id <client-id> [--client-secret] \
--callback-port <port> celonis <your-constructed-url-from-step-2>Use the same <port> you registered in Step A1. Omit --client-secret if your app is a public client.
Do not add a headers block with a static Authorization value to this config entry. A static header combined with OAuth causes Claude Code to hard-fail rather than fall back. That pattern is Path B only.
claude mcp login celonisThis opens a system browser for login and consent. For headless/SSH sessions with no local browser:
claude mcp login celonis --no-browserThis prints a URL to open elsewhere and accepts a pasted redirect URL back.
Run /mcp and confirm celonis shows as connected. Then ask Claude: "What tools does the celonis MCP server expose?"
That's it — no refresh script, no restart. Claude Code refreshes the token silently in the background.
| Symptom | Cause | Fix |
|---|---|---|
Browser doesn't open on claude mcp login | Headless/SSH session, or no default browser | Use claude mcp login celonis --no-browser and paste the redirect URL manually |
claude mcp add doesn't auto-discover the auth server | Celonis tenant doesn't expose OAuth discovery metadata | Re-run with explicit --client-id/--client-secret/--callback-port flags |
| Callback port conflict ("address already in use") | Another local process is bound to that port | Pick a different port, re-register the matching redirect URI in Celonis Admin, retry |
invalid_client / unauthorized_client | Public vs. confidential client mismatch | Confirm the client type in Celonis Admin; re-run with matching flags |
Login succeeds but /mcp shows disconnected | Redirect URI mismatch between registration and --callback-port | Recheck they match exactly, including http://localhost:<port>/callback |
Celonis rejects the http://localhost:<port>/callback redirect URI at registration, or login fails specifically on the redirect step | Confirmed HTTPS-only enforcement on this tenant's auth server — not a fixable misconfiguration | Use Path B (Client Credentials) below |
Use this path as it's the only one confirmed to work end-to-end today. (Path A above remains documented for tenants where Celonis's OAuth app registration accepts loopback redirect URIs.) It requires manually refreshing a short-lived token and fully restarting Claude Code every ~15 minutes.
In Celonis:
- Go to Admin & Settings → Applications.
- Select your application (or create one).
- Confirm that it has the "Client Credentials" grant type enabled. Without this, token requests will fail.
- Note down the Client ID and Client Secret.
You'll also need the Team, Realm, and Asset ID described in Step 1 above.
Create a .env file in your project directory (or ~/.env if you want it available globally) with:
CELONIS_CLIENT_ID=<your-client-id>
CELONIS_CLIENT_SECRET=<your-client-secret>
CELONIS_TEAM=<your-team>
CELONIS_REALM=<your-realm>
CELONIS_ACCESS_TOKEN=Claude Code does not automatically read .env files. The CELONIS_ACCESS_TOKEN must be present in the shell environment that launches Claude Code. The simplest way to guarantee this is to auto-load .env in your shell profile:
# Add to ~/.zshrc or ~/.bashrc
[ -f ~/.env ] && set -a && source ~/.env && set +aThen open a new terminal (or run source ~/.zshrc) so the change takes effect.
Add .env to your .gitignore if this is inside a git repo — never commit credentials.
Add this entry to .mcp.json (project-level) or ~/.claude/settings.json (global, under mcpServers):
{
"mcpServers": {
"celonis": {
"type": "http",
"url": "<your-constructed-url-from-step-2>",
"headers": {
"Authorization": "Bearer ${CELONIS_ACCESS_TOKEN}",
"Accept": "application/json, text/event-stream"
}
}
}
}Use project-level .mcp.json if you want to share the config (minus credentials) via git. Use global settings.json if you want the same Celonis connection available across all projects.
OAuth tokens from Celonis expire in roughly 15 minutes, so you'll need to refresh before each session. Save this as refresh-token.sh in your project directory and run chmod +x refresh-token.sh:
#!/bin/bash
# Fetches a fresh OAuth 2.0 token from Celonis and updates CELONIS_ACCESS_TOKEN in .env.
set -euo pipefail
ENV_FILE="$(cd "$(dirname "$0")" && pwd)/.env"
if [ ! -f "$ENV_FILE" ]; then
echo "Error: .env file not found at $ENV_FILE"
exit 1
fi
set -a
source "$ENV_FILE"
set +a
for var in CELONIS_CLIENT_ID CELONIS_CLIENT_SECRET CELONIS_TEAM CELONIS_REALM; do
if [ -z "${!var:-}" ]; then
echo "Error: $var is not set in .env"
exit 1
fi
done
echo "Requesting token from Celonis..."
RESPONSE=$(curl -s -w "\n%{http_code}" -X POST \
"https://${CELONIS_TEAM}.${CELONIS_REALM}.celonis.cloud/oauth2/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials" \
-d "client_id=${CELONIS_CLIENT_ID}" \
-d "client_secret=${CELONIS_CLIENT_SECRET}" \
-d "scope=mcp-asset.tools:execute")
HTTP_STATUS=$(echo "$RESPONSE" | tail -n1)
BODY=$(echo "$RESPONSE" | sed '$d')
if [ "$HTTP_STATUS" != "200" ]; then
echo "Error: Token request failed (HTTP $HTTP_STATUS)"
echo "$BODY"
exit 1
fi
TOKEN=$(echo "$BODY" | python3 -c "import sys, json; d=json.load(sys.stdin); print(d['access_token'])" 2>/dev/null || true)
if [ -z "$TOKEN" ]; then
echo "Error: Could not parse access_token from response:"
echo "$BODY"
exit 1
fi
NEW_TOKEN="$TOKEN" ENV_FILE="$ENV_FILE" python3 - <<'EOF'
import os, re
token = os.environ['NEW_TOKEN']
env_file = os.environ['ENV_FILE']
with open(env_file, 'r') as f:
content = f.read()
updated = re.sub(r'^CELONIS_ACCESS_TOKEN=.*', f'CELONIS_ACCESS_TOKEN={token}', content, flags=re.MULTILINE)
if 'CELONIS_ACCESS_TOKEN=' not in updated:
updated += f'\nCELONIS_ACCESS_TOKEN={token}\n'
with open(env_file, 'w') as f:
f.write(updated)
EOF
echo "Done. CELONIS_ACCESS_TOKEN updated in .env"Run it with ./refresh-token.sh any time before starting a Claude Code session.
- Run
./refresh-token.shto get a fresh token. - Fully restart Claude Code, with the new token loaded. How you do this depends on whether you're using Terminal or VS Code, and (for VS Code) which scope you chose in Step 4:
Terminal: In the same terminal, run
set -a && source .env && set +a, then Ctrl+C andclaudeto restart.VS Code, project-scope config (
.mcp.json): The token must be sourced in the terminal you launch VS Code from, and VS Code must be opened from inside this project directory. Run:cd /path/to/this/project set -a && source .env && set +a code .VS Code, global-scope config (
~/.claude/settings.json): The directory doesn't matter, but the token still needs sourcing first:set -a && source ~/.env && set +a code .Only fall back to quitting (Cmd+Q) and reopening VS Code via Finder/Dock if
code .isn't available. That path needs an extralaunchctl setenvstep (see B6 below), and closing the window alone is not enough on its own.
- Run
/mcpto confirm thecelonisserver shows as connected. - Test by asking Claude: "What tools does the Celonis MCP server expose?".
Every single time you refresh — not just the first time — you must repeat all three steps: refresh, source, restart. Running ./refresh-token.sh only updates the .env file on disk. Your currently-running shell (and any Claude Code session launched from it) keeps whatever token it already has in memory until you explicitly re-run set -a && source .env && set +a in that same terminal, and then launch a fresh Claude Code session from it. Skipping the "source" step is the single most common cause of a token refresh silently "not working."
Also note that Claude Code discovers an MCP server's tools once, at session startup. Refreshing the token after a session has already started, or reconnecting a failed server mid-session, does not re-trigger tool discovery. You must fix the token and then start a brand-new session, in that order. A mid-session reconnect will show the server as healthy but the mcp__celonis__* tools still won't display until you restart.
| Symptom | Cause | Fix |
|---|---|---|
Server not in /mcp | Config not saved correctly, or wrong file | Re-check .mcp.json / settings.json syntax and location |
FORBIDDEN error | Token expired, or wrong auth prefix | Run ./refresh-token.sh, then source .env in the same terminal, then restart — all three steps, every time |
Unauthorized / 401 | Token expired mid-session, or refreshed without re-sourcing | Run ./refresh-token.sh, then source .env in the same terminal, then restart — all three steps, every time |
Tools connect but mcp__celonis__* still missing after reconnecting | Tool discovery only runs at session startup — a mid-session reconnect doesn't re-trigger it | Start a brand-new session after the token is already valid, rather than fixing it mid-session |
| Token request fails (non-200) | Client Credentials grant type not enabled, or wrong client ID/secret | Recheck the OAuth app config in Celonis Admin |
| VS Code extension won't pick up new token (macOS) | Token not sourced in the launching terminal, or (project scope) VS Code not opened from the right directory, or launched via Finder/Dock (doesn't inherit shell env vars) | Prefer set -a && source .env && set +a then code . from the correct directory. If you must launch via Finder/Dock, run launchctl setenv CELONIS_ACCESS_TOKEN "<token>" first, then fully quit (Cmd+Q) and reopen |
Server entry missing from .mcp.json entirely | claude mcp remove <name> was run to inspect the config, but it deletes rather than displays | Use claude mcp get <name> to inspect without deleting; re-add the entry manually if it was removed |
- Path B (Client Credentials) is the default and only confirmed-working path today. Path A (Authorization Code + PKCE) is documented for tenants whose Celonis OAuth app registration accepts
http://localhostredirect URIs — this tenant's does not. - OAuth 2.0 is the only supported method for new Celonis API credentials as of June 30, 2026.
- Path B only — Never commit
.envor any file containing your Client Secret or Access Token to version control (Path A creates no such file).