defacto-mcp
# defacto-mcp
Unofficial read-only MCP server for **DeFacto** (defacto.com.tr) — Türkiye's big fashion retailer (500+ stores in 100 countries, founded 2004): product search, full product detail, the category directory, one category's products, price statistics and the store locator.
mcp-name: io.github.mohammad-abbasi-sh/defacto-mcp
## Tools
| Tool | What it does |
| --- | --- |
| `defacto_search_products` | Search products by keyword (Turkish), e.g. `elbise` (dress), `kot pantolon`, `mont`. Page (24 products/page). |
| `defacto_get_product` | Full detail of one product (URL or path ending in `-<id>`): name, code, category, colour, season, list / discounted / campaign prices in TRY, sizes with per-size stock, colour variants, description, Ürün Bilgileri attributes, review count and fit percentages, images. |
| `defacto_list_categories` | The full category directory from the public sitemap: 240 categories grouped by department (Kadın, Erkek, Kız Çocuk, Erkek Çocuk, Kız Bebek, Erkek Bebek, Bebek, Ev, …). |
| `defacto_category_products` | Products of one category (e.g. `/kadin-tesettur-elbise`), with paging. Top-level landing slugs such as `/kadin-elbise` work too. |
| `defacto_price_stats` | Price statistics for a search (first 24 results): min / median / mean / max in TRY, campaign share, average discount, top categories. |
| `defacto_list_stores` | DeFacto stores from the store locator (300+ stores): name, city, address, phone, hours, coordinates. Optional city filter, e.g. `İstanbul`. |
| `defacto_health` | Reachability check (home page + one search). |
## Install
Requires Python 3.10+. The package is published on PyPI (pending publisher setup — see below); once live:
```bash
uvx defacto-mcp
```
Claude Desktop (`claude_desktop_config.json`):
```json
{
"mcpServers": {
"defacto": {
"command": "uvx",
"args": ["defacto-mcp"]
}
}
}
```
No login, no API key. Read-only: the server only fetches public pages.
## For AI agents
- Search is Turkish: use Turkish keywords (`elbise`, not `dress`). Results carry `exact_match` — a nonsense query returns HTTP 200 with generic fallback products, so `exact_match: false` means the site found nothing; check the flag before treating results as matches.
- Prices are live and move with campaigns; `price_try` is the effective price (campaign price when present), `list_price_try` the site's listed price and `discount_pct` is computed from them. Verify price and availability on defacto.com.tr before buying.
- A product URL always ends in `-<id>` (e.g. `...-midi-elbise-3511234`) — that is the identifier `defacto_get_product` needs.
- Category slugs come from `defacto_list_categories` (e.g. `kadin-tesettur-elbise`).
- Every response includes `fetched_at` (UTC) and `source`.
## How it works
- Search and category listings are parsed from the server-rendered pages (24 products per page, each card carrying a `data-documents` JSON blob with prices, campaign price, sizes and stock). One card per page is an empty "freeItem" promo card and is skipped.
- Detail pages are parsed from the embedded JS object (list / discounted / campaign prices, per-size quantities, colour variants, pictures, description and the Ürün Bilgileri attributes) plus the review summary (count + fit percentages).
- Categories come from the public sitemap (`/sharedxml/tr-tr/category.xml`, 240 URLs); the sitemap lists fine-grained categories — top-level landing pages such as `/kadin-elbise` are not in it but work as category pages.
- Stores come from the `/magazalar` page's `window.STORES` JSON (cities + stores with addresses, phones, hours and coordinates).
- Transport uses Chrome TLS impersonation (curl-cffi): plain requests are refused with HTTP 403. Requests are spaced ~0.8s apart and retried once with another fingerprint on 403/429.
## Caveats
- DeFacto runs frequent campaigns: a price seen in the morning can change the same day. The server always returns what the site returns at fetch time.
- The average star rating and review texts load client-side and are not in the server HTML — detail returns the review count and fit percentages only.
- The site's own Google Maps / Firebase keys embedded in recorded pages were never included in the test fixtures.
- Category names in `defacto_list_categories` are derived from the slugs (the sitemap carries no display names).
## License
[PolyForm Noncommercial 1.0.0](https://polyformproject.org/licenses/noncommercial/1.0.0/) — free for personal and non-commercial use; commercial use needs a separate license.
Built by [Mohammad Abbasi](https://github.com/mohammad-abbasi-sh) — [Almanibama](https://almanibama.ir) · [mabbasi.ir](https://mabbasi.ir)
TDQS
Scored across 7 tools
Most tools are cleanly separated by input axis: search takes a keyword, category_products takes a slug/URL, get_product takes a single URL, list_stores takes a city, and health probes reachability. The only mild overlap is that search_products, category_products and price_stats all return product listings, but the descriptions make clear that price_stats is an aggregate summary and the other two differ by input type.
All tools share a uniform `defacto_` prefix and snake_case, and most follow verb_noun (get_product, search_products, list_categories, list_stores). The two noun-only names (category_products, price_stats) break the verb pattern slightly but are still predictable and readable.
Seven tools is well within the sweet spot for a read-only product catalog server. Each tool covers a distinct capability (detail, keyword search, category browse, category directory, price aggregation, store locator, health) and none feels redundant filler.
The surface covers the core discovery-to-detail lifecycle for products plus stores and a diagnostic health check, which is solid for a read-only scraping server. Minor gaps remain: search and category listings expose no sort/filter parameters, and there is no tool for reviews, related products, or per-store product availability.