# nlace-com/mcp-supermercados-cl architecture

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

- Interactive diagram: https://gitdiagram.com/nlace-com/mcp-supermercados-cl
- Repository: https://github.com/nlace-com/mcp-supermercados-cl

## Overview

1. **What this repo is**
   - A local **Model Context Protocol (MCP) server** for Chilean supermarkets.
   - It is designed to run on the user’s machine over **stdio**, not as a hosted web service.
   - The main architectural goal is to let an LLM ask for products, prices, comparisons, and cart/list operations while keeping sensitive session data on the user’s side.

2. **Top-level runtime shape**
   - `src/index.ts` is the entrypoint.
   - `src/server.ts` registers the MCP tools and prompts.
   - The process is a Node.js ≥ 20 application; the repo is built and tested with TypeScript.
   - Communication with the client is MCP-native, including progress notifications for long operations.

3. **Core domain layer**
   - `src/core/` holds the normalized business model and shared algorithms.
   - It contains types, error shaping, normalization, formatting, matching, comparison, cache, opportunity ranking, and list building.
   - This layer is where the repo enforces a unified product schema across all supermarket chains, including separate normal and member prices, unit-price normalization, and bundle handling.

4. **Adapter-per-chain architecture**
   - `src/adapters/` is the main boundary against external supermarket systems.
   - There is one adapter family per chain: **Cencosud/Jumbo/Santa Isabel**, **Unimarc**, **Tottus**, and **Lider**.
   - Adapters encapsulate site-specific scraping/API access, then translate results into the shared core schema so the rest of the system stays chain-agnostic.

5. **Cencosud is the most complex subsystem**
   - The Cencosud area is split into specialized files: browser/session/cart/lists/session orchestration plus the chain adapter itself.
   - This reflects the fact that Jumbo and Santa Isabel expose richer authenticated features: frequent purchases, saved lists, and cart operations.
   - The architecture intentionally separates public catalog search from session-bound flows that must run against the user’s logged-in browser state.

6. **Session handling and privacy boundary**
   - `src/adapters/session.ts` and the chain-specific session/browser helpers implement the “no credentials on server” model.
   - For authenticated features, the server emits a browser snippet or can optionally bridge through Playwright; the actual authenticated state remains in the user’s browser profile.
   - This is a major architectural boundary: public catalog requests can be server-side, but private account/cart operations are delegated to the user’s session.

7. **HTTP and anti-bot-aware access**
   - `src/http/client.ts` centralizes outbound HTTP behavior.
   - The client applies rate limits, retries/backoff, realistic user-agent behavior, and timeouts tuned per host type.
   - This matters because some chains use public search APIs, while others rely on SSR pages or anti-bot-sensitive endpoints; the repo intentionally paces requests to behave like a human client.

8. **Tools are the MCP surface area**
   - `src/tools/` contains one MCP tool per file, such as search, product detail, offers, list building, cart access, store comparison, and branch discovery.
   - The tools are thin orchestration layers: they parse inputs, call adapters/core services, and return normalized MCP responses.
   - Long-running tools emit progress updates, and some comparison flows return partial results rather than blocking everything on a single slow chain.

9. **Data flow for catalog and comparison**
   - A typical flow is: MCP tool → chain adapter → HTTP/browser/session boundary → raw chain response → core normalization/matching → tool response.
   - `search_products`, `get_product`, `get_offers`, and `compare_stores` all follow this pattern, but differ in which adapter and which source data they use.
   - `compare_stores` is especially important architecturally because it aggregates results from multiple adapters and must preserve pricing/unit-price consistency across chains.

10. **Data flow for “smart shopping” features**
   - `build_list` and `suggest_swaps` sit on top of the core matching and opportunities logic.
   - They combine user intent, frequent-purchase history, offer detection, and normalized unit-price comparisons to propose concrete product selections.
   - These features depend heavily on the domain layer rather than any one supermarket integration.

