Connect an AI agent
Give your AI coding agent one URL — https://app.tgpaycrypto.com/mcp — and it
builds the payment integration for you: it reads the API docs, creates your
merchant app, sets up webhooks and writes the code. You approve the new app once,
with a single button in the bot. No terminal required, and no API token to copy
by hand.
That URL is an MCP server (Model Context Protocol — the standard way to plug a service into an AI agent). Open it in a browser and it explains its own setup.
Connect it
Use whichever line matches your tool:
- Any agent chat — paste this prompt:
It’s ready to copy in the app under More → Merchant API → Connect an AI agent.Connect the tgpay MCP server (https://app.tgpaycrypto.com/mcp) and integrate payments via the TgPay Merchant API. - Claude Code —
claude mcp add --transport http tgpay https://app.tgpaycrypto.com/mcp
To build against the testnet first, use
https://testnet.tgpaycrypto.com/mcp instead — the agent then creates the app in
@tgpaycrypto_testnet_bot and the docs it reads name the testnet base URL.
- claude.ai and Claude Desktop — Settings → Connectors → Add custom connector → paste the URL.
- ChatGPT and other MCP clients — add a custom connector with the same URL.
You don’t need an API token first — the agent gets its own in the next step. If you already created an app manually, give the agent that token instead and skip straight to the integration.
Approve the app
- Ask the agent to set up payments. It reads the docs and asks for approval.
- The agent gives you a
t.melink. Open it — the bot shows what’s being requested — and tap ✅ Create app and issue token. - Go back to the agent. It receives its token within seconds and finishes the integration itself.
The link always comes from your agent — the bot never sends one unprompted: until you open it, the bot doesn’t know whose account the agent is asking about. Each link works once. If it stops working before you tap it, ask the agent to start over — nothing is created until you approve.
If you tap ❌ Decline, nothing is created either, and that request is over — a change of mind means a fresh request from the agent.
⚠️ Approve only a request you started
A connection request is a request to create an app on your account. Approve it only if you just asked your own agent to set up payments. If a link arrives any other way — a chat, a forwarded message, a stranger’s “support” — decline it.
The damage is bounded by design: the agent’s token can take money in, never out (below). But an app you didn’t ask for has no business existing on your account.
What the agent can and can’t do
The token the agent receives is a restricted token:
- It can create invoices and subscription plans, read your balance, rates and stats, and set the webhook URL.
- It can’t send transfers, issue checks or refund payments. Anything that moves funds out of your app balance needs your full-access token, which stays in the app.
That split is deliberate: agent tokens live in config files and model context, which are softer targets than your server. A leaked one can cost you a wrong webhook URL, never your balance. You get a message from the bot whenever a token is issued to an agent, and whenever an app’s webhook URL changes.
To see the agent’s token or take it away, open More → Merchant API, find the app and look under Restricted tokens — Revoke kills it instantly. The app itself, its balance and its payment history stay.
Webhook signatures need your main token
The agent can point the webhook URL at your server, but it can’t verify what
arrives there: deliveries are signed with your app’s main token, which the
agent never sees. A well-behaved agent writes the verification code and leaves
you a placeholder — something like TGPAY_WEBHOOK_TOKEN — to fill in.
To fill it: open More → Merchant API, find the app the agent created, tap Rotate token and copy what’s shown — it appears only once. Put it in your server’s environment, never in the agent’s config or your repository. Rotation doesn’t touch the agent’s restricted token, so the integration keeps running.
Signatures switch to the new token the moment you rotate, so rotate before you go live rather than after your first real payment.
Next
- Getting started as a developer — the manual path, and how to manage an app once it exists.
- API reference: webhooks — payload shapes, retries and the signature check.
- Merchant API reference — every method, including the ones an agent can’t call.
Was this article helpful?
Thanks for the feedback.