{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"Auto-Refresh Script for Celonis Access Tokens","description":"API documentation for Celonis APIs.","siteUrl":"https://developer.celonis.com/","keywords":"celonis developer portal, celonis apis, celonis api reference docs","lang":"en-US","llmstxt":{"hide":false,"description":"Celonis API documentation","sections":[{"title":"API Docs","description":"Available Celonis API Docs","includeFiles":["**/*.md"]},{"title":"API Specs","description":"All Celonis API specifications","includeFiles":["**/openapi.yaml"]}]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"auto-refresh-script-for-celonis-access-tokens","__idx":0},"children":["Auto-Refresh Script for Celonis Access Tokens"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["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."]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"auto-refresh-scripts","__idx":1},"children":["Auto-refresh scripts"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Save the corresponding script below as either ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["refresh-token.sh"]}," (Mac/Linux) or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["refresh-token.bat"]}," (Windows) on your computer."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"mac--linux--refresh-tokensh-","__idx":2},"children":["Mac / Linux (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["refresh-token.sh"]},")"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"#!/bin/bash\n\n# ── Celonis credentials ───────────────────────────────────────────────────────\nCELONIS_CLIENT_ID=\"YOUR-CLIENT-ID\"\nCELONIS_CLIENT_SECRET=\"YOUR-CLIENT-SECRET\"\nCELONIS_TEAM=\"YOUR-TEAM\"\nCELONIS_REALM=\"YOUR-REALM\"\nCELONIS_MCP_SERVER_ID=\"YOUR-MCP-SERVER-ID\"\n\n# ── Config file path ──────────────────────────────────────────────────────────\nCONFIG_FILE=\"$HOME/Library/Application Support/Claude/claude_desktop_config.json\"\n\n# ── Fetch a new access token ──────────────────────────────────────────────────\necho \"Fetching new Celonis access token...\"\n\nTOKEN_RESPONSE=$(curl --silent --request POST \\\n  --url \"https://${CELONIS_TEAM}.${CELONIS_REALM}.celonis.cloud/oauth2/token\" \\\n  --header \"content-type: multipart/form-data\" \\\n  --form \"client_id=${CELONIS_CLIENT_ID}\" \\\n  --form \"client_secret=${CELONIS_CLIENT_SECRET}\" \\\n  --form \"grant_type=client_credentials\" \\\n  --form \"scope=mcp-asset.tools:execute\")\n\nACCESS_TOKEN=$(echo \"$TOKEN_RESPONSE\" | python3 -c \"import sys, json; print(json.load(sys.stdin)['access_token'])\")\n\nif [ -z \"$ACCESS_TOKEN\" ]; then\n  echo \"❌ Failed to fetch access token. Check your credentials.\"\n  exit 1\nfi\n\necho \"✅ Token fetched successfully.\"\n\n# ── Write updated config file ─────────────────────────────────────────────────\ncat > \"$CONFIG_FILE\" <<EOF\n{\n  \"mcpServers\": {\n    \"celonis\": {\n      \"command\": \"npx\",\n      \"args\": [\n        \"-y\",\n        \"mcp-remote\",\n        \"https://${CELONIS_TEAM}.${CELONIS_REALM}.celonis.cloud/studio-copilot/api/v1/mcp-servers/mcp/${CELONIS_MCP_SERVER_ID}\",\n        \"--header\",\n        \"Authorization:\\${AUTH_TOKEN}\"\n      ],\n      \"env\": {\n        \"AUTH_TOKEN\": \"Bearer ${ACCESS_TOKEN}\"\n      }\n    }\n  }\n}\nEOF\n\necho \"✅ Claude Desktop config updated. Restart Claude Desktop to apply.\"\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"windows--refresh-tokenbat-","__idx":3},"children":["Windows (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["refresh-token.bat"]},")"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bat","header":{"controls":{"copy":{}}},"source":"@echo off\n\n:: ── Celonis credentials ───────────────────────────────────────────────────────\nset CELONIS_CLIENT_ID=YOUR-CLIENT-ID\nset CELONIS_CLIENT_SECRET=YOUR-CLIENT-SECRET\nset CELONIS_TEAM=YOUR-TEAM\nset CELONIS_REALM=YOUR-REALM\nset CELONIS_MCP_SERVER_ID=YOUR-MCP-SERVER-ID\n\n:: ── Config file path ──────────────────────────────────────────────────────────\nset CONFIG_FILE=%APPDATA%\\Claude\\claude_desktop_config.json\n\n:: ── Fetch a new access token ──────────────────────────────────────────────────\necho Fetching new Celonis access token...\n\ncurl --silent --request POST ^\n  --url \"https://%CELONIS_TEAM%.%CELONIS_REALM%.celonis.cloud/oauth2/token\" ^\n  --header \"content-type: multipart/form-data\" ^\n  --form \"client_id=%CELONIS_CLIENT_ID%\" ^\n  --form \"client_secret=%CELONIS_CLIENT_SECRET%\" ^\n  --form \"grant_type=client_credentials\" ^\n  --form \"scope=mcp-asset.tools:execute\" ^\n  --output token_response.json\n\nfor /f \"tokens=*\" %%a in ('python -c \"import json; data=json.load(open('token_response.json')); print(data['access_token'])\"') do set ACCESS_TOKEN=%%a\ndel token_response.json\n\nif \"%ACCESS_TOKEN%\"==\"\" (\n  echo Failed to fetch access token. Check your credentials.\n  exit /b 1\n)\n\necho Token fetched successfully.\n\n:: ── Write updated config file ─────────────────────────────────────────────────\n(\necho {\necho   \"mcpServers\": {\necho     \"celonis\": {\necho       \"command\": \"npx\",\necho       \"args\": [\necho         \"-y\",\necho         \"mcp-remote\",\necho         \"https://%CELONIS_TEAM%.%CELONIS_REALM%.celonis.cloud/studio-copilot/api/v1/mcp-servers/mcp/%CELONIS_MCP_SERVER_ID%\",\necho         \"--header\",\necho         \"Authorization:${AUTH_TOKEN}\"\necho       ],\necho       \"env\": {\necho         \"AUTH_TOKEN\": \"Bearer %ACCESS_TOKEN%\"\necho       }\necho     }\necho   }\necho }\n) > \"%CONFIG_FILE%\"\n\necho Claude Desktop config updated. Restart Claude Desktop to apply.\n","lang":"bat"},"children":[]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"run-the-script-manually","__idx":4},"children":["Run the script manually"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"mac--linux","__idx":5},"children":["Mac / Linux"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Open Terminal."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Navigate to the folder where you saved the script: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cd ~/Downloads"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Make it executable (first time only): ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["chmod +x refresh-token.sh"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Run the executable: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["./refresh-token.sh"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Restart Claude Desktop."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"windows","__idx":6},"children":["Windows"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Open File Explorer and find ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["refresh-token.bat"]},"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Double-click the file to run it."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Restart Claude Desktop."]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"run-the-script-automatically-on-login-optional","__idx":7},"children":["Run the script automatically on login (optional)"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["If you want the token refreshed every time you start your computer:"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Mac:"]}," Add the script to ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["System Settings → General → Login Items"]},"."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Windows:"]}," Press ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Win + R"]},", type ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["shell:startup"]},", and then add a shortcut to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["refresh-token.bat"]}," in that folder."]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"placeholders-to-replace","__idx":8},"children":["Placeholders to replace"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Placeholder"},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Placeholder"]}]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"What to put here"},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["What to put here"]}]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["YOUR-CLIENT-ID"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["OAuth Client ID from Celonis Admin settings"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["YOUR-CLIENT-SECRET"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["OAuth Client Secret from Celonis Admin settings"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["YOUR-TEAM"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Your Celonis team subdomain"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["YOUR-REALM"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Your Celonis realm (e.g., ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["us-1"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["eu-1"]},")"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["YOUR-MCP-SERVER-ID"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The ID of your published MCP Asset in Celonis Studio"]}]}]}]}]}]},"headings":[{"value":"Auto-Refresh Script for Celonis Access Tokens","id":"auto-refresh-script-for-celonis-access-tokens","depth":1},{"value":"Auto-refresh scripts","id":"auto-refresh-scripts","depth":2},{"value":"Mac / Linux ( refresh-token.sh )","id":"mac--linux--refresh-tokensh-","depth":3},{"value":"Windows ( refresh-token.bat )","id":"windows--refresh-tokenbat-","depth":3},{"value":"Run the script manually","id":"run-the-script-manually","depth":2},{"value":"Mac / Linux","id":"mac--linux","depth":3},{"value":"Windows","id":"windows","depth":3},{"value":"Run the script automatically on login (optional)","id":"run-the-script-automatically-on-login-optional","depth":2},{"value":"Placeholders to replace","id":"placeholders-to-replace","depth":2}],"frontmatter":{"seo":{"title":"Auto-Refresh Script for Celonis Access Tokens"}},"lastModified":"2026-08-27T16:35:27.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/mcp-server-asset/troubleshooting/claude-refresh-token-script","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}