Agents and MCP
How an AI agent makes a Munim Billing account, signs a person in with an emailed code, and sets everything up through MCP or REST.
What an agent can do
Claude Code, Cursor, or any agent that speaks MCP or HTTP can set Munim Billing up end to end: make an account, name the business, add products and prices, make checkouts, add webhooks, connect App Store and Google Play apps, and sync billing data into the app’s own database. Every MCP tool is the same call as a REST endpoint, so the two never drift.
A few things stay with people, on purpose:
- Claiming a sandbox and signing in take a code emailed to the person.
- Where payouts go: the account owner connects a bank in the dashboard. No tool changes it.
- Making store keys (App Store Connect, Google Cloud) and the one Play Console setting Google has no API for. The store app’s
setup.next_stepssays exactly what. - Refunds and cancellations in live mode: agents are told to confirm with the person first.
Make a sandbox account
On the test API, one call with no key makes a new test account and returns its secret key. Use it when the person doesn’t have an account yet, or to prototype.
curl -X POST https://billing-sandbox-api.munimtech.com/v1/sandbox \
-H "Content-Type: application/json" \
-d '{"name": "Acme Notes"}'{
"object": "sandbox",
"api_key": "mb_test_sk_…",
"claim_url": "https://billing-sandbox-api.munimtech.com/claim/mbc_…",
"expires_at": 1767139200000,
"api_base": "https://billing-sandbox-api.munimtech.com",
"mcp_url": "https://billing-sandbox-api.munimtech.com/mcp",
"account": { "object": "account", "id": "sel_…", "mode": "test", "name": "Acme Notes", "setup": { "complete": false, "next_step": "claim", "steps": [ … ] } },
"next_steps": [ "Save api_key (shown once) …", "Give the person you're working for the claim_url …", … ]
}The key is shown once. Save it where the app’s server reads secrets (MUNIM_BILLING_SECRET_KEY). Sandboxes are rate-limited per caller, and one that nobody claims expires after 30 days.
Hand the sandbox to a person
Give the person the claim_url. They enter their email, type the code we send, and the account is theirs: it shows up in the dashboard and stops expiring. The agent’s key keeps working.
The agent can also do it in the conversation:
| Step | REST | MCP tool |
|---|---|---|
| Email the person a code | POST /v1/account/claim { email } | claim_sandbox |
| Check the code | POST /v1/account/claim/verify { email, code } | verify_claim |
| A fresh link (older ones stop working) | POST /v1/account/claim_link | get_claim_link |
Claiming fails if the email already has a Munim Billing account. Then sign in to that account instead.
Sign a person in by code
To work on someone’s existing account, or to get a live key, sign them in with their email. An account is made if they don’t have one. On the live API the response has a live key and a test key.
# 1. Email the person a code
curl -X POST https://billing-api.munimtech.com/v1/auth/start \
-H "Content-Type: application/json" \
-d '{"email": "[email protected]"}'
# 2. Ask them for it, then trade it for a key
curl -X POST https://billing-api.munimtech.com/v1/auth/verify \
-H "Content-Type: application/json" \
-d '{"email": "[email protected]", "code": "123456", "key_name": "Claude Code on acme-web"}'{
"object": "sign_in",
"role": "owner",
"api_key": "mb_live_sk_…",
"api_key_id": "key_…",
"test_api_key": "mb_test_sk_…",
"api_base": "https://billing-api.munimtech.com",
"mcp_url": "https://billing-api.munimtech.com/mcp",
"account": { "object": "account", "id": "sel_…", "mode": "live", "setup": { … }, … }
}If the person belongs to several accounts, pass account (sel_…) to pick one; the default is the one they used last. Team members with view-only access can’t get keys.
Follow the setup checklist
GET /v1/account (MCP: get_account) returns the account and setup.steps: what’s done, what’s next, and which endpoint or tool does it. Steps a person has to do carry a human note instead. Call it first, and again after each step.
curl https://billing-sandbox-api.munimtech.com/v1/account \
-H "Authorization: Bearer mb_test_sk_…"{
"object": "account",
"id": "sel_…",
"mode": "test",
"name": "Acme Notes",
"support_email": null,
"fee": { "bps": 500, "fixed": 50 },
"sandbox": { "claimed": false, "expires_at": 1767139200000 },
"payouts": { "ready": false, "method": null, "stripe_status": null, "paypal_email": null },
"setup": {
"complete": false,
"next_step": "catalog",
"steps": [
{
"id": "catalog",
"title": "Create a product and a price for it",
"done": false,
"required": true,
"api": "POST /v1/products { name } then POST /v1/prices { product_id, unit_amount, currency: 'usd', type, interval? }",
"mcp_tool": "create_product, then create_price",
"human": null
},
…
]
},
"dashboard_url": "https://dashboard.billing.munimtech.com",
…
}The steps are: claim (sandboxes), profile, catalog, webhooks, test_purchase, go_live and payouts.
Set up the MCP server
The server speaks Streamable HTTP at /mcp on both APIs. It works with no key: the create_sandbox or sign_in tools make one and bind it to the MCP session, so the other tools work right away without editing any config.
# Sandbox (test mode, no real money)
claude mcp add --transport http munim-billing https://billing-sandbox-api.munimtech.com/mcp
# Live
claude mcp add --transport http munim-billing https://billing-api.munimtech.com/mcp{
"mcpServers": {
"munim-billing": { "url": "https://billing-sandbox-api.munimtech.com/mcp" }
}
}Already have a key? Send it as a header, and the session uses that account:
{
"mcpServers": {
"munim-billing": {
"url": "https://billing-api.munimtech.com/mcp",
"headers": { "Authorization": "Bearer mb_live_sk_…" }
}
}
}Then ask the agent something like “Set up Munim Billing for this app”. It starts with get_account and reads get_integration_guide before writing code. Every tool is listed in the MCP tool reference.
Docs for agents
Each API serves a plain-text summary written for agents: every endpoint, the MCP setup, and what stays with people.
- Sandbox: https://billing-sandbox-api.munimtech.com/llms.txt
- Live: https://billing-api.munimtech.com/llms.txt
A person can see and change everything an agent did in the dashboard.