This script automatically fetches a fresh Celonis access token and updates your Claude Desktop config file so you never have to do it manually. You can choose to run it once before starting Claude Desktop or set it to run automatically each time you login. Without this script, the access token will need to be manually refreshed every 15 minutes.
Save the corresponding script below as either refresh-token.sh (Mac/Linux) or refresh-token.bat (Windows) on your computer.
#!/bin/bash
# ── Celonis credentials ───────────────────────────────────────────────────────
CELONIS_CLIENT_ID="YOUR-CLIENT-ID"
CELONIS_CLIENT_SECRET="YOUR-CLIENT-SECRET"
CELONIS_TEAM="YOUR-TEAM"
CELONIS_REALM="YOUR-REALM"
CELONIS_MCP_SERVER_ID="YOUR-MCP-SERVER-ID"
# ── Config file path ──────────────────────────────────────────────────────────
CONFIG_FILE="$HOME/Library/Application Support/Claude/claude_desktop_config.json"
# ── Fetch a new access token ──────────────────────────────────────────────────
echo "Fetching new Celonis access token..."
TOKEN_RESPONSE=$(curl --silent --request POST \
--url "https://${CELONIS_TEAM}.${CELONIS_REALM}.celonis.cloud/oauth2/token" \
--header "content-type: multipart/form-data" \
--form "client_id=${CELONIS_CLIENT_ID}" \
--form "client_secret=${CELONIS_CLIENT_SECRET}" \
--form "grant_type=client_credentials" \
--form "scope=mcp-asset.tools:execute")
ACCESS_TOKEN=$(echo "$TOKEN_RESPONSE" | python3 -c "import sys, json; print(json.load(sys.stdin)['access_token'])")
if [ -z "$ACCESS_TOKEN" ]; then
echo "❌ Failed to fetch access token. Check your credentials."
exit 1
fi
echo "✅ Token fetched successfully."
# ── Write updated config file ─────────────────────────────────────────────────
cat > "$CONFIG_FILE" <<EOF
{
"mcpServers": {
"celonis": {
"command": "npx",
"args": [
"-y",
"mcp-remote",
"https://${CELONIS_TEAM}.${CELONIS_REALM}.celonis.cloud/studio-copilot/api/v1/mcp-servers/mcp/${CELONIS_MCP_SERVER_ID}",
"--header",
"Authorization:\${AUTH_TOKEN}"
],
"env": {
"AUTH_TOKEN": "Bearer ${ACCESS_TOKEN}"
}
}
}
}
EOF
echo "✅ Claude Desktop config updated. Restart Claude Desktop to apply."@echo off
:: ── Celonis credentials ───────────────────────────────────────────────────────
set CELONIS_CLIENT_ID=YOUR-CLIENT-ID
set CELONIS_CLIENT_SECRET=YOUR-CLIENT-SECRET
set CELONIS_TEAM=YOUR-TEAM
set CELONIS_REALM=YOUR-REALM
set CELONIS_MCP_SERVER_ID=YOUR-MCP-SERVER-ID
:: ── Config file path ──────────────────────────────────────────────────────────
set CONFIG_FILE=%APPDATA%\Claude\claude_desktop_config.json
:: ── Fetch a new access token ──────────────────────────────────────────────────
echo Fetching new Celonis access token...
curl --silent --request POST ^
--url "https://%CELONIS_TEAM%.%CELONIS_REALM%.celonis.cloud/oauth2/token" ^
--header "content-type: multipart/form-data" ^
--form "client_id=%CELONIS_CLIENT_ID%" ^
--form "client_secret=%CELONIS_CLIENT_SECRET%" ^
--form "grant_type=client_credentials" ^
--form "scope=mcp-asset.tools:execute" ^
--output token_response.json
for /f "tokens=*" %%a in ('python -c "import json; data=json.load(open('token_response.json')); print(data['access_token'])"') do set ACCESS_TOKEN=%%a
del token_response.json
if "%ACCESS_TOKEN%"=="" (
echo Failed to fetch access token. Check your credentials.
exit /b 1
)
echo Token fetched successfully.
:: ── Write updated config file ─────────────────────────────────────────────────
(
echo {
echo "mcpServers": {
echo "celonis": {
echo "command": "npx",
echo "args": [
echo "-y",
echo "mcp-remote",
echo "https://%CELONIS_TEAM%.%CELONIS_REALM%.celonis.cloud/studio-copilot/api/v1/mcp-servers/mcp/%CELONIS_MCP_SERVER_ID%",
echo "--header",
echo "Authorization:${AUTH_TOKEN}"
echo ],
echo "env": {
echo "AUTH_TOKEN": "Bearer %ACCESS_TOKEN%"
echo }
echo }
echo }
echo }
) > "%CONFIG_FILE%"
echo Claude Desktop config updated. Restart Claude Desktop to apply.- Open Terminal.
- Navigate to the folder where you saved the script:
cd ~/Downloads - Make it executable (first time only):
chmod +x refresh-token.sh - Run the executable:
./refresh-token.sh - Restart Claude Desktop.
- Open File Explorer and find
refresh-token.bat. - Double-click the file to run it.
- Restart Claude Desktop.
If you want the token refreshed every time you start your computer:
Mac: Add the script to System Settings → General → Login Items.
Windows: Press Win + R, type shell:startup, and then add a shortcut to refresh-token.bat in that folder.
| Placeholder | What to put here |
|---|---|
YOUR-CLIENT-ID | OAuth Client ID from Celonis Admin settings |
YOUR-CLIENT-SECRET | OAuth Client Secret from Celonis Admin settings |
YOUR-TEAM | Your Celonis team subdomain |
YOUR-REALM | Your Celonis realm (e.g., us-1, eu-1) |
YOUR-MCP-SERVER-ID | The ID of your published MCP Asset in Celonis Studio |