get_payment
Retrieve detailed payment information including status, amount, and payer details by providing a payment ID. This tool enables verification and tracking of transaction data within the Mercado Pago payment platform.
Instructions
Retrieve a payment by its ID. Returns full payment details including status, amount, payer info.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| payment_id | Yes |
Implementation Reference
- src/actions.ts:49-57 (handler)The getPayment function is the main handler that retrieves payment details from Mercado Pago API. It validates the payment_id parameter and makes a GET request to /v1/payments/{payment_id} endpoint.
export async function getPayment( client: MercadoPagoClient, params: GetPaymentParams ): Promise<unknown> { if (!params.payment_id || typeof params.payment_id !== "string") { throw new Error("payment_id is required and must be a string"); } return client.get(`/v1/payments/${encodeURIComponent(params.payment_id)}`); } - src/schemas.ts:16-18 (schema)GetPaymentParams interface defines the input type for the get_payment tool, requiring a payment_id string parameter.
export interface GetPaymentParams { payment_id: string; } - src/schemas.ts:60-70 (schema)getPaymentSchema defines the MCP tool schema with name, description, and parameter validation for the get_payment tool.
export const getPaymentSchema = { name: "get_payment", description: "Retrieve a payment by its ID. Returns full payment details including status, amount, payer info.", parameters: { type: "object", required: ["payment_id"], properties: { payment_id: { type: "string", description: "The payment ID to look up" }, }, }, } as const; - src/mcp-server.ts:41-56 (registration)Registration of the get_payment tool with the MCP server, including Zod schema validation and the async handler that calls tools.get_payment().
server.tool( "get_payment", "Retrieve a payment by its ID. Returns full payment details including status, amount, payer info.", { payment_id: z.string(), }, async (params) => { try { const result = await tools.get_payment(params); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } catch (error) { const message = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: message }], isError: true }; } }, ); - src/index.ts:27-28 (helper)Tool mapping in createMercadoPagoTools that connects the get_payment tool name to the getPayment handler function with the client instance.
get_payment: (params: GetPaymentParams) => getPayment(client, params),