get_categories
Get all top-level categories for a MercadoLibre site. Specify a site ID to retrieve structured category listings for navigation or filtering.
Instructions
List all top-level categories for a MercadoLibre site.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| site_id | No | Site ID (default: MLA) |
Implementation Reference
- src/actions.ts:41-47 (handler)The actual handler/implementation of get_categories. Calls the MercadoLibre API to list all top-level categories for a given site (defaults to MLA).
export async function getCategories( client: MercadoLibreClient, params?: GetCategoriesParams ): Promise<unknown> { const siteId = params?.site_id ?? "MLA"; return client.get(`/sites/${encodeURIComponent(siteId)}/categories`); } - src/schemas.ts:19-21 (schema)TypeScript interface for the input parameters of get_categories. Contains an optional site_id field.
export interface GetCategoriesParams { site_id?: string; } - src/mcp-server.ts:70-85 (registration)MCP server registration of the 'get_categories' tool with description and Zod schema. This is where the tool is exposed to MCP clients.
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 }; } }, ); - src/index.ts:31-31 (helper)Helper/bridge function that wires the registered tool name (snake_case) to the actual handler (camelCase) with a bound client.
get_categories: (params?: GetCategoriesParams) => getCategories(client, params),