deposit
Generate a Stripe checkout URL to deposit funds into your wallet for marketplace transactions. After payment, funds are credited automatically to enable service purchases.
Instructions
Generate a Stripe checkout URL to deposit funds into your wallet. Returns a URL that must be visited to complete the payment. After payment, funds are credited automatically.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| amountCents | Yes | Amount to deposit in cents (minimum $1.00 = 100) |
Implementation Reference
- src/tools/identity.ts:36-61 (handler)Main deposit tool registration and handler. Defines the tool with name 'deposit', description, input schema using zod validation (amountCents, minimum 100), and the handler logic that retrieves the agent ID, gets wallet info, validates wallet ID, and calls createDeposit to generate a Stripe checkout URL.
// deposit — Get a Stripe checkout URL to add funds server.tool( 'deposit', 'Generate a Stripe checkout URL to deposit funds into your wallet. Returns a URL that must be visited to complete the payment. After payment, funds are credited automatically.', { amountCents: z.number().min(100).describe('Amount to deposit in cents (minimum $1.00 = 100)'), }, { destructiveHint: true, idempotentHint: false, openWorldHint: true }, async (params) => { const agentId = await client.getAgentId(); const walletInfo = await client.getWallet(agentId); const walletId = walletInfo.id || walletInfo.walletId; if (!walletId) { return { content: [{ type: 'text' as const, text: 'Could not determine wallet ID. Check your profile.' }], isError: true, }; } const result = await client.createDeposit(walletId, params.amountCents); return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }], }; } ); - src/tools/identity.ts:40-42 (schema)Input validation schema for the deposit tool. Defines amountCents parameter as a number with minimum value of 100 (representing $1.00).
{ amountCents: z.number().min(100).describe('Amount to deposit in cents (minimum $1.00 = 100)'), }, - src/client.ts:100-105 (helper)API client method that makes the actual HTTP POST request to create a deposit. Calls the /policy-wallets/{walletId}/deposit endpoint with the amountCents in the request body.
async createDeposit(walletId: string, amountCents: number): Promise<any> { return this.request(`/policy-wallets/${walletId}/deposit`, { method: 'POST', body: { amountCents }, }); } - src/client.ts:30-57 (helper)Base HTTP request method used by createDeposit. Constructs the full URL with base path, handles query parameters, sets authorization headers, and makes the fetch request with proper method, headers, and body serialization.
private async request<T>(path: string, opts: RequestOptions = {}): Promise<T> { const { method = 'GET', body, params } = opts; let url = `${this.baseUrl}/v1${path}`; // Append query params if (params) { const searchParams = new URLSearchParams(); for (const [key, value] of Object.entries(params)) { if (value !== undefined && value !== '') { searchParams.set(key, String(value)); } } const qs = searchParams.toString(); if (qs) url += `?${qs}`; } const headers: Record<string, string> = { 'Authorization': `Bearer ${this.apiKey}`, 'Content-Type': 'application/json', 'X-Theagora-Source': 'mcp', }; const res = await fetch(url, { method, headers, body: body ? JSON.stringify(body) : undefined, }); - src/index.ts:25-25 (registration)Registration call that invokes registerIdentityTools to register all identity-related tools including the deposit tool.
registerIdentityTools(server, client);