Connect an agent
To let an agent pay for services, it needs access to your wallet. There are three ways, depending on the agent. All of them are scoped: an agent can read balances and pay for services and approved payees, but it can never approve a new recipient or raise your spending limit (those need a browser login).
1. MCP connector with OAuth (Claude.ai, ChatGPT)
Chat clients that support MCP connectors use OAuth 2.1, so there are no codes to copy.
- In the client, add a custom connector pointing at the XDC AI MCP server:
https://api.xdcai.tech/mcp. - The client discovers our OAuth server automatically (at
https://xdcai.tech/.well-known/oauth-authorization-server), registers itself, and opens a browser tab. - Log in with your email and approve the request (scope: view your address and balances, and pay for services).
- The client receives a token and can now pay on your behalf, within your spend caps.
No client secret is involved; the flow uses PKCE. You can revoke access by removing the connector in the client.
2. CLI login link (Claude Code, Cursor, Codex, shell agents)
Shell-based agents use the xdcai CLI. Logging in opens a link you approve in the browser - the CLI then holds a session; you never paste a code.
npx xdcai@latest login
# Opens (or prints) a link like https://xdcai.tech/connect?code=...
# Log in with your email in the browser; the CLI finishes automatically.
npx xdcai@latest call GET "https://api.xdcai.tech/x402/connect/<serviceId>/<path>"
npx xdcai@latest wallet balance
The login link expires in 10 minutes and is single-use. Under the hood the CLI starts a pairing, you complete it in the browser, and the CLI polls until it receives a 24-hour session token (auto-refreshed for 90 days).
3. API key (headless / custom clients)
For agents that cannot open a browser (some custom MCP clients, scripts, or headless runners), mint an API key.
- Go to xdcai.tech/account and open the API keys section (under "Add wallet to agent").
- Click generate, optionally name it. The key is shown once - copy it now. It starts with
xdcai_. - Give it to the client as a bearer token:
Authorization: Bearer xdcai_your_key_here
The key can read your wallet and pay for services and approved payees. It cannot add payees or change limits (those are browser-only, so a leaked key can never widen its own access). Revoke a key any time from the same page; it stops working immediately. Keys are stored only as a hash - we cannot show a key again after it is created.
Which should I use?
| Agent | Use |
|---|---|
| Claude.ai, ChatGPT (MCP) | OAuth connector (api.xdcai.tech/mcp) |
| Claude Code, Cursor, Codex, shell | npx xdcai login |
| Headless / custom client | API key (xdcai_...) |
Whatever you choose, set a spending limit first so the agent has a hard, on-chain ceiling.