@ar-agents/mercadolibre · v0.4.3 · independent · MELI-unaffiliated
Mercado Libre
Agent Toolkit.
Built on Vercel.
The typed TypeScript SDK Mercado Libre stopped shipping when they archived mercadolibre/nodejs-sdk in February 2022 — rebuilt for the AI SDK era. 14 drop-in tools, 9 domains, OAuth coalescing, /myfeeds replay, HITL gates on irreversible ops, agentic-commerce feed generator.
Live demoLIVE
A real agent (claude-sonnet-4-6) running the 14 tools against a mocked MELI backend. Try a preset prompt or write your own.
Quickstart
Three lines and an LLM is driving Mercado Libre. The 14 tools come pre-typed; the agent never sees a thrown exception — every result is a discriminated union.
pnpm add @ar-agents/mercadolibre ai zod
import { Experimental_Agent as Agent, stepCountIs } from "ai";
import { anthropic } from "@ai-sdk/anthropic";
import { MeliClient } from "@ar-agents/mercadolibre";
import { meliTools } from "@ar-agents/mercadolibre/ai-sdk";
const client = new MeliClient({
auth: { kind: "bearer", accessToken: process.env.MELI_ACCESS_TOKEN! },
});
const agent = new Agent({
model: anthropic("claude-sonnet-4-6"),
tools: meliTools(client, { siteId: "MLA", sellerId: 12345 }),
stopWhen: stepCountIs(8),
});
const { text } = await agent.generate({
prompt: "Cuántas órdenes pagas tengo hoy y hay alguna pregunta sin responder?",
});Nine domains. Production-grade.
Every helper that follows the cookbook recipes — not an exhaustive endpoint dump. The point is to make the agent loop trivial, not to wrap REST calls.
get / multiget / create / update / pause / close / relist / search / scroll-iterate. Category predictor + technical-spec planner in one call (categorizeAndPlan).
List, answer (≤2000 chars), blacklist + heuristic spam classifier with explainable features (URL/phone/email + repetition + new-account + length).
Search, get, billing-info (CUIT/CUIL/DNI), packs (cart vs single). partitionByPack splits a feed into single-orders and cart-grouped buckets.
search, evidences, messages + the 2-day SLA defendClaim helper (sequential uploads + partial-failure surface, never half-defended).
Shipment + history + label blob (PDF / ZPL) routed through auth + retry + rate-limit + telemetry. Shipping options for any item.
Thermometer (5_green → 1_red), pre-evaluated alert severities, monitorReputation async-iterator with rethrow on permanent errors.
Candidates + opt-in. autoOptInPromotions enforces a per-item margin floor so you never give away the listing.
Typed parser + the /myfeeds 2-day replay nobody else implements. Dedup by (topic, resource, sent) so the live feed doesn't double-deliver.
meliTools(client, opts) returns a 14-tool ToolSet. Every tool returns { ok: true, ... } | { ok: false, code, message } — no thrown errors.
Eight blindspots this fills
Things every JS Mercado Libre integration gets wrong because the official archived SDK never modeled them.
- 01Single-use refresh-token racesTwo parallel refreshes invalidate both tokens. We coalesce per-userId via in-process AsyncLock + document the cross-process CAS pattern.
- 02Per-seller rate limitingToken bucket scoped to seller:<id>, default 24/s burst 60. Idle-bucket sweep every 256 acquires so multi-tenant hosts don't leak.
- 03/myfeeds 2-day replayWhen your service was down for 5 minutes, this is the only path that gets the events back. Auto-dedup on a live feed.
- 04Category prediction + tech specs in one callcategorizeAndPlan parallelizes the two endpoints. Save a round-trip for every CSV-import row.
- 05Claim defense in 2-day SLAdefendClaim does GET + sequential evidence uploads (parallel races MELI's one-shot semantics) + optional message. Stops on first failure.
- 06Reputation thermometer alertsevaluateReputationAlerts translates the level + rates into actionable severities. Critical/warning thresholds configurable.
- 07Promotion margin guardautoOptInPromotions never opts in below your floor — and skips candidates where MELI didn't suggest a discount.
- 08Heuristic spam classifierExplainable features (no LLM dependency). Pair the borderline label with an LLM second-pass before auto-answering.
Built for production from day one.
Every line you'd write yourself in your second integration is already there.
Two strategic moves shipped in v0.4.0v0.4
Beyond making MELI agent-friendly: making it agent-native commerce infrastructure.
Performance
Numbers from the bench suite (`pnpm bench`). Run them yourself to verify.
Plug it into Claude Desktop, Cursor, or Codeium
@ar-agents/mcp@0.9.0 bundles every package — including this one — into a single MCP server. One install, one config, all 14 MELI tools available to your favorite IDE agent.
{
"mcpServers": {
"ar-agents": {
"command": "npx",
"args": ["-y", "@ar-agents/mcp"],
"env": {
"MELI_ACCESS_TOKEN": "APP_USR-...",
"MELI_SELLER_ID": "12345",
"MELI_SITE_ID": "MLA"
}
}
}
}