Skip to main content
Glama
dan1d

mercadolibre-mcp

get_categories

Retrieve top-level product categories from MercadoLibre to organize searches, filter listings, and navigate the marketplace efficiently.

Instructions

List all top-level categories for a MercadoLibre site.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
site_idNoSite ID (default: MLA)

Implementation Reference

  • The core handler function that executes the get_categories tool logic. It takes an optional GetCategoriesParams object, defaults to site_id 'MLA' (Argentina), and makes an API call to fetch categories for the specified MercadoLibre site.
    export async function getCategories(
      client: MercadoLibreClient,
      params?: GetCategoriesParams
    ): Promise<unknown> {
      const siteId = params?.site_id ?? "MLA";
      return client.get(`/sites/${encodeURIComponent(siteId)}/categories`);
    }
  • TypeScript interface defining the input parameters for get_categories. It accepts an optional site_id parameter to specify which MercadoLibre site to query (defaults to MLA for Argentina).
    export interface GetCategoriesParams {
      site_id?: string;
    }
  • MCP server registration of the get_categories tool. Defines the tool name, description, Zod schema for validation (site_id optional), and the async handler that calls tools.get_categories() and formats the response.
    server.tool(
      "get_categories",
      "List all top-level categories for a MercadoLibre site.",
      {
        site_id: z.string().optional().describe("Site ID (default: MLA)"),
      },
      async (params) => {
        try {
          const result = await tools.get_categories(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 };
        }
      },
    );
  • Wrapper function that creates the get_categories tool interface, binding the MercadoLibre client instance to the getCategories handler function.
    get_categories: (params?: GetCategoriesParams) => getCategories(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/mercadolibre-mcp'

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