Skip to main content
Glama

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
NameRequiredDescriptionDefault
payment_idYes

Implementation Reference

  • 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)}`);
    }
  • GetPaymentParams interface defines the input type for the get_payment tool, requiring a payment_id string parameter.
    export interface GetPaymentParams {
      payment_id: string;
    }
  • 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;
  • 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 };
        }
      },
    );
  • 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),

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/dan1d/cobroya'

If you have feedback or need assistance with the MCP directory API, please join our Discord server