create_gateway
Create a payment gateway for your company by providing a global gateway ID and credential settings. Optionally add a display name, card types, or payment method.
Instructions
Create a company gateway. POST /gateways. Required: gblGatewayId, setting (credentials object). Optional: displayName, card (array of card type IDs), paymentMethod. Use list_global_gateways first to discover valid gblGatewayId and required setting keys (requiredFields / fieldDetails) for each gateway type (e.g. Stripe, Braintree); then build setting with those keys as field names and your credential values.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| gblGatewayId | Yes | Global gateway ID (required). Obtain from list_global_gateways; use the id as gblGatewayId. | |
| displayName | No | Display name for the gateway | |
| setting | Yes | Credentials object (required). Keys must match the gateway's requiredFields from list_global_gateways (e.g. publicKey, privateKey, merchantId, transactionKey). Use fieldDetails for human-readable labels. | |
| card | No | Array of card type IDs (optional) | |
| paymentMethod | No | Payment method (optional, may be required by API) |
Implementation Reference
- Handler function that validates args using Zod schema, constructs the request body, and calls the gateway service to create a gateway via POST /gateways.
async function handler(client: Client, args: Record<string, unknown> | undefined) { const parsed = schema.safeParse(args); if (!parsed.success) { return errorResult(parsed.error.errors.map((e) => e.message).join("; ")); } const body = { gblGatewayId: parsed.data.gblGatewayId, displayName: parsed.data.displayName, setting: parsed.data.setting, card: parsed.data.card, paymentMethod: parsed.data.paymentMethod, }; return handleToolCall(() => gatewayService.createGateway(client, body)); } - Zod validation schema and MCP ToolDefinition (name, description, inputSchema) for create_gateway. Defines required parameters: gblGatewayId, setting (credentials object), and optional: displayName, card, paymentMethod.
const settingSchema = z.record(z.union([z.string(), z.number(), z.boolean()])); const schema = z.object({ gblGatewayId: z.number().int().positive("gblGatewayId is required"), displayName: z.string().optional(), setting: settingSchema.refine((obj) => Object.keys(obj).length > 0, "setting must have at least one credential key"), card: z.array(z.number().int()).optional(), paymentMethod: z.string().optional(), }); const definition = { name: "create_gateway", description: "Create a company gateway. POST /gateways. Required: gblGatewayId, setting (credentials object). Optional: displayName, card (array of card type IDs), paymentMethod. Use list_global_gateways first to discover valid gblGatewayId and required setting keys (requiredFields / fieldDetails) for each gateway type (e.g. Stripe, Braintree); then build setting with those keys as field names and your credential values.", inputSchema: { type: "object" as const, properties: { gblGatewayId: { type: "number", description: "Global gateway ID (required). Obtain from list_global_gateways; use the id as gblGatewayId.", }, displayName: { type: "string", description: "Display name for the gateway" }, setting: { type: "object", description: "Credentials object (required). Keys must match the gateway's requiredFields from list_global_gateways (e.g. publicKey, privateKey, merchantId, transactionKey). Use fieldDetails for human-readable labels.", }, card: { type: "array", description: "Array of card type IDs (optional)", }, paymentMethod: { type: "string", description: "Payment method (optional, may be required by API)" }, }, required: ["gblGatewayId", "setting"], }, }; - src/tools/gateways/index.ts:17-29 (registration)Registration of createGatewayTool within the gateways tool collection. Called by the main tools/index.ts registry to include create_gateway in the tool list.
export function registerGatewayTools(): Tool[] { return [ listGlobalGatewaysTool, listGatewaysTool, getGatewayTool, getClientTokenTool, createSetupIntentTool, createGatewayTool, updateGatewayTool, deleteGatewayTool, testGatewayTool, ]; } - src/tools/index.ts:26-57 (registration)Central tool registry in src/tools/index.ts that spreads all registered tools including createGatewayTool via registerGatewayTools().
const tools: Tool[] = [ ...registerCustomerTools(), ...registerProductTools(), ...registerProductRatePlanTools(), ...registerProductRatePlanChargeTools(), ...registerSubscriptionTools(), ...registerInvoiceTools(), ...registerTransactionTools(), ...registerBillRunTools(), ...registerGatewayTools(), ...registerCurrencyTools(), ...registerIntegrationTools(), ...registerShippingTools(), ...registerFilterTools(), ...registerDocsTools(), ]; /** All tool definitions for tools/list */ export function getToolDefinitions(): ToolDefinition[] { return tools.map((t) => t.definition); } /** Execute a tool by name. Returns result or undefined if tool not found. */ export async function executeTool( name: string, args: Record<string, unknown> | undefined, client: RebilliaClient ): Promise<ToolResult | undefined> { const tool = tools.find((t) => t.definition.name === name); if (!tool) return undefined; return tool.handler(client, args); } - API service function that performs the actual HTTP POST /gateways call to create a company gateway.
export async function createGateway( client: Client, body: CreateGatewayBody ): Promise<unknown> { return client.post<unknown>("/gateways", body); }