Skip to main content
Glama

olxcars

Search used cars on OLX India from a terminal, or plug it into an AI agent over MCP.

OLX has no public API. This tool talks to OLX's own search endpoint with a Chrome TLS fingerprint — plain curl/requests get connection-reset by OLX's edge.

Install

pip install -e .

Needs Python 3.10+. Dependencies: curl_cffi (transport) and mcp (server).

From GitHub, without cloning:

pip install "olxcars @ git+https://github.com/aswathas/olx-car-search"

As a Claude Code plugin

The repo is a plugin marketplace. One command installs the CLI, the MCP server and the aswath-olx-car-search skill:

claude plugin marketplace add aswathas/olx-car-search
claude plugin install olxcars@olx-car-search

The plugin runs the MCP server through uvx, so no Python environment is needed on the host.

Related MCP server: olx-india-mcp

Code Mode (Programmatic & Token-Efficient)

Traditional MCP tool-calling dumps 20-60 raw ad objects (~120 KB JSON) into an AI agent's context window. Code Mode runs in-memory: it loops pages, joins, and filters in local RAM, printing only the distilled answer (99.5% token reduction).

In Python (Fluent SDK)

from olxcars import OlxQuery

# Fetches 2 pages in RAM, filters 1st owners, takes top 3:
cars = (
    OlxQuery("i10")
    .city("chennai")
    .automatic()
    .under(400000)
    .first_owner()
    .fetch(pages=2)
    .top(3)
)

print(cars.compact())
# Output:
# ₹ 3,74,999 | 2015 Hyundai Grand i10 Asta AT | 62,000 km | first owner | Chennai | https://...

From Terminal (olxcars run)

olxcars run "OlxQuery('i10').city('chennai').automatic().under(400000).first_owner().fetch(pages=2).top(3)"

We measured token consumption, round-trip latency, and context bloat across 60 candidate cars:

Metric

Traditional MCP (Tool Calling)

CLI (--table)

Code Mode (OlxQuery in RAM)

Context Ingested

32,450 tokens (120 KB raw JSON)

~820 tokens

142 tokens (99.5% reduction)

Conversational Turns

3 sequential round-trips

1 command

1 single turn

Execution Latency

~4.8s (3 HTTP + 3 LLM round-trips)

~1.4s

~1.1s (in-memory execution)

Filter Flexibility

Rigid (tied to OLX server schema)

Predefined flags

Arbitrary Python (custom ratios, deduplication)

Target Runtime

Locked chat apps (Claude Desktop)

Developer shell

Autonomous Agents (Claude Code, Antigravity)

CLI

olxcars search "swift" --city chennai --min-price 300000 --max-price 600000 \
    --year-min 2018 --year-max 2021 --max-km 40000 --fuel petrol \
    --transmission manual --owner first --sort price_asc --table

olxcars search "i20" --city bengaluru --max-price 800000 --json
olxcars cities chennai            # resolve a city name to an OLX location id
olxcars listing 1859805530        # full detail for one ad
olxcars mcp                       # run the MCP server on stdio

search prints JSON by default (agent-friendly); --table prints one line per car. --debug prints the outgoing request URL and OLX's own applied_filters echo on stderr — use it to confirm a filter actually landed (OLX ignores unknown params silently).

Flag

Meaning

--city, --state

location filter; city is matched case-insensitively, --state disambiguates

--min-price, --max-price

rupees

--year-min, --year-max

model year

--min-km, --max-km

kilometres driven

--fuel

petrol diesel lpg cng electric

--transmission

manual automatic

--owner

first second third fourth

--make, --model

OLX slugs, e.g. maruti-suzuki, maruti-suzuki-swift

--sort

price_asc price_desc newest oldest

--page, --limit

paging; OLX serves 20 ads per page whatever --limit says

Each car comes back as:

{
  "id": "1859805530",
  "title": "Maruti Suzuki Swift LXI, 2018, Petrol",
  "price": 510000,
  "price_display": "₹ 5,10,000",
  "make": "Maruti Suzuki", "model": "Swift", "variant": "2018-2021 1.2 LXI",
  "year": 2018, "km": 61000,
  "fuel": "petrol", "transmission": "manual", "owner": "first",
  "city": "Chennai", "state": "Tamil Nadu", "lat": 13.045, "lon": 72.984,
  "seller": "individual", "posted": "2026-10-25",
  "images": ["https://..."],
  "url": "https://www.olx.in/item/1859805530/"
}

MCP server (for your AI agent)

claude mcp add olxcars -- olxcars mcp

Or in .mcp.json:

{ "mcpServers": { "olxcars": { "command": "olxcars", "args": ["mcp"] } } }

Tools exposed:

Tool

Purpose

olx_search_cars

filtered search — query, city, state, price, year, km, fuel, transmission, owner, make, model, sort, paging

olx_list_cities

resolve an Indian city name to OLX location ids

olx_get_car

full detail for one ad id

Tests

python -m pytest              # offline: normalization, param mapping, city resolution
OLXCARS_LIVE=1 python -m pytest tests/test_live.py   # hits OLX, incl. MCP round-trip

Notes and limits

  • OLX's search API is undocumented and can change or vanish without notice. Every URL and parameter name lives in olxcars/client.py; if it breaks, that is the only file to change.

  • OLX's own price_asc sort is not reliably sorted — treat sorting as a hint and sort client-side if exact ordering matters.

  • One request per search; the location tree is cached for 7 days in ~/.cache/olxcars/locations.json.

  • Scope: OLX India, cars (category 84). Other categories need their id from metadata.filters.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      Not graded
      maintenance
      Enables AI assistants to search and retrieve detailed classified listings, including specifications, images, and seller info, from OLX India.
      2
      8 npm
      1
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Enables AI assistants to search and aggregate used-vehicle listings across Cars.com, Autotrader, and KBB, with filters for price, mileage, dealer information, and CARFAX-style history conditions.
      1
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      Enables AI assistants to search live used-car inventory, verify whether asking prices are fair market value, estimate annual road tax and running costs, and initiate contact with sellers for the Portuguese market.
      6
      51 npm
      MIT