get_trends
Retrieve trending searches on MercadoLibre for specific countries to identify popular products and market demand.
Instructions
Get current trending searches on MercadoLibre for a specific site/country.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| site_id | No | Site ID (default: MLA) |
Implementation Reference
- src/actions.ts:63-69 (handler)The getTrends handler function that executes the tool logic. It takes a MercadoLibreClient and optional GetTrendsParams, defaults site_id to 'MLA', and makes an API call to the /trends/{site_id} endpoint.
export async function getTrends( client: MercadoLibreClient, params?: GetTrendsParams ): Promise<unknown> { const siteId = params?.site_id ?? "MLA"; return client.get(`/trends/${encodeURIComponent(siteId)}`); } - src/schemas.ts:31-33 (schema)The GetTrendsParams interface defining the input validation schema for the get_trends tool. It accepts an optional site_id parameter.
export interface GetTrendsParams { site_id?: string; } - src/mcp-server.ts:121-136 (registration)MCP server tool registration for get_trends. Registers the tool with Zod schema validation, error handling, and wraps the call to tools.get_trends with proper MCP response formatting.
server.tool( "get_trends", "Get current trending searches on MercadoLibre for a specific site/country.", { site_id: z.string().optional().describe("Site ID (default: MLA)"), }, async (params) => { try { const result = await tools.get_trends(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:34-34 (helper)Helper wrapper in createMercadoLibreTools that binds the MercadoLibreClient to the getTrends function, creating the get_trends tool object.
get_trends: (params?: GetTrendsParams) => getTrends(client, params),