Skip to main content
Glama
dan1d

mercadolibre-mcp

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
NameRequiredDescriptionDefault
site_idNoSite ID (default: MLA)

Implementation Reference

  • 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)}`);
    }
  • 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;
    }
  • 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 };
        }
      },
    );
  • 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),

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