Connect agents with MCP
Bring Bagseven access and bounded payment tools into your assistant.
Start the MCP service
Run the platform first. Set BAGSEVEN_MCP_WORKER to the intended worker identity, then start the MCP service separately:
corepack pnpm mcp:localThe local HTTP endpoint is http://localhost:4009/mcp. Tool calls are forwarded to the authenticated daemon. account credentials stay with the human.
Connect a remote client
- 1
Expose the existing MCP port over HTTPS
For local development, tunnel port 4009 with ngrok. A remote assistant cannot reach your localhost directly.
- 2
Configure the public origin
Set BAGSEVEN_MCP_PUBLIC_URL to the HTTPS origin and MCP_OAUTH_REQUIRED=true. Restart MCP after changing these settings.
- 3
Add the MCP endpoint
Enter the HTTPS origin followed by /mcp in your client. Choose OAuth and complete email-code and wallet-signature consent.
- 4
Discover and test tools
Ask for available entitlements. Use paid_run for prepaid service credits. Use payment tools only when authorizing new spending.
ngrok http 4009
# .env — use your tunnel origin, without /mcp here
BAGSEVEN_MCP_PUBLIC_URL=https://your-tunnel.ngrok-free.dev
MCP_OAUTH_REQUIRED=trueCommon tool groups
| Goal | Tools |
|---|---|
| Inspect prepaid access | grant_status, check_entitlement |
| Use prepaid credits | paid_run, consume_entitlement |
| Inspect registered agents | list_agents, get_agent |
| Manage permissions | list_mandates, get_mandate, prepare_mandate, create_mandate |
| Request a new payment | bagseven_fetch |
| Understand a refusal | explain_denial |
{
"feature": "ocr",
"amount": "1",
"idempotency_key": "document-job-123"
}The JSON above is an example paid_run input. A grant_id is optional; the service can select an eligible living grant. Credit units are not USDC.
Sessions and reconnects
OAuth credentials and consent attempts persist in PostgreSQL, with single-use code and rotating refresh exchanges. HTTP transports are created per request; ordinary restarts do not erase account consent. An upgrade may still require client reinitialization. If your tunnel hostname changes, update the public origin and client endpoint. OAuth login does not itself create or fund a spending mandate.