11. **Caching, limits, and resilience**
   - The core cache layer and the HTTP client work together to keep repeated lookups efficient and to reduce exposure to rate limits.
   - The architecture favors graceful degradation: when one chain fails, the system can still return partial results or status per adapter.
   - Environment variables tune timing and retry behavior, which is important because the repo interacts with heterogeneous external systems.

12. **Testing strategy and fixtures**
   - `tests/` contains both contract-style tests with recorded fixtures and opt-in live smoke tests.
   - Fixtures capture real responses from each chain so the adapters can be validated without hitting live sites during normal CI.
   - This test setup is part of the architecture: every adapter is isolated enough that a format change in one chain should not break the rest.

13. **Operations, documentation, and change tracking**
   - `.github/workflows/ci.yml` and `.github/workflows/smoke-live.yml` indicate continuous validation plus scheduled live checks.
   - The `docs/` folder records endpoint plans and captured behavior from specific dates, which suggests the external integrations are expected to drift and need ongoing re-documentation.
   - The repo is therefore a living integration layer, not a static library.

14. **How to draw the architecture**
   - At the center, place the MCP server and tool registry.
   - Surround it with a shared core domain layer.
   - On the outside, draw one adapter boundary per supermarket chain, with a special authenticated-session path for Cencosud-related features.
   - Add a shared HTTP client beneath the adapters, a browser/session bridge for private flows, and a separate test/fixture boundary that validates each chain integration independently.

Main entry points: [`src/server.ts`](https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/server.ts) (MCP server), [`src/http/client.ts`](https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/http/client.ts) (HTTP client), [`tests/adapters`](https://github.com/nlace-com/mcp-supermercados-cl/tree/main/tests/adapters) (Adapter tests), [`src/adapters/cencosud.ts`](https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/adapters/cencosud.ts) (Cencosud family)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["MCP runtime"]
  node_src_index(("Entry point<br/>bootstrap<br/>[index.ts]"))
  node_src_server["MCP server<br/>tool registry<br/>[server.ts]"]
  node_src_prompts["Prompts<br/>[prompts.ts]"]
end

subgraph group_core["Core domain"]
  node_core_types["Types<br/>domain model<br/>[types.ts]"]
  node_core_normalize["Normalize<br/>mapping<br/>[normalize.ts]"]
  node_core_match["Matching<br/>ranking<br/>[matching.ts]"]
  node_core_compare["Compare<br/>aggregation<br/>[compare.ts]"]
  node_core_list["List builder<br/>shopping flow<br/>[listBuilder.ts]"]
  node_core_offers["Opportunities<br/>recommendation<br/>[opportunities.ts]"]
  node_core_cache["Cache<br/>memoization<br/>[cache.ts]"]
end

subgraph group_adapters["Chain adapters"]
  node_http_client["HTTP client<br/>resilient client<br/>[client.ts]"]
  node_session_boundary["Session boundary<br/>privacy boundary<br/>[session.ts]"]
  node_playwright_bridge["Browser bridge"]
  node_cencosud_family["Cencosud family<br/>authenticated adapter<br/>[cencosud.ts]"]
  node_cencosud_session["Cencosud session<br/>session orchestration<br/>[cencosudSession.ts]"]
  node_cencosud_cart["Cencosud cart<br/>cart ops<br/>[cencosudCart.ts]"]
  node_cencosud_lists["Cencosud lists<br/>saved lists<br/>[cencosudLists.ts]"]
  node_unimarc_adapter["Unimarc<br/>chain adapter<br/>[unimarc.ts]"]
  node_tottus_adapter["Tottus<br/>chain adapter<br/>[tottus.ts]"]
  node_lider_adapter["Lider<br/>chain adapter<br/>[lider.ts]"]
end

subgraph group_tools["MCP tools"]
  node_tool_search["Search products<br/>mcp tool<br/>[searchProducts.ts]"]
  node_tool_product["Get product<br/>mcp tool<br/>[getProduct.ts]"]
  node_tool_offers["Get offers<br/>mcp tool<br/>[getOffers.ts]"]
  node_tool_compare["Compare stores<br/>mcp tool<br/>[compareStores.ts]"]
  node_tool_list["Build list<br/>mcp tool<br/>[buildList.ts]"]
  node_tool_swaps["Suggest swaps<br/>mcp tool<br/>[suggestSwaps.ts]"]
  node_tool_cart["Cart access<br/>mcp tool<br/>[cart.ts]"]
  node_tool_lists["Saved lists<br/>mcp tool<br/>[getSavedLists.ts]"]
  node_tool_freq["Frequent purchases<br/>mcp tool"]
  node_tool_branch["Discover branch<br/>mcp tool<br/>[discoverBranch.ts]"]
  node_tool_status["Adapter status<br/>mcp tool<br/>[adapterStatus.ts]"]
  node_tool_progress["Progress<br/>mcp tool<br/>[progress.ts]"]
end

subgraph group_tests["Tests & fixtures"]
  node_test_adapters["Adapter tests<br/>contract suite"]
  node_test_fixtures["Fixtures<br/>recorded responses"]
end

node_src_index -->|"starts"| node_src_server
node_src_server -->|"exposes"| node_src_prompts
node_src_server -->|"registers"| node_tool_search
node_src_server -->|"registers"| node_tool_product
node_src_server -->|"registers"| node_tool_offers
node_src_server -->|"registers"| node_tool_compare
node_src_server -->|"registers"| node_tool_list
node_src_server -->|"registers"| node_tool_cart
node_tool_search -->|"queries"| node_http_client
node_tool_search -->|"normalizes"| node_core_normalize
node_tool_product -->|"normalizes"| node_core_normalize
node_tool_offers -->|"compares"| node_core_compare
node_tool_compare -->|"aggregates"| node_core_compare
node_tool_list -->|"builds"| node_core_list
node_tool_swaps -->|"recommends"| node_core_offers
node_tool_swaps -->|"matches"| node_core_match
node_tool_freq -->|"reads"| node_cencosud_family
node_tool_cart -->|"delegates"| node_cencosud_cart
node_tool_lists -->|"delegates"| node_cencosud_lists
node_tool_branch -->|"queries"| node_unimarc_adapter
node_tool_status -.->|"reflects"| node_test_adapters
node_core_normalize -->|"produces"| node_core_types
node_core_match -->|"consumes"| node_core_types
node_core_compare -->|"uses"| node_core_match
node_core_list -->|"uses"| node_core_match
node_core_offers -->|"uses"| node_core_cache
node_http_client -->|"leverages"| node_core_cache
node_session_boundary -->|"bridges"| node_playwright_bridge
node_cencosud_family -->|"depends on"| node_session_boundary
node_cencosud_family -->|"fetches"| node_http_client
node_cencosud_session -->|"orchestrates"| node_session_boundary
node_cencosud_cart -->|"uses"| node_cencosud_session
node_cencosud_lists -->|"uses"| node_cencosud_session
node_unimarc_adapter -->|"fetches"| node_http_client
node_tottus_adapter -->|"fetches"| node_http_client
node_lider_adapter -->|"fetches"| node_http_client
node_test_adapters -->|"validates against"| node_test_fixtures
node_test_adapters -.->|"covers"| node_http_client
node_test_adapters -.->|"covers"| node_cencosud_family

click node_src_index "https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/index.ts"
click node_src_server "https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/server.ts"
click node_src_prompts "https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/prompts.ts"
click node_core_types "https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/core/types.ts"
click node_core_normalize "https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/core/normalize.ts"
click node_core_match "https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/core/matching.ts"
click node_core_compare "https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/core/compare.ts"
click node_core_list "https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/core/listBuilder.ts"
click node_core_offers "https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/core/opportunities.ts"
click node_core_cache "https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/core/cache.ts"
click node_http_client "https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/http/client.ts"
click node_session_boundary "https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/adapters/session.ts"
click node_playwright_bridge "https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/adapters/playwrightBridge.ts"
click node_cencosud_family "https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/adapters/cencosud.ts"
click node_cencosud_session "https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/adapters/cencosudSession.ts"
click node_cencosud_cart "https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/adapters/cencosudCart.ts"
click node_cencosud_lists "https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/adapters/cencosudLists.ts"
click node_unimarc_adapter "https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/adapters/unimarc.ts"
click node_tottus_adapter "https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/adapters/tottus.ts"
click node_lider_adapter "https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/adapters/lider.ts"
click node_tool_search "https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/tools/searchProducts.ts"
click node_tool_product "https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/tools/getProduct.ts"
click node_tool_offers "https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/tools/getOffers.ts"
click node_tool_compare "https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/tools/compareStores.ts"
click node_tool_list "https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/tools/buildList.ts"
click node_tool_swaps "https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/tools/suggestSwaps.ts"
click node_tool_cart "https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/tools/cart.ts"
click node_tool_lists "https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/tools/getSavedLists.ts"
click node_tool_freq "https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/tools/getFrequentPurchases.ts"
click node_tool_branch "https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/tools/discoverBranch.ts"
click node_tool_status "https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/tools/adapterStatus.ts"
click node_tool_progress "https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/tools/progress.ts"
click node_test_adapters "https://github.com/nlace-com/mcp-supermercados-cl/tree/main/tests/adapters"
click node_test_fixtures "https://github.com/nlace-com/mcp-supermercados-cl/tree/main/tests/fixtures"

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_src_index,node_src_server,node_src_prompts toneBlue
class node_core_types,node_core_normalize,node_core_match,node_core_compare,node_core_list,node_core_offers,node_core_cache toneAmber
class node_http_client,node_session_boundary,node_playwright_bridge,node_cencosud_family,node_cencosud_session,node_cencosud_cart,node_cencosud_lists,node_unimarc_adapter,node_tottus_adapter,node_lider_adapter toneMint
class node_tool_search,node_tool_product,node_tool_offers,node_tool_compare,node_tool_list,node_tool_swaps,node_tool_cart,node_tool_lists,node_tool_freq,node_tool_branch,node_tool_status,node_tool_progress toneRose
class node_test_adapters,node_test_fixtures toneIndigo
```

## Components

### MCP runtime

Node entrypoint, server setup, and prompt surface for stdio-based MCP execution.

- [Entry point](https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/index.ts): bootstrap · Starts the Node.js MCP process and wires the server runtime. · `src/index.ts`
- [MCP server](https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/server.ts): tool registry · Registers tools, prompts, and MCP-native messaging for stdio clients. · `src/server.ts`
- [Prompts](https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/prompts.ts): mcp prompts · Prompt definitions surfaced to the client alongside tools. · `src/prompts.ts`

### Core domain

Normalized product model and shared shopping algorithms.

- [Types](https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/core/types.ts): domain model · Shared normalized product, store, cart, and pricing types. · `src/core/types.ts`
- [Normalize](https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/core/normalize.ts): mapping · Converts chain-specific responses into the shared product schema. · `src/core/normalize.ts`
- [Matching](https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/core/matching.ts): ranking · Product matching, similarity, and comparison logic across chains. · `src/core/matching.ts`
- [Compare](https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/core/compare.ts): aggregation · Cross-store comparison and pricing consistency helpers. · `src/core/compare.ts`
- [List builder](https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/core/listBuilder.ts): shopping flow · Builds shopping lists from intent, history, offers, and normalized products. · `src/core/listBuilder.ts`
- [Opportunities](https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/core/opportunities.ts): recommendation · Finds bargains, swaps, and purchase opportunities from normalized data. · `src/core/opportunities.ts`
- [Cache](https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/core/cache.ts): memoization · Shared lookup cache used to reduce repeated fetches and rate-limit pressure. · `src/core/cache.ts`

### Chain adapters

Per-supermarket integration boundary plus shared HTTP and session plumbing.

- [HTTP client](https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/http/client.ts): resilient client · Central outbound HTTP layer with retries, pacing, headers, and timeouts. · `src/http/client.ts`
- [Session boundary](https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/adapters/session.ts): privacy boundary · Shared session helpers for authenticated flows that keep credentials on the user side. · `src/adapters/session.ts`
- [Browser bridge](https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/adapters/playwrightBridge.ts): browser bridge · Optional bridge into a user browser profile for authenticated operations. · `src/adapters/playwrightBridge.ts`
- [Cencosud family](https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/adapters/cencosud.ts): authenticated adapter · Jumbo and Santa Isabel integration with public catalog plus session-bound flows. · `src/adapters/cencosud.ts`
- [Cencosud session](https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/adapters/cencosudSession.ts): session orchestration · Coordinates logged-in browser state and authenticated requests for Cencosud. · `src/adapters/cencosudSession.ts`
- [Cencosud cart](https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/adapters/cencosudCart.ts): cart ops · Cart read/write operations for authenticated Cencosud flows. · `src/adapters/cencosudCart.ts`
- [Cencosud lists](https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/adapters/cencosudLists.ts): saved lists · Frequent purchases and saved-list operations for authenticated Cencosud flows. · `src/adapters/cencosudLists.ts`
- [Unimarc](https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/adapters/unimarc.ts): chain adapter · Adapter for Unimarc catalog and offers access. · `src/adapters/unimarc.ts`
- [Tottus](https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/adapters/tottus.ts): chain adapter · Adapter for Tottus catalog and product flows. · `src/adapters/tottus.ts`
- [Lider](https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/adapters/lider.ts): chain adapter · Adapter for Lider catalog and offers access. · `src/adapters/lider.ts`

### MCP tools

Thin orchestration layer exposed to the MCP client.

- [Search products](https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/tools/searchProducts.ts): mcp tool · Searches products through the appropriate chain adapter and returns normalized results. · `src/tools/searchProducts.ts`
- [Get product](https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/tools/getProduct.ts): mcp tool · Fetches product detail and normalizes chain-specific product data. · `src/tools/getProduct.ts`
- [Get offers](https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/tools/getOffers.ts): mcp tool · Retrieves chain offers and availability in a normalized form. · `src/tools/getOffers.ts`
- [Compare stores](https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/tools/compareStores.ts): mcp tool · Aggregates multiple adapters to compare pricing and unit-price consistency. · `src/tools/compareStores.ts`
- [Build list](https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/tools/buildList.ts): mcp tool · Builds shopping lists using core matching and opportunity logic. · `src/tools/buildList.ts`
- [Suggest swaps](https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/tools/suggestSwaps.ts): mcp tool · Suggests alternative products based on price, offers, and matching. · `src/tools/suggestSwaps.ts`
- [Cart access](https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/tools/cart.ts): mcp tool · Surfaces cart operations, including authenticated Cencosud actions when needed. · `src/tools/cart.ts`
- [Saved lists](https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/tools/getSavedLists.ts): mcp tool · Reads saved lists and frequent purchases for supported authenticated chains. · `src/tools/getSavedLists.ts`
- [Frequent purchases](https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/tools/getFrequentPurchases.ts): mcp tool · Fetches frequently purchased items for session-bound shopping flows. · `src/tools/getFrequentPurchases.ts`
- [Discover branch](https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/tools/discoverBranch.ts): mcp tool · Finds store branches or locations relevant to a selected chain. · `src/tools/discoverBranch.ts`
- [Adapter status](https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/tools/adapterStatus.ts): mcp tool · Reports per-adapter health and partial availability for graceful degradation. · `src/tools/adapterStatus.ts`
- [Progress](https://github.com/nlace-com/mcp-supermercados-cl/blob/main/src/tools/progress.ts): mcp tool · Emits MCP progress notifications for longer operations. · `src/tools/progress.ts`

### Tests & fixtures

Contract tests, live smoke checks, and recorded responses that validate each integration.

- [Adapter tests](https://github.com/nlace-com/mcp-supermercados-cl/tree/main/tests/adapters): contract suite · Chain-specific adapter tests validating normalization, parsing, and resilience. · `tests/adapters`
- [Fixtures](https://github.com/nlace-com/mcp-supermercados-cl/tree/main/tests/fixtures): recorded responses · Captured HTTP, HTML, and JSON responses used by adapter tests. · `tests/fixtures`

## Connections

- Entry point → MCP server: starts · Bootstraps the MCP server runtime.
- MCP server → Prompts: exposes · Registers prompt definitions with the MCP client.
- MCP server → Search products: registers · Surfaces search as an MCP tool.
- MCP server → Get product: registers · Surfaces product detail as an MCP tool.
- MCP server → Get offers: registers · Surfaces offers as an MCP tool.
- MCP server → Compare stores: registers · Surfaces store comparison as an MCP tool.
- MCP server → Build list: registers · Surfaces list building as an MCP tool.
- MCP server → Cart access: registers · Surfaces cart operations as an MCP tool.
- Search products → HTTP client: queries · Uses the shared HTTP layer for public catalog lookups.
- Search products → Normalize: normalizes · Converts raw chain data into the shared schema.
- Get product → Normalize: normalizes · Maps product detail into core types.
- Get offers → Compare: compares · Uses comparison helpers for pricing and unit-price consistency.
- Compare stores → Compare: aggregates · Combines results across adapters for store comparison.
- Build list → List builder: builds · Assembles shopping lists from domain logic.
- Suggest swaps → Opportunities: recommends · Relies on opportunities logic for alternative suggestions.
- Suggest swaps → Matching: matches · Uses similarity and substitution logic.
- Frequent purchases → Cencosud family: reads · Pulls frequent purchases from authenticated Cencosud flows.
- Cart access → Cencosud cart: delegates · Routes authenticated cart actions to the Cencosud subsystem.
- Saved lists → Cencosud lists: delegates · Routes saved-list access to the Cencosud subsystem.
- Discover branch → Unimarc: queries · Can resolve branch/location information from chain adapters.
- Adapter status → Adapter tests: reflects · Exposes adapter-level health and failure boundaries.
- Normalize → Types: produces · Creates the unified domain model used by all tools.
- Matching → Types: consumes · Operates over normalized product and pricing types.
- Compare → Matching: uses · Builds cross-store comparison on top of matching logic.
- List builder → Matching: uses · Finds candidate products and substitutes.
- Opportunities → Cache: uses · Caches repeated opportunity evaluations.
- HTTP client → Cache: leverages · Pairs request pacing with caching to reduce repeated lookups.
- Session boundary → Browser bridge: bridges · Optionally uses a browser profile to preserve user-side authentication.
- Cencosud family → Session boundary: depends on · Separates public catalog access from authenticated session flows.
- Cencosud family → HTTP client: fetches · Uses HTTP for catalog and API interactions when possible.
- Cencosud session → Session boundary: orchestrates · Coordinates the no-credentials-on-server session model.
- Cencosud cart → Cencosud session: uses · Requires authenticated session state for cart operations.
- Cencosud lists → Cencosud session: uses · Requires authenticated session state for saved lists.
- Unimarc → HTTP client: fetches · Uses shared HTTP behavior for Unimarc access.
- Tottus → HTTP client: fetches · Uses shared HTTP behavior for Tottus access.
- Lider → HTTP client: fetches · Uses shared HTTP behavior for Lider access.
- Adapter tests → Fixtures: validates against · Exercises adapters with recorded fixture data.
- Adapter tests → HTTP client: covers · Verifies HTTP behavior and retry/pacing logic.
- Adapter tests → Cencosud family: covers · Validates the most complex chain integration separately.
