Agentic Frameworks
Integrate your backend applications and AI agents with Madgicx MCP using OAuth 2.0 client credentials.
Agentic Frameworks
Agentic frameworks are server-side applications that can securely store credentials. Unlike browser-based OAuth flows, these integrations authenticate directly using a Client ID and Client Secret — no user interaction required after initial setup.
This is ideal for backend services, automated pipelines, and AI agent frameworks that need programmatic access to Madgicx MCP.
Two MCP servers, one set of credentials
Both Madgicx MCP servers (Facebook Ads and Google Ads) authorize against the same Madgicx OAuth provider. A single Client ID / Client Secret pair works for both — point your MCP client at one or both URLs.
Server URLs
| Server | URL |
|---|---|
| Facebook Ads MCP | https://mcp.madgicx.com/mcp |
| Google Ads MCP | https://mcp-google-ads.madgicx.com/mcp |
The framework guides on this page use MADGICX_MCP_URL for the Facebook Ads server by default. To target Google Ads, swap the URL — or run two MCP clients in parallel, one per server.
Getting Your Credentials
Open MCP Integration settings
Navigate to Workspace Settings → MCP Integration in your Madgicx dashboard.
Copy your Client ID
Your Client ID is displayed in the Credentials section. Use the copy button to copy it.
Generate a Client Secret
Click the rotate icon next to the Client ID to generate a new Client Secret. Copy and store it securely — it will only be shown once.
Store your secret securely
The client secret is only displayed once at creation time. Store it in a secrets manager or environment variable — never commit it to source control.
Rotating the Client Secret
You can rotate your client secret at any time from the MCP Integration settings:
- Click the rotate icon next to your Client ID
- Confirm the rotation in the dialog — this will invalidate your current secret immediately
- Copy and deploy the new secret to all services that use it
Secret rotation is immediate
Rotating the secret invalidates the previous one instantly. Any services using the old secret will need to be updated, or they will fail to authenticate.
Environment Variables
All framework integrations below use the same environment variables. Create a .env file or set them in your environment:
Token URL is shared
Note that MADGICX_TOKEN_URL is the same for both servers — https://app.madgicx.com/o/token/. Only the MCP endpoint URL differs.
To run agents against both MCP servers simultaneously, configure two MCP clients in your application using the same credentials but different URLs (see each framework guide for the multi-server pattern).
Auth Helper
All framework integrations use a shared MadgicxConfidentialClientAuth helper that handles the OAuth 2.0 client credentials flow, including automatic token refresh. Place this in your project as auth.py:
This class:
- Reads credentials from environment variables (or accepts them as constructor arguments)
- Automatically obtains tokens via the
client_credentialsgrant - Refreshes expired access tokens using the refresh token
- Falls back to a full re-authentication if the refresh token is also expired
- Is thread-safe for use in concurrent applications
- Works for both MCP servers — the same access token is accepted by Facebook Ads and Google Ads