get_category
Retrieve category details including name, hierarchical path from root, and list of subcategories for a given category ID.
Instructions
Get category details including name, path from root, and children categories.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| category_id | Yes | Category ID (e.g. MLA1055) |
Implementation Reference
- src/actions.ts:49-54 (handler)The actual handler function for get_category. Makes a GET request to /categories/{category_id} via the MercadoLibreClient.
export async function getCategory( client: MercadoLibreClient, params: GetCategoryParams ): Promise<unknown> { return client.get(`/categories/${encodeURIComponent(params.category_id)}`); } - src/schemas.ts:23-25 (schema)Input parameter type definition for get_category. Defines the required category_id string field.
export interface GetCategoryParams { category_id: string; } - src/mcp-server.ts:87-102 (registration)MCP server registration of the 'get_category' tool with Zod schema for category_id and a handler that calls tools.get_category.
server.tool( "get_category", "Get category details including name, path from root, and children categories.", { category_id: z.string().describe("Category ID (e.g. MLA1055)"), }, async (params) => { try { const result = await tools.get_category(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:23-38 (helper)Tool factory that wires get_category to the getCategory action with the client bound. Also re-exports getCategory and GetCategoryParams.
export function createMercadoLibreTools(accessToken?: string) { const client = new MercadoLibreClient(accessToken); return { tools: { search_items: (params: SearchItemsParams) => searchItems(client, params), get_item: (params: GetItemParams) => getItem(client, params), get_item_description: (params: GetItemDescriptionParams) => getItemDescription(client, params), get_categories: (params?: GetCategoriesParams) => getCategories(client, params), get_category: (params: GetCategoryParams) => getCategory(client, params), get_seller_info: (params: GetSellerInfoParams) => getSellerInfo(client, params), get_trends: (params?: GetTrendsParams) => getTrends(client, params), get_currency_conversion: (params: GetCurrencyConversionParams) => getCurrencyConversion(client, params), }, }; }