Skip to content
Last updated

Setting up Celonis Agent Tools (MCP Server) in Claude Code

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://localhost redirect 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.

Prerequisites

  • 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: curl and python3 available (both ship standard on macOS/Linux)

Step 1: Construct your MCP Server URL

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-corp in acme-corp.eu-1.celonis.cloud)
  • Realm — one of us-1, eu-1, eu-2, ap-1, or try (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-123456789abc


Path A: Authorization Code + PKCE

Note

Use 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.

A1. Register an OAuth app for interactive login

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>/callback

where 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.

A2. Connect with the Claude Code CLI

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.

Note

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.

A3. Log in

claude mcp login celonis

This opens a system browser for login and consent. For headless/SSH sessions with no local browser:

claude mcp login celonis --no-browser

This prints a URL to open elsewhere and accepts a pasted redirect URL back.

A4. Test

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.

A5. Troubleshooting (Path A)

SymptomCauseFix
Browser doesn't open on claude mcp loginHeadless/SSH session, or no default browserUse claude mcp login celonis --no-browser and paste the redirect URL manually
claude mcp add doesn't auto-discover the auth serverCelonis tenant doesn't expose OAuth discovery metadataRe-run with explicit --client-id/--client-secret/--callback-port flags
Callback port conflict ("address already in use")Another local process is bound to that portPick a different port, re-register the matching redirect URI in Celonis Admin, retry
invalid_client / unauthorized_clientPublic vs. confidential client mismatchConfirm the client type in Celonis Admin; re-run with matching flags
Login succeeds but /mcp shows disconnectedRedirect URI mismatch between registration and --callback-portRecheck 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 stepConfirmed HTTPS-only enforcement on this tenant's auth server — not a fixable misconfigurationUse Path B (Client Credentials) below

Path B: Client Credentials (Default)

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.

B1. Get your OAuth credentials

In Celonis:

  1. Go to Admin & Settings → Applications.
  2. Select your application (or create one).
  3. Confirm that it has the "Client Credentials" grant type enabled. Without this, token requests will fail.
  4. Note down the Client ID and Client Secret.

You'll also need the Team, Realm, and Asset ID described in Step 1 above.

B2. Store your credentials

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=
Note

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 +a

Then 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.

B3. Add the MCP server to your config

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.

B4. Set up token refresh

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.

B5. Activate and test

  1. Run ./refresh-token.sh to get a fresh token.
  2. 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 and claude to 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 extra launchctl setenv step (see B6 below), and closing the window alone is not enough on its own.

  3. Run /mcp to confirm the celonis server shows as connected.
  4. Test by asking Claude: "What tools does the Celonis MCP server expose?".

B6. Troubleshooting (Path B)

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.

SymptomCauseFix
Server not in /mcpConfig not saved correctly, or wrong fileRe-check .mcp.json / settings.json syntax and location
FORBIDDEN errorToken expired, or wrong auth prefixRun ./refresh-token.sh, then source .env in the same terminal, then restart — all three steps, every time
Unauthorized / 401Token expired mid-session, or refreshed without re-sourcingRun ./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 reconnectingTool discovery only runs at session startup — a mid-session reconnect doesn't re-trigger itStart 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/secretRecheck 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 entirelyclaude mcp remove <name> was run to inspect the config, but it deletes rather than displaysUse claude mcp get <name> to inspect without deleting; re-add the entry manually if it was removed

Notes

  • 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://localhost redirect 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 .env or any file containing your Client Secret or Access Token to version control (Path A creates no such file).