# marcosnahuel/mercadolibre-mcp architecture

> Architecture diagram of the GitHub repository marcosnahuel/mercadolibre-mcp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/marcosnahuel/mercadolibre-mcp
- Repository: https://github.com/marcosnahuel/mercadolibre-mcp

## Overview

This is a Mercado Libre MCP server for seller operations, with a proxy to Mercado Libre’s official MCP and TRAID knowledge tools. The main workflow is an MCP client invoking a registered seller tool, which calls the authenticated Mercado Libre API client and returns formatted results; some tools also write changes back. Authentication supports direct, auto-refresh, and Supabase-backed tokens. The README documents broader capabilities, but only sampled excerpts and SOURCE INDEX references support the relationships shown; unsampled flows are not expanded.

Main entry points: [`src/index.ts`](https://github.com/marcosnahuel/mercadolibre-mcp/blob/main/src/index.ts) (Server and tool routing), [`src/client.ts`](https://github.com/marcosnahuel/mercadolibre-mcp/blob/main/src/client.ts) (Mercado Libre API client), [`src/auth.ts`](https://github.com/marcosnahuel/mercadolibre-mcp/blob/main/src/auth.ts) (OAuth token selection), [`src/layers/traid/index.ts`](https://github.com/marcosnahuel/mercadolibre-mcp/blob/main/src/layers/traid/index.ts) (TRAID tool registration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["MCP runtime"]
  node_server["Server and tool routing<br/>[index.ts]"]
  node_guard["Tool safety gate<br/>[tool-guard.ts]"]
end

subgraph group_seller["Seller operations"]
  node_seller_catalog["Products and categories"]
  node_seller_orders["Orders<br/>[orders.ts]"]
  node_seller_pricing["Pricing and history"]
  node_seller_stock["Stock and risk"]
  node_seller_questions["Questions and answers<br/>[questions.ts]"]
  node_seller_insights["Metrics and reputation"]
  node_seller_ads_competitors["Ads and competitors"]
end

subgraph group_authapi["Authentication and API"]
  node_ml_client["Mercado Libre API client<br/>[client.ts]"]
  node_auth["OAuth token selection<br/>[auth.ts]"]
  node_token_store[("Supabase token store<br/>[token-store.ts]")]
  node_types["Shared domain types<br/>[types.ts]"]
end

subgraph group_knowledge["TRAID knowledge"]
  node_traid_layer["TRAID tool registration<br/>[index.ts]"]
  node_feature_lookup["Feature lookup<br/>[feature-lookup.ts]"]
  node_client_context["Client context<br/>[client-context.ts]"]
  node_knowledge_loader["Knowledge loading and search<br/>[loader.ts]"]
end

subgraph group_integrations["External integrations"]
  node_official_proxy["Official MCP proxy<br/>[upstream-proxy.ts]"]
  node_ml_api["Mercado Libre API"]
  node_supabase[("Supabase")]
  node_knowledge_files["Configured knowledge files"]
  node_official_mcp["Official Mercado Libre MCP"]
end

node_mcp_client(("MCP client"))

node_mcp_client -->|"invokes tools"| node_server
node_server -->|"wraps registration"| node_guard
node_server -->|"registers tools"| node_seller_catalog
node_server -->|"registers tools"| node_seller_orders
node_server -->|"registers tools"| node_seller_pricing
node_server -->|"registers tools"| node_seller_stock
node_server -->|"registers tools"| node_seller_questions
node_server -->|"registers tools"| node_seller_insights
node_server -->|"registers tools"| node_seller_ads_competitors
node_seller_catalog -->|"calls API"| node_ml_client
node_seller_orders -->|"calls API"| node_ml_client
node_seller_pricing -->|"calls API"| node_ml_client
node_seller_stock -->|"calls API"| node_ml_client
node_seller_questions -->|"calls API"| node_ml_client
node_seller_insights -->|"calls API"| node_ml_client
node_seller_ads_competitors -->|"calls API"| node_ml_client
node_ml_client -->|"gets access token"| node_auth
node_auth -->|"reads and refreshes"| node_token_store
node_auth -->|"uses token backend"| node_supabase
node_ml_client -->|"sends authenticated requests"| node_ml_api
node_server -->|"registers knowledge tools"| node_traid_layer
node_traid_layer -->|"registers"| node_feature_lookup
node_traid_layer -->|"registers"| node_client_context
node_feature_lookup -->|"searches features"| node_knowledge_loader
node_client_context -->|"loads client data"| node_knowledge_loader
node_knowledge_loader -->|"loads snapshot"| node_knowledge_files
node_server -->|"registers proxy"| node_official_proxy
node_official_proxy -->|"proxies tools"| node_official_mcp

click node_server "https://github.com/marcosnahuel/mercadolibre-mcp/blob/main/src/index.ts"
click node_guard "https://github.com/marcosnahuel/mercadolibre-mcp/blob/main/src/tool-guard.ts"
click node_seller_catalog "https://github.com/marcosnahuel/mercadolibre-mcp/tree/main/src/tools"
click node_seller_orders "https://github.com/marcosnahuel/mercadolibre-mcp/blob/main/src/tools/orders.ts"
click node_seller_pricing "https://github.com/marcosnahuel/mercadolibre-mcp/tree/main/src/tools"
click node_seller_stock "https://github.com/marcosnahuel/mercadolibre-mcp/tree/main/src/tools"
click node_seller_questions "https://github.com/marcosnahuel/mercadolibre-mcp/blob/main/src/tools/questions.ts"
click node_seller_insights "https://github.com/marcosnahuel/mercadolibre-mcp/tree/main/src/tools"
click node_seller_ads_competitors "https://github.com/marcosnahuel/mercadolibre-mcp/tree/main/src/tools"
click node_ml_client "https://github.com/marcosnahuel/mercadolibre-mcp/blob/main/src/client.ts"
click node_auth "https://github.com/marcosnahuel/mercadolibre-mcp/blob/main/src/auth.ts"
click node_token_store "https://github.com/marcosnahuel/mercadolibre-mcp/blob/main/src/token-store.ts"
click node_types "https://github.com/marcosnahuel/mercadolibre-mcp/blob/main/src/types.ts"
click node_traid_layer "https://github.com/marcosnahuel/mercadolibre-mcp/blob/main/src/layers/traid/index.ts"
click node_feature_lookup "https://github.com/marcosnahuel/mercadolibre-mcp/blob/main/src/layers/traid/feature-lookup.ts"
click node_client_context "https://github.com/marcosnahuel/mercadolibre-mcp/blob/main/src/layers/traid/client-context.ts"
click node_knowledge_loader "https://github.com/marcosnahuel/mercadolibre-mcp/blob/main/src/knowledge/loader.ts"
click node_official_proxy "https://github.com/marcosnahuel/mercadolibre-mcp/blob/main/src/upstream-proxy.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_server,node_guard,node_mcp_client toneBlue
class node_seller_catalog,node_seller_orders,node_seller_pricing,node_seller_stock,node_seller_questions,node_seller_insights,node_seller_ads_competitors toneAmber
class node_ml_client,node_auth,node_token_store,node_types toneMint
class node_traid_layer,node_feature_lookup,node_client_context,node_knowledge_loader toneRose
class node_official_proxy,node_ml_api,node_supabase,node_knowledge_files,node_official_mcp toneIndigo
```

## Components

### MCP runtime

- [Server and tool routing](https://github.com/marcosnahuel/mercadolibre-mcp/blob/main/src/index.ts): `src/index.ts`
- [Tool safety gate](https://github.com/marcosnahuel/mercadolibre-mcp/blob/main/src/tool-guard.ts): `src/tool-guard.ts`

### Seller operations

- [Products and categories](https://github.com/marcosnahuel/mercadolibre-mcp/tree/main/src/tools): `src/tools`
- [Orders](https://github.com/marcosnahuel/mercadolibre-mcp/blob/main/src/tools/orders.ts): `src/tools/orders.ts`
- [Pricing and history](https://github.com/marcosnahuel/mercadolibre-mcp/tree/main/src/tools): `src/tools`
- [Stock and risk](https://github.com/marcosnahuel/mercadolibre-mcp/tree/main/src/tools): `src/tools`
- [Questions and answers](https://github.com/marcosnahuel/mercadolibre-mcp/blob/main/src/tools/questions.ts): `src/tools/questions.ts`
- [Metrics and reputation](https://github.com/marcosnahuel/mercadolibre-mcp/tree/main/src/tools): `src/tools`
- [Ads and competitors](https://github.com/marcosnahuel/mercadolibre-mcp/tree/main/src/tools): `src/tools`

### Authentication and API

- [Mercado Libre API client](https://github.com/marcosnahuel/mercadolibre-mcp/blob/main/src/client.ts): `src/client.ts`
- [OAuth token selection](https://github.com/marcosnahuel/mercadolibre-mcp/blob/main/src/auth.ts): `src/auth.ts`
- [Supabase token store](https://github.com/marcosnahuel/mercadolibre-mcp/blob/main/src/token-store.ts): `src/token-store.ts`
- [Shared domain types](https://github.com/marcosnahuel/mercadolibre-mcp/blob/main/src/types.ts): `src/types.ts`

### TRAID knowledge

- [TRAID tool registration](https://github.com/marcosnahuel/mercadolibre-mcp/blob/main/src/layers/traid/index.ts): `src/layers/traid/index.ts`
- [Feature lookup](https://github.com/marcosnahuel/mercadolibre-mcp/blob/main/src/layers/traid/feature-lookup.ts): `src/layers/traid/feature-lookup.ts`
- [Client context](https://github.com/marcosnahuel/mercadolibre-mcp/blob/main/src/layers/traid/client-context.ts): `src/layers/traid/client-context.ts`
- [Knowledge loading and search](https://github.com/marcosnahuel/mercadolibre-mcp/blob/main/src/knowledge/loader.ts): `src/knowledge/loader.ts`

### External integrations

- [Official MCP proxy](https://github.com/marcosnahuel/mercadolibre-mcp/blob/main/src/upstream-proxy.ts): `src/upstream-proxy.ts`
- **Mercado Libre API**
- **Supabase**
- **Configured knowledge files**
- **Official Mercado Libre MCP**

### Other components

- **MCP client**

## Connections

- MCP client → Server and tool routing: invokes tools (evidence: `README.md`)
- Server and tool routing → Tool safety gate: wraps registration (evidence: `src/index.ts`)
- Server and tool routing → Products and categories: registers tools (evidence: `src/index.ts`)
- Server and tool routing → Orders: registers tools (evidence: `src/index.ts`)
- Server and tool routing → Pricing and history: registers tools (evidence: `src/index.ts`)
- Server and tool routing → Stock and risk: registers tools (evidence: `src/index.ts`)
- Server and tool routing → Questions and answers: registers tools (evidence: `src/index.ts`)
- Server and tool routing → Metrics and reputation: registers tools (evidence: `src/index.ts`)
- Server and tool routing → Ads and competitors: registers tools (evidence: `src/index.ts`)
- Products and categories → Mercado Libre API client: calls API (evidence: `src/tools/categories.ts`)
- Orders → Mercado Libre API client: calls API (evidence: `src/tools/orders.ts`)
- Pricing and history → Mercado Libre API client: calls API (evidence: `src/tools/pricing.ts`)
- Stock and risk → Mercado Libre API client: calls API (evidence: `src/tools/stockout_risk.ts`)
- Questions and answers → Mercado Libre API client: calls API (evidence: `src/tools/questions.ts`)
- Metrics and reputation → Mercado Libre API client: calls API (evidence: `src/tools/metrics.ts`)
- Ads and competitors → Mercado Libre API client: calls API (evidence: `src/tools/ads.ts`)
- Mercado Libre API client → OAuth token selection: gets access token (evidence: `src/client.ts`)
- OAuth token selection → Supabase token store: reads and refreshes (evidence: `src/auth.ts`)
- OAuth token selection → Supabase: uses token backend (evidence: `README.md`)
- Mercado Libre API client → Mercado Libre API: sends authenticated requests (evidence: `src/client.ts`)
- Server and tool routing → TRAID tool registration: registers knowledge tools (evidence: `src/index.ts`)
- TRAID tool registration → Feature lookup: registers (evidence: `src/layers/traid/index.ts`)
- TRAID tool registration → Client context: registers (evidence: `src/layers/traid/index.ts`)
- Feature lookup → Knowledge loading and search: searches features (evidence: `src/layers/traid/feature-lookup.ts`)
- Client context → Knowledge loading and search: loads client data (evidence: `src/layers/traid/client-context.ts`)
- Knowledge loading and search → Configured knowledge files: loads snapshot (evidence: `src/knowledge/loader.ts`)
- Server and tool routing → Official MCP proxy: registers proxy (evidence: `src/index.ts`)
- Official MCP proxy → Official Mercado Libre MCP: proxies tools (evidence: `README.md`)
