Use OAuth to connect
Use an OAuth server-to-server access token to connect programmatically to the Adobe Analytics or Customer Journey Analytics MCP servers. This guide outlines the requirements and walks through the connection workflow.
Requirements
Before connecting, you need an Adobe Developer Console project with OAuth server-to-server credentials and an IMS access token generated using the client_credentials grant type.
Each request to the MCP server requires the following headers:
Authorizationx-gw-ims-org-idx-api-keyx-global-company-idSend these headers to the endpoint for your product:
- Customer Journey Analytics:
https://mcp-gateway.adobe.io/cja/mcp - Adobe Analytics:
https://mcp-gateway.adobe.io/aa/mcp
Connect to the MCP server
Set the required headers and open a connection using the streamable-http transport. The following pseudocode demonstrates the workflow:
# Configuration
MCP_URL = "https://mcp-gateway.adobe.io/cja/mcp" # or /aa/mcp for Adobe Analytics
ORG_ID = "<IMS_ORGANIZATION_ID>"
CLIENT_ID = "<CLIENT_ID>"
# Set required headers
headers = {
"Authorization": "Bearer <ACCESS_TOKEN>",
"x-gw-ims-org-id": ORG_ID,
"x-api-key": CLIENT_ID
}
# For Adobe Analytics, also include:
# headers["x-global-company-id"] = "<GLOBAL_COMPANY_ID>"
# Open an MCP client connection using streamable-http
client = MCPClient(
transport = "streamable-http",
url = MCP_URL,
headers = headers
)
# Interact with the server
client.ping()
tools = client.tools.list()
result = client.tools.call("tool_name", {"param": "value"})
Token refresh
Access tokens expire after the duration specified in the expires_in field of the token response. To maintain an active connection:
- Cache the access token and track its expiration time.
- Refresh the token before it expires to avoid interruptions.
- If you receive a
401 Unauthorizedresponse, request a new token, update your headers, reconnect, and retry the request.
See the token generation guide for details on requesting and refreshing access tokens.