ring-mcp 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. ring_mcp-0.1.0/LICENSE +9 -0
  2. ring_mcp-0.1.0/PKG-INFO +196 -0
  3. ring_mcp-0.1.0/README.md +175 -0
  4. ring_mcp-0.1.0/pyproject.toml +54 -0
  5. ring_mcp-0.1.0/ring_mcp.egg-info/PKG-INFO +196 -0
  6. ring_mcp-0.1.0/ring_mcp.egg-info/SOURCES.txt +50 -0
  7. ring_mcp-0.1.0/ring_mcp.egg-info/dependency_links.txt +1 -0
  8. ring_mcp-0.1.0/ring_mcp.egg-info/entry_points.txt +2 -0
  9. ring_mcp-0.1.0/ring_mcp.egg-info/requires.txt +2 -0
  10. ring_mcp-0.1.0/ring_mcp.egg-info/top_level.txt +1 -0
  11. ring_mcp-0.1.0/setup.cfg +4 -0
  12. ring_mcp-0.1.0/src/__init__.py +5 -0
  13. ring_mcp-0.1.0/src/prompts/__init__.py +11 -0
  14. ring_mcp-0.1.0/src/prompts/appraise_ad.py +15 -0
  15. ring_mcp-0.1.0/src/prompts/find_deal.py +19 -0
  16. ring_mcp-0.1.0/src/prompts/watch_search.py +15 -0
  17. ring_mcp-0.1.0/src/registry.py +20 -0
  18. ring_mcp-0.1.0/src/resources/__init__.py +16 -0
  19. ring_mcp-0.1.0/src/resources/categories.py +15 -0
  20. ring_mcp-0.1.0/src/resources/guide.py +18 -0
  21. ring_mcp-0.1.0/src/resources/provinces.py +15 -0
  22. ring_mcp-0.1.0/src/server.py +64 -0
  23. ring_mcp-0.1.0/src/services/core.py +804 -0
  24. ring_mcp-0.1.0/src/services/format.py +41 -0
  25. ring_mcp-0.1.0/src/services/http.py +131 -0
  26. ring_mcp-0.1.0/src/services/output.py +42 -0
  27. ring_mcp-0.1.0/src/services/posts.py +224 -0
  28. ring_mcp-0.1.0/src/services/pricing.py +93 -0
  29. ring_mcp-0.1.0/src/services/result.py +49 -0
  30. ring_mcp-0.1.0/src/services/store.py +39 -0
  31. ring_mcp-0.1.0/src/services/table.py +181 -0
  32. ring_mcp-0.1.0/src/tools/__init__.py +24 -0
  33. ring_mcp-0.1.0/src/tools/appraise.py +123 -0
  34. ring_mcp-0.1.0/src/tools/best_for_budget.py +178 -0
  35. ring_mcp-0.1.0/src/tools/categories.py +54 -0
  36. ring_mcp-0.1.0/src/tools/cheapest.py +99 -0
  37. ring_mcp-0.1.0/src/tools/compare.py +58 -0
  38. ring_mcp-0.1.0/src/tools/export.py +78 -0
  39. ring_mcp-0.1.0/src/tools/filter_options.py +49 -0
  40. ring_mcp-0.1.0/src/tools/filters.py +42 -0
  41. ring_mcp-0.1.0/src/tools/find_deals.py +125 -0
  42. ring_mcp-0.1.0/src/tools/market.py +96 -0
  43. ring_mcp-0.1.0/src/tools/new_since.py +89 -0
  44. ring_mcp-0.1.0/src/tools/places.py +47 -0
  45. ring_mcp-0.1.0/src/tools/post.py +24 -0
  46. ring_mcp-0.1.0/src/tools/posts.py +34 -0
  47. ring_mcp-0.1.0/src/tools/price_trend.py +76 -0
  48. ring_mcp-0.1.0/src/tools/search.py +91 -0
  49. ring_mcp-0.1.0/src/tools/similar.py +25 -0
  50. ring_mcp-0.1.0/src/tools/status.py +35 -0
  51. ring_mcp-0.1.0/src/tools/suggest.py +58 -0
  52. ring_mcp-0.1.0/src/tools/watch.py +134 -0
ring_mcp-0.1.0/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ring-mcp contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,196 @@
1
+ Metadata-Version: 2.4
2
+ Name: ring-mcp
3
+ Version: 0.1.0
4
+ Summary: Unofficial read-only MCP server for Ring (ring.ir), Iran's classifieds app: search ads, read details, find the cheapest and best-value ads, appraise prices.
5
+ License-Expression: MIT
6
+ Project-URL: Homepage, https://github.com/khabbazan/ring-mcp
7
+ Project-URL: Repository, https://github.com/khabbazan/ring-mcp
8
+ Project-URL: Issues, https://github.com/khabbazan/ring-mcp/issues
9
+ Keywords: mcp,mcp-server,model-context-protocol,ring,ring-ir,iran,persian,farsi,classifieds,marketplace,price-analysis,toman,unofficial
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3.14
13
+ Classifier: Natural Language :: Persian
14
+ Classifier: Topic :: Internet :: WWW/HTTP
15
+ Requires-Python: >=3.14
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Requires-Dist: mcp<3,>=2.2
19
+ Requires-Dist: httpx>=0.27
20
+ Dynamic: license-file
21
+
22
+ # Ring-MCP
23
+
24
+ **Give an AI agent a pair of eyes on [Ring](https://ring.ir) (رینگ), Iran's free classifieds app.**
25
+
26
+ Ring-MCP is an unofficial, read-only [MCP](https://modelcontextprotocol.io) server. Your agent can search ads in any city or province, open an ad in full, compare several ads, find the cheapest or best-value ones for a budget, judge whether a price is fair, and watch a search for new ads. All prices are in Toman.
27
+
28
+ Ring's public API is small: it lists ads newest first and nothing else. No price sort, no result count, no similar-ads call, no single-ad endpoint. Everything that makes Ring-MCP useful beyond a plain listing (ranking, deal scoring, market statistics, appraisal, watches) is computed here, on the ads fetched during the call.
29
+
30
+ <p align="center"><img src="docs/demo.gif" alt="Chatting with an MCP client that calls Ring-MCP: a Persian table of the best-value Peugeot 206 ads under one billion Toman" width="760"></p>
31
+
32
+ ## Contents
33
+
34
+ - [Quick start](#quick-start)
35
+ - [What you can ask](#what-you-can-ask)
36
+ - [Tools](#tools)
37
+ - [Prompts and resources](#prompts-and-resources)
38
+ - [Behaviour](#behaviour)
39
+ - [Limits](#limits)
40
+ - [Configuration](#configuration)
41
+ - [Development](#development)
42
+
43
+ ## Quick start
44
+
45
+ Requires Python 3.14+ and [uv](https://docs.astral.sh/uv/). The server speaks stdio and needs no account or token.
46
+
47
+ ```bash
48
+ git clone https://github.com/khabbazan/ring-mcp.git && cd ring-mcp
49
+ claude mcp add ring -- uv --directory "$PWD" run ring-mcp
50
+ ```
51
+
52
+ Claude Desktop, Cursor or any client with an `mcpServers` file:
53
+
54
+ ```json
55
+ { "mcpServers": { "ring": { "command": "uv", "args": ["--directory", "/path/to/ring-mcp", "run", "ring-mcp"] } } }
56
+ ```
57
+
58
+ Check the connection by asking the agent to call `ring_status`: it reports whether ring.ir is reachable and how fast.
59
+
60
+ ## What you can ask
61
+
62
+ - «یک پژو ۲۰۶ دست‌دوم در تهران زیر ۴۰۰ میلیون تومان پیدا کن و بگو کدام آگهی ارزش بیشتری دارد.»
63
+ - «۷۵۰ میلیون برای این آگهی منصفانه است؟ `https://ring.ir/a/vlvx8zyr1jWW`»
64
+ - «آپارتمان اجاره‌ای در مشهد با ودیعه زیر ۳۰۰ میلیون نشان بده، فقط آگهی‌های ۶ ساعت اخیر.»
65
+ - «آگهی‌های تازه‌ی آیفون ۱۵ در اصفهان را زیر نظر بگیر و بگو از دفعه‌ی قبل چه چیزی اضافه شده.»
66
+ - «میانه‌ی قیمت پراید در روزهایی که بررسی کردم چطور تغییر کرده؟»
67
+
68
+ Persian queries work best; Arabic letter variants and Persian/Arabic digits are folded to match.
69
+
70
+ ## Tools
71
+
72
+ Every tool is prefixed `ring_`. An ad card has `id`, `title`, `price` (sale) or `deposit` + `rent`, `info` (mileage, condition...), `zone` (neighbourhood), `age_h` (hours since publication), `photos`, `pinned`, `urgent`, `escrow` (secure payment offered), `seller_type`, `url`, and `suspect_price` when the price looks like a placeholder or an outlier. Absent flags mean false. Every list shows at most 10 ads per page.
73
+
74
+ Typical sequence: `ring_places` / `ring_categories` -> `ring_filters` -> `ring_search` -> `ring_post` -> `ring_similar` / `ring_appraise` / `ring_compare`.
75
+
76
+ ### Find places and categories
77
+
78
+ | Tool | What it does |
79
+ |---|---|
80
+ | `ring_places` | Provinces and cities (31 + 1,173) with ids and slugs |
81
+ | `ring_categories` | The 240-node category tree; search by name, list children |
82
+ | `ring_filters` | Every filter of a category: key, kind (range / select / switch), label, unit, options |
83
+ | `ring_filter_options` | Allowed values of a select filter (brands, years, colours), with text search |
84
+ | `ring_suggest` | The search box's suggestions: categories and business accounts |
85
+
86
+ ### Search and price
87
+
88
+ | Tool | What it does |
89
+ |---|---|
90
+ | `ring_search` | Search a city, province or all Iran by category, text, price, deposit, photo, urgency and any category filter; multi-page merge, client-side age, keyword and neighbourhood filters, cursor paging |
91
+ | `ring_cheapest` | The cheapest ads of a search; placeholder and outlier prices skipped |
92
+ | `ring_best_for_budget` | Within a budget: best value with an explainable `deal_score`, and the most you can get; bait titles skipped; flats for sale ranked per m2 when the title states the area; rentals ask first whether the deposit counts (`rent_basis`: `rent_only` or `with_deposit`) |
93
+ | `ring_find_deals` | Ads priced well below the median of a search, no budget needed |
94
+ | `ring_market` | Price statistics (min, quartiles, median, max) plus breakdown by neighbourhood and by day |
95
+ | `ring_appraise` | Is an ad's price (or a price you give) high or low versus similar ads: percentile, verdict, fair band, confidence |
96
+ | `ring_new_since` | Ads published after a timestamp: poll with the returned `latest` |
97
+ | `ring_export` | The ads of a search as CSV or JSON lines |
98
+ | `ring_watch` | Saved searches: create, then check to get only the ads newer than the last check (local file) |
99
+ | `ring_price_trend` | One median asking price per day for a search, kept locally |
100
+ | `ring_status` | Is Ring reachable, latency, caches, saved watches |
101
+
102
+ ### One ad
103
+
104
+ | Tool | What it does |
105
+ |---|---|
106
+ | `ring_post` | Full ad: price, specs, description, images, category path, map point |
107
+ | `ring_posts` | Up to 10 ads in one call, compact |
108
+ | `ring_compare` | 2 to 6 ads side by side: prices and only the specs that differ |
109
+ | `ring_similar` | Ads of the same category and brand word, in the ad's province, then all Iran |
110
+
111
+ All tools only read from Ring. Only `ring_watch` and `ring_price_trend` write, and only to a local file of your own searches.
112
+
113
+ ## Prompts and resources
114
+
115
+ Ready-made starting points for clients that show prompts and resources.
116
+
117
+ | Prompt | Use it to |
118
+ |---|---|
119
+ | `ring_find_deal` | Find the best deals on a product, optionally within a budget and a place |
120
+ | `ring_appraise_ad` | Judge one ad's price and decide: buy, negotiate (with a target price) or skip |
121
+ | `ring_watch_search` | Save a search and report only what is new on each check |
122
+
123
+ | Resource | Content |
124
+ |---|---|
125
+ | `ring://guide` | The tool workflow in a few lines |
126
+ | `ring://categories` | The ten top-level categories (JSON) |
127
+ | `ring://provinces` | The provinces with ids and slugs (JSON) |
128
+
129
+ ## Behaviour
130
+
131
+ - **10 per page, then it asks.** Every list shows at most 10 items. When more exist, the answer ends with the question «آیا صفحه بعدی را نشان بدهم؟» and the agent puts it to the user instead of fetching more on its own. `ring_search` and `ring_new_since` continue with `cursor` (older ads); the ranked tools and the lists of places, categories and filter options continue with `page`.
132
+ - **Rentals ask about the deposit.** `ring_best_for_budget` on a rental category first asks whether the deposit should count; `rent_basis` is `rent_only` or `with_deposit` (deposit converted to monthly cost at `deposit_rate_pct`, default 3%).
133
+ - **Unrelated results are flagged, not hidden.** Ring's text search also reads descriptions, so some results may not match `query`. When many shown ads share no word with it, a 🔎 note under the table says so; pass `keywords` to filter strictly.
134
+ - **Notes in Persian.** Hints such as "too few priced ads" or "no ad states a price" come back in Persian under the table.
135
+
136
+ ## Limits
137
+
138
+ - **Asking prices only**, as typed by sellers. A missing price means negotiable. Nothing here is financial advice.
139
+ - **A sample, not the market.** Price tools see the newest `pages` pages (up to 300 ads), not every ad. Use a narrow `query` (one model, one area) and raise `pages` for a wider scan.
140
+ - **Places.** `place` takes a city (`تهران`), a province (`استان تهران`), a slug (`tehran-province`) or `سراسر ایران`. Ring has no public neighbourhood filter, so `neighbourhoods=['ونک']` matches the fetched ads' `zone` text on our side, whole words only; `ring_watch` and `ring_price_trend` do not take it.
141
+ - **Filters.** `ring_filters` lists a category's keys. Range: `{"mileage": {"min": 0, "max": 50000}}`; select: `{"gearbox_type": ["automatic"]}` with values from `ring_filter_options`; switch: `{"has_escrow_payment": true}`. Unknown keys and values are reported in `ignored`, never silently dropped.
142
+ - **Ad details come from HTML**, so a site redesign can break `ring_post` first; the list API tools are the stable core.
143
+ - **Similar and appraisal** are category plus brand-word searches. They ignore year, mileage, area and condition: refine with `query` and `filters`.
144
+ - **No phone numbers, chat, favourites or map search.** Contact the seller on ring.ir via `url`.
145
+
146
+ ## Configuration
147
+
148
+ | Variable | Default | Meaning |
149
+ |---|---|---|
150
+ | `RING_MCP_PROXY` | unset | Optional HTTP proxy URL for requests to ring.ir; system proxy settings are ignored |
151
+ | `RING_MCP_STATE` | `~/.ring-mcp/state.json` | File for saved watches and price history |
152
+
153
+ ## Development
154
+
155
+ Every pull request runs the **Ruff** workflow (`.github/workflows/ruff.yml`: `ruff check` and `ruff format --check`). To allow merging only after it passes, mark the `ruff` job as a required status check: on GitHub, *Settings -> Branches -> Add branch protection rule* for `main`, tick *Require status checks to pass before merging* and select `ruff`.
156
+
157
+ ```bash
158
+ uv sync
159
+ uv run ruff check . && uv run ruff format --check .
160
+ uv run pytest -q # offline, recorded fixtures
161
+ uv run pytest -m integration -q # real ring.ir
162
+ ```
163
+
164
+ ### Releasing to PyPI
165
+
166
+ `.github/workflows/publish.yml` publishes with PyPI Trusted Publishing (no token). One-time setup: add a publisher for project `ring-mcp`, workflow `publish.yml`, environment `pypi` on pypi.org, and create the `pypi` environment in the GitHub repo settings. Then:
167
+
168
+ 1. Bump `version` in `pyproject.toml` and merge.
169
+ 2. Create a GitHub Release with tag `v<version>` (must match). The workflow runs tests, builds, checks metadata and uploads to PyPI.
170
+
171
+ Run the workflow manually (Actions -> Publish to PyPI -> Run workflow) to push a build to TestPyPI first (needs a `testpypi` publisher/environment).
172
+
173
+ Everything lives directly under `src/` and is installed as the `ring_mcp` package:
174
+
175
+ | Path | Role |
176
+ |---|---|
177
+ | `server.py` | Setup only: instructions, registration of tools, prompts and resources, the entry point |
178
+ | `tools/` | One file per tool |
179
+ | `prompts/`, `resources/` | Prompt templates and read-only resources |
180
+ | `services/http.py` | The only HTTP code: shared client, retries, redirects |
181
+ | `services/core.py` | Text folding, prices, zones, categories, filters, query building, paged fetching |
182
+ | `services/posts.py` | Ad-page parser and comparable-ad search |
183
+ | `services/pricing.py` | Bait detection, deal score, price statistics |
184
+ | `services/store.py` | The local state file |
185
+ | `services/result.py` | The `Ok` / `Err` result type |
186
+ | `services/output.py` | Compact JSON for tool answers |
187
+
188
+ Services never raise for expected failures: they return `Err(message)`, and only the tool layer calls `.unwrap()` to turn it into a tool error the model can read.
189
+
190
+ Tests live in `tests/`, which mirrors `src/`, as `pytest_<subject>.py` files with `test_success_...` / `test_failed_...` names. Shared fixtures are in `tests/conftest.py`, recorded ring.ir responses in `tests/fixtures`, data builders in `tests/factory`. A test checks that the tool tables above match the tools the server actually lists.
191
+
192
+ ## Disclaimer
193
+
194
+ Unofficial and not affiliated with Ring. It reads public data through the endpoints of the ring.ir web app, which can change without notice. Everything it returns is asking prices typed by sellers, not advice. Keep request rates low.
195
+
196
+ MIT licensed.
@@ -0,0 +1,175 @@
1
+ # Ring-MCP
2
+
3
+ **Give an AI agent a pair of eyes on [Ring](https://ring.ir) (رینگ), Iran's free classifieds app.**
4
+
5
+ Ring-MCP is an unofficial, read-only [MCP](https://modelcontextprotocol.io) server. Your agent can search ads in any city or province, open an ad in full, compare several ads, find the cheapest or best-value ones for a budget, judge whether a price is fair, and watch a search for new ads. All prices are in Toman.
6
+
7
+ Ring's public API is small: it lists ads newest first and nothing else. No price sort, no result count, no similar-ads call, no single-ad endpoint. Everything that makes Ring-MCP useful beyond a plain listing (ranking, deal scoring, market statistics, appraisal, watches) is computed here, on the ads fetched during the call.
8
+
9
+ <p align="center"><img src="docs/demo.gif" alt="Chatting with an MCP client that calls Ring-MCP: a Persian table of the best-value Peugeot 206 ads under one billion Toman" width="760"></p>
10
+
11
+ ## Contents
12
+
13
+ - [Quick start](#quick-start)
14
+ - [What you can ask](#what-you-can-ask)
15
+ - [Tools](#tools)
16
+ - [Prompts and resources](#prompts-and-resources)
17
+ - [Behaviour](#behaviour)
18
+ - [Limits](#limits)
19
+ - [Configuration](#configuration)
20
+ - [Development](#development)
21
+
22
+ ## Quick start
23
+
24
+ Requires Python 3.14+ and [uv](https://docs.astral.sh/uv/). The server speaks stdio and needs no account or token.
25
+
26
+ ```bash
27
+ git clone https://github.com/khabbazan/ring-mcp.git && cd ring-mcp
28
+ claude mcp add ring -- uv --directory "$PWD" run ring-mcp
29
+ ```
30
+
31
+ Claude Desktop, Cursor or any client with an `mcpServers` file:
32
+
33
+ ```json
34
+ { "mcpServers": { "ring": { "command": "uv", "args": ["--directory", "/path/to/ring-mcp", "run", "ring-mcp"] } } }
35
+ ```
36
+
37
+ Check the connection by asking the agent to call `ring_status`: it reports whether ring.ir is reachable and how fast.
38
+
39
+ ## What you can ask
40
+
41
+ - «یک پژو ۲۰۶ دست‌دوم در تهران زیر ۴۰۰ میلیون تومان پیدا کن و بگو کدام آگهی ارزش بیشتری دارد.»
42
+ - «۷۵۰ میلیون برای این آگهی منصفانه است؟ `https://ring.ir/a/vlvx8zyr1jWW`»
43
+ - «آپارتمان اجاره‌ای در مشهد با ودیعه زیر ۳۰۰ میلیون نشان بده، فقط آگهی‌های ۶ ساعت اخیر.»
44
+ - «آگهی‌های تازه‌ی آیفون ۱۵ در اصفهان را زیر نظر بگیر و بگو از دفعه‌ی قبل چه چیزی اضافه شده.»
45
+ - «میانه‌ی قیمت پراید در روزهایی که بررسی کردم چطور تغییر کرده؟»
46
+
47
+ Persian queries work best; Arabic letter variants and Persian/Arabic digits are folded to match.
48
+
49
+ ## Tools
50
+
51
+ Every tool is prefixed `ring_`. An ad card has `id`, `title`, `price` (sale) or `deposit` + `rent`, `info` (mileage, condition...), `zone` (neighbourhood), `age_h` (hours since publication), `photos`, `pinned`, `urgent`, `escrow` (secure payment offered), `seller_type`, `url`, and `suspect_price` when the price looks like a placeholder or an outlier. Absent flags mean false. Every list shows at most 10 ads per page.
52
+
53
+ Typical sequence: `ring_places` / `ring_categories` -> `ring_filters` -> `ring_search` -> `ring_post` -> `ring_similar` / `ring_appraise` / `ring_compare`.
54
+
55
+ ### Find places and categories
56
+
57
+ | Tool | What it does |
58
+ |---|---|
59
+ | `ring_places` | Provinces and cities (31 + 1,173) with ids and slugs |
60
+ | `ring_categories` | The 240-node category tree; search by name, list children |
61
+ | `ring_filters` | Every filter of a category: key, kind (range / select / switch), label, unit, options |
62
+ | `ring_filter_options` | Allowed values of a select filter (brands, years, colours), with text search |
63
+ | `ring_suggest` | The search box's suggestions: categories and business accounts |
64
+
65
+ ### Search and price
66
+
67
+ | Tool | What it does |
68
+ |---|---|
69
+ | `ring_search` | Search a city, province or all Iran by category, text, price, deposit, photo, urgency and any category filter; multi-page merge, client-side age, keyword and neighbourhood filters, cursor paging |
70
+ | `ring_cheapest` | The cheapest ads of a search; placeholder and outlier prices skipped |
71
+ | `ring_best_for_budget` | Within a budget: best value with an explainable `deal_score`, and the most you can get; bait titles skipped; flats for sale ranked per m2 when the title states the area; rentals ask first whether the deposit counts (`rent_basis`: `rent_only` or `with_deposit`) |
72
+ | `ring_find_deals` | Ads priced well below the median of a search, no budget needed |
73
+ | `ring_market` | Price statistics (min, quartiles, median, max) plus breakdown by neighbourhood and by day |
74
+ | `ring_appraise` | Is an ad's price (or a price you give) high or low versus similar ads: percentile, verdict, fair band, confidence |
75
+ | `ring_new_since` | Ads published after a timestamp: poll with the returned `latest` |
76
+ | `ring_export` | The ads of a search as CSV or JSON lines |
77
+ | `ring_watch` | Saved searches: create, then check to get only the ads newer than the last check (local file) |
78
+ | `ring_price_trend` | One median asking price per day for a search, kept locally |
79
+ | `ring_status` | Is Ring reachable, latency, caches, saved watches |
80
+
81
+ ### One ad
82
+
83
+ | Tool | What it does |
84
+ |---|---|
85
+ | `ring_post` | Full ad: price, specs, description, images, category path, map point |
86
+ | `ring_posts` | Up to 10 ads in one call, compact |
87
+ | `ring_compare` | 2 to 6 ads side by side: prices and only the specs that differ |
88
+ | `ring_similar` | Ads of the same category and brand word, in the ad's province, then all Iran |
89
+
90
+ All tools only read from Ring. Only `ring_watch` and `ring_price_trend` write, and only to a local file of your own searches.
91
+
92
+ ## Prompts and resources
93
+
94
+ Ready-made starting points for clients that show prompts and resources.
95
+
96
+ | Prompt | Use it to |
97
+ |---|---|
98
+ | `ring_find_deal` | Find the best deals on a product, optionally within a budget and a place |
99
+ | `ring_appraise_ad` | Judge one ad's price and decide: buy, negotiate (with a target price) or skip |
100
+ | `ring_watch_search` | Save a search and report only what is new on each check |
101
+
102
+ | Resource | Content |
103
+ |---|---|
104
+ | `ring://guide` | The tool workflow in a few lines |
105
+ | `ring://categories` | The ten top-level categories (JSON) |
106
+ | `ring://provinces` | The provinces with ids and slugs (JSON) |
107
+
108
+ ## Behaviour
109
+
110
+ - **10 per page, then it asks.** Every list shows at most 10 items. When more exist, the answer ends with the question «آیا صفحه بعدی را نشان بدهم؟» and the agent puts it to the user instead of fetching more on its own. `ring_search` and `ring_new_since` continue with `cursor` (older ads); the ranked tools and the lists of places, categories and filter options continue with `page`.
111
+ - **Rentals ask about the deposit.** `ring_best_for_budget` on a rental category first asks whether the deposit should count; `rent_basis` is `rent_only` or `with_deposit` (deposit converted to monthly cost at `deposit_rate_pct`, default 3%).
112
+ - **Unrelated results are flagged, not hidden.** Ring's text search also reads descriptions, so some results may not match `query`. When many shown ads share no word with it, a 🔎 note under the table says so; pass `keywords` to filter strictly.
113
+ - **Notes in Persian.** Hints such as "too few priced ads" or "no ad states a price" come back in Persian under the table.
114
+
115
+ ## Limits
116
+
117
+ - **Asking prices only**, as typed by sellers. A missing price means negotiable. Nothing here is financial advice.
118
+ - **A sample, not the market.** Price tools see the newest `pages` pages (up to 300 ads), not every ad. Use a narrow `query` (one model, one area) and raise `pages` for a wider scan.
119
+ - **Places.** `place` takes a city (`تهران`), a province (`استان تهران`), a slug (`tehran-province`) or `سراسر ایران`. Ring has no public neighbourhood filter, so `neighbourhoods=['ونک']` matches the fetched ads' `zone` text on our side, whole words only; `ring_watch` and `ring_price_trend` do not take it.
120
+ - **Filters.** `ring_filters` lists a category's keys. Range: `{"mileage": {"min": 0, "max": 50000}}`; select: `{"gearbox_type": ["automatic"]}` with values from `ring_filter_options`; switch: `{"has_escrow_payment": true}`. Unknown keys and values are reported in `ignored`, never silently dropped.
121
+ - **Ad details come from HTML**, so a site redesign can break `ring_post` first; the list API tools are the stable core.
122
+ - **Similar and appraisal** are category plus brand-word searches. They ignore year, mileage, area and condition: refine with `query` and `filters`.
123
+ - **No phone numbers, chat, favourites or map search.** Contact the seller on ring.ir via `url`.
124
+
125
+ ## Configuration
126
+
127
+ | Variable | Default | Meaning |
128
+ |---|---|---|
129
+ | `RING_MCP_PROXY` | unset | Optional HTTP proxy URL for requests to ring.ir; system proxy settings are ignored |
130
+ | `RING_MCP_STATE` | `~/.ring-mcp/state.json` | File for saved watches and price history |
131
+
132
+ ## Development
133
+
134
+ Every pull request runs the **Ruff** workflow (`.github/workflows/ruff.yml`: `ruff check` and `ruff format --check`). To allow merging only after it passes, mark the `ruff` job as a required status check: on GitHub, *Settings -> Branches -> Add branch protection rule* for `main`, tick *Require status checks to pass before merging* and select `ruff`.
135
+
136
+ ```bash
137
+ uv sync
138
+ uv run ruff check . && uv run ruff format --check .
139
+ uv run pytest -q # offline, recorded fixtures
140
+ uv run pytest -m integration -q # real ring.ir
141
+ ```
142
+
143
+ ### Releasing to PyPI
144
+
145
+ `.github/workflows/publish.yml` publishes with PyPI Trusted Publishing (no token). One-time setup: add a publisher for project `ring-mcp`, workflow `publish.yml`, environment `pypi` on pypi.org, and create the `pypi` environment in the GitHub repo settings. Then:
146
+
147
+ 1. Bump `version` in `pyproject.toml` and merge.
148
+ 2. Create a GitHub Release with tag `v<version>` (must match). The workflow runs tests, builds, checks metadata and uploads to PyPI.
149
+
150
+ Run the workflow manually (Actions -> Publish to PyPI -> Run workflow) to push a build to TestPyPI first (needs a `testpypi` publisher/environment).
151
+
152
+ Everything lives directly under `src/` and is installed as the `ring_mcp` package:
153
+
154
+ | Path | Role |
155
+ |---|---|
156
+ | `server.py` | Setup only: instructions, registration of tools, prompts and resources, the entry point |
157
+ | `tools/` | One file per tool |
158
+ | `prompts/`, `resources/` | Prompt templates and read-only resources |
159
+ | `services/http.py` | The only HTTP code: shared client, retries, redirects |
160
+ | `services/core.py` | Text folding, prices, zones, categories, filters, query building, paged fetching |
161
+ | `services/posts.py` | Ad-page parser and comparable-ad search |
162
+ | `services/pricing.py` | Bait detection, deal score, price statistics |
163
+ | `services/store.py` | The local state file |
164
+ | `services/result.py` | The `Ok` / `Err` result type |
165
+ | `services/output.py` | Compact JSON for tool answers |
166
+
167
+ Services never raise for expected failures: they return `Err(message)`, and only the tool layer calls `.unwrap()` to turn it into a tool error the model can read.
168
+
169
+ Tests live in `tests/`, which mirrors `src/`, as `pytest_<subject>.py` files with `test_success_...` / `test_failed_...` names. Shared fixtures are in `tests/conftest.py`, recorded ring.ir responses in `tests/fixtures`, data builders in `tests/factory`. A test checks that the tool tables above match the tools the server actually lists.
170
+
171
+ ## Disclaimer
172
+
173
+ Unofficial and not affiliated with Ring. It reads public data through the endpoints of the ring.ir web app, which can change without notice. Everything it returns is asking prices typed by sellers, not advice. Keep request rates low.
174
+
175
+ MIT licensed.
@@ -0,0 +1,54 @@
1
+ [project]
2
+ name = "ring-mcp"
3
+ version = "0.1.0"
4
+ description = "Unofficial read-only MCP server for Ring (ring.ir), Iran's classifieds app: search ads, read details, find the cheapest and best-value ads, appraise prices."
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ requires-python = ">=3.14"
8
+ keywords = [
9
+ "mcp", "mcp-server", "model-context-protocol", "ring", "ring-ir", "iran", "persian", "farsi",
10
+ "classifieds", "marketplace", "price-analysis", "toman", "unofficial",
11
+ ]
12
+ classifiers = [
13
+ "Development Status :: 4 - Beta",
14
+ "Intended Audience :: Developers",
15
+ "Programming Language :: Python :: 3.14",
16
+ "Natural Language :: Persian",
17
+ "Topic :: Internet :: WWW/HTTP",
18
+ ]
19
+ dependencies = ["mcp>=2.2,<3", "httpx>=0.27"]
20
+
21
+ [project.urls]
22
+ Homepage = "https://github.com/khabbazan/ring-mcp"
23
+ Repository = "https://github.com/khabbazan/ring-mcp"
24
+ Issues = "https://github.com/khabbazan/ring-mcp/issues"
25
+
26
+ [project.scripts]
27
+ ring-mcp = "ring_mcp.server:main"
28
+
29
+ [dependency-groups]
30
+ dev = ["pytest>=8", "ruff>=0.6"]
31
+
32
+ [build-system]
33
+ requires = ["setuptools>=77"]
34
+ build-backend = "setuptools.build_meta"
35
+
36
+ # Everything lives directly under `src/`; it is installed as the `ring_mcp` package.
37
+ [tool.setuptools]
38
+ package-dir = { ring_mcp = "src" }
39
+ packages = ["ring_mcp", "ring_mcp.tools", "ring_mcp.services", "ring_mcp.prompts", "ring_mcp.resources"]
40
+
41
+ [tool.pytest.ini_options]
42
+ testpaths = ["tests"]
43
+ pythonpath = ["."]
44
+ python_files = ["pytest_*.py"]
45
+ addopts = "-m 'not integration' --import-mode=importlib"
46
+ markers = ["integration: calls the real ring.ir (run with -m integration)"]
47
+
48
+ [tool.ruff]
49
+ line-length = 120
50
+ target-version = "py314"
51
+
52
+ [tool.ruff.lint]
53
+ select = ["E", "F", "I", "B", "UP"]
54
+ ignore = ["E501"]
@@ -0,0 +1,196 @@
1
+ Metadata-Version: 2.4
2
+ Name: ring-mcp
3
+ Version: 0.1.0
4
+ Summary: Unofficial read-only MCP server for Ring (ring.ir), Iran's classifieds app: search ads, read details, find the cheapest and best-value ads, appraise prices.
5
+ License-Expression: MIT
6
+ Project-URL: Homepage, https://github.com/khabbazan/ring-mcp
7
+ Project-URL: Repository, https://github.com/khabbazan/ring-mcp
8
+ Project-URL: Issues, https://github.com/khabbazan/ring-mcp/issues
9
+ Keywords: mcp,mcp-server,model-context-protocol,ring,ring-ir,iran,persian,farsi,classifieds,marketplace,price-analysis,toman,unofficial
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3.14
13
+ Classifier: Natural Language :: Persian
14
+ Classifier: Topic :: Internet :: WWW/HTTP
15
+ Requires-Python: >=3.14
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Requires-Dist: mcp<3,>=2.2
19
+ Requires-Dist: httpx>=0.27
20
+ Dynamic: license-file
21
+
22
+ # Ring-MCP
23
+
24
+ **Give an AI agent a pair of eyes on [Ring](https://ring.ir) (رینگ), Iran's free classifieds app.**
25
+
26
+ Ring-MCP is an unofficial, read-only [MCP](https://modelcontextprotocol.io) server. Your agent can search ads in any city or province, open an ad in full, compare several ads, find the cheapest or best-value ones for a budget, judge whether a price is fair, and watch a search for new ads. All prices are in Toman.
27
+
28
+ Ring's public API is small: it lists ads newest first and nothing else. No price sort, no result count, no similar-ads call, no single-ad endpoint. Everything that makes Ring-MCP useful beyond a plain listing (ranking, deal scoring, market statistics, appraisal, watches) is computed here, on the ads fetched during the call.
29
+
30
+ <p align="center"><img src="docs/demo.gif" alt="Chatting with an MCP client that calls Ring-MCP: a Persian table of the best-value Peugeot 206 ads under one billion Toman" width="760"></p>
31
+
32
+ ## Contents
33
+
34
+ - [Quick start](#quick-start)
35
+ - [What you can ask](#what-you-can-ask)
36
+ - [Tools](#tools)
37
+ - [Prompts and resources](#prompts-and-resources)
38
+ - [Behaviour](#behaviour)
39
+ - [Limits](#limits)
40
+ - [Configuration](#configuration)
41
+ - [Development](#development)
42
+
43
+ ## Quick start
44
+
45
+ Requires Python 3.14+ and [uv](https://docs.astral.sh/uv/). The server speaks stdio and needs no account or token.
46
+
47
+ ```bash
48
+ git clone https://github.com/khabbazan/ring-mcp.git && cd ring-mcp
49
+ claude mcp add ring -- uv --directory "$PWD" run ring-mcp
50
+ ```
51
+
52
+ Claude Desktop, Cursor or any client with an `mcpServers` file:
53
+
54
+ ```json
55
+ { "mcpServers": { "ring": { "command": "uv", "args": ["--directory", "/path/to/ring-mcp", "run", "ring-mcp"] } } }
56
+ ```
57
+
58
+ Check the connection by asking the agent to call `ring_status`: it reports whether ring.ir is reachable and how fast.
59
+
60
+ ## What you can ask
61
+
62
+ - «یک پژو ۲۰۶ دست‌دوم در تهران زیر ۴۰۰ میلیون تومان پیدا کن و بگو کدام آگهی ارزش بیشتری دارد.»
63
+ - «۷۵۰ میلیون برای این آگهی منصفانه است؟ `https://ring.ir/a/vlvx8zyr1jWW`»
64
+ - «آپارتمان اجاره‌ای در مشهد با ودیعه زیر ۳۰۰ میلیون نشان بده، فقط آگهی‌های ۶ ساعت اخیر.»
65
+ - «آگهی‌های تازه‌ی آیفون ۱۵ در اصفهان را زیر نظر بگیر و بگو از دفعه‌ی قبل چه چیزی اضافه شده.»
66
+ - «میانه‌ی قیمت پراید در روزهایی که بررسی کردم چطور تغییر کرده؟»
67
+
68
+ Persian queries work best; Arabic letter variants and Persian/Arabic digits are folded to match.
69
+
70
+ ## Tools
71
+
72
+ Every tool is prefixed `ring_`. An ad card has `id`, `title`, `price` (sale) or `deposit` + `rent`, `info` (mileage, condition...), `zone` (neighbourhood), `age_h` (hours since publication), `photos`, `pinned`, `urgent`, `escrow` (secure payment offered), `seller_type`, `url`, and `suspect_price` when the price looks like a placeholder or an outlier. Absent flags mean false. Every list shows at most 10 ads per page.
73
+
74
+ Typical sequence: `ring_places` / `ring_categories` -> `ring_filters` -> `ring_search` -> `ring_post` -> `ring_similar` / `ring_appraise` / `ring_compare`.
75
+
76
+ ### Find places and categories
77
+
78
+ | Tool | What it does |
79
+ |---|---|
80
+ | `ring_places` | Provinces and cities (31 + 1,173) with ids and slugs |
81
+ | `ring_categories` | The 240-node category tree; search by name, list children |
82
+ | `ring_filters` | Every filter of a category: key, kind (range / select / switch), label, unit, options |
83
+ | `ring_filter_options` | Allowed values of a select filter (brands, years, colours), with text search |
84
+ | `ring_suggest` | The search box's suggestions: categories and business accounts |
85
+
86
+ ### Search and price
87
+
88
+ | Tool | What it does |
89
+ |---|---|
90
+ | `ring_search` | Search a city, province or all Iran by category, text, price, deposit, photo, urgency and any category filter; multi-page merge, client-side age, keyword and neighbourhood filters, cursor paging |
91
+ | `ring_cheapest` | The cheapest ads of a search; placeholder and outlier prices skipped |
92
+ | `ring_best_for_budget` | Within a budget: best value with an explainable `deal_score`, and the most you can get; bait titles skipped; flats for sale ranked per m2 when the title states the area; rentals ask first whether the deposit counts (`rent_basis`: `rent_only` or `with_deposit`) |
93
+ | `ring_find_deals` | Ads priced well below the median of a search, no budget needed |
94
+ | `ring_market` | Price statistics (min, quartiles, median, max) plus breakdown by neighbourhood and by day |
95
+ | `ring_appraise` | Is an ad's price (or a price you give) high or low versus similar ads: percentile, verdict, fair band, confidence |
96
+ | `ring_new_since` | Ads published after a timestamp: poll with the returned `latest` |
97
+ | `ring_export` | The ads of a search as CSV or JSON lines |
98
+ | `ring_watch` | Saved searches: create, then check to get only the ads newer than the last check (local file) |
99
+ | `ring_price_trend` | One median asking price per day for a search, kept locally |
100
+ | `ring_status` | Is Ring reachable, latency, caches, saved watches |
101
+
102
+ ### One ad
103
+
104
+ | Tool | What it does |
105
+ |---|---|
106
+ | `ring_post` | Full ad: price, specs, description, images, category path, map point |
107
+ | `ring_posts` | Up to 10 ads in one call, compact |
108
+ | `ring_compare` | 2 to 6 ads side by side: prices and only the specs that differ |
109
+ | `ring_similar` | Ads of the same category and brand word, in the ad's province, then all Iran |
110
+
111
+ All tools only read from Ring. Only `ring_watch` and `ring_price_trend` write, and only to a local file of your own searches.
112
+
113
+ ## Prompts and resources
114
+
115
+ Ready-made starting points for clients that show prompts and resources.
116
+
117
+ | Prompt | Use it to |
118
+ |---|---|
119
+ | `ring_find_deal` | Find the best deals on a product, optionally within a budget and a place |
120
+ | `ring_appraise_ad` | Judge one ad's price and decide: buy, negotiate (with a target price) or skip |
121
+ | `ring_watch_search` | Save a search and report only what is new on each check |
122
+
123
+ | Resource | Content |
124
+ |---|---|
125
+ | `ring://guide` | The tool workflow in a few lines |
126
+ | `ring://categories` | The ten top-level categories (JSON) |
127
+ | `ring://provinces` | The provinces with ids and slugs (JSON) |
128
+
129
+ ## Behaviour
130
+
131
+ - **10 per page, then it asks.** Every list shows at most 10 items. When more exist, the answer ends with the question «آیا صفحه بعدی را نشان بدهم؟» and the agent puts it to the user instead of fetching more on its own. `ring_search` and `ring_new_since` continue with `cursor` (older ads); the ranked tools and the lists of places, categories and filter options continue with `page`.
132
+ - **Rentals ask about the deposit.** `ring_best_for_budget` on a rental category first asks whether the deposit should count; `rent_basis` is `rent_only` or `with_deposit` (deposit converted to monthly cost at `deposit_rate_pct`, default 3%).
133
+ - **Unrelated results are flagged, not hidden.** Ring's text search also reads descriptions, so some results may not match `query`. When many shown ads share no word with it, a 🔎 note under the table says so; pass `keywords` to filter strictly.
134
+ - **Notes in Persian.** Hints such as "too few priced ads" or "no ad states a price" come back in Persian under the table.
135
+
136
+ ## Limits
137
+
138
+ - **Asking prices only**, as typed by sellers. A missing price means negotiable. Nothing here is financial advice.
139
+ - **A sample, not the market.** Price tools see the newest `pages` pages (up to 300 ads), not every ad. Use a narrow `query` (one model, one area) and raise `pages` for a wider scan.
140
+ - **Places.** `place` takes a city (`تهران`), a province (`استان تهران`), a slug (`tehran-province`) or `سراسر ایران`. Ring has no public neighbourhood filter, so `neighbourhoods=['ونک']` matches the fetched ads' `zone` text on our side, whole words only; `ring_watch` and `ring_price_trend` do not take it.
141
+ - **Filters.** `ring_filters` lists a category's keys. Range: `{"mileage": {"min": 0, "max": 50000}}`; select: `{"gearbox_type": ["automatic"]}` with values from `ring_filter_options`; switch: `{"has_escrow_payment": true}`. Unknown keys and values are reported in `ignored`, never silently dropped.
142
+ - **Ad details come from HTML**, so a site redesign can break `ring_post` first; the list API tools are the stable core.
143
+ - **Similar and appraisal** are category plus brand-word searches. They ignore year, mileage, area and condition: refine with `query` and `filters`.
144
+ - **No phone numbers, chat, favourites or map search.** Contact the seller on ring.ir via `url`.
145
+
146
+ ## Configuration
147
+
148
+ | Variable | Default | Meaning |
149
+ |---|---|---|
150
+ | `RING_MCP_PROXY` | unset | Optional HTTP proxy URL for requests to ring.ir; system proxy settings are ignored |
151
+ | `RING_MCP_STATE` | `~/.ring-mcp/state.json` | File for saved watches and price history |
152
+
153
+ ## Development
154
+
155
+ Every pull request runs the **Ruff** workflow (`.github/workflows/ruff.yml`: `ruff check` and `ruff format --check`). To allow merging only after it passes, mark the `ruff` job as a required status check: on GitHub, *Settings -> Branches -> Add branch protection rule* for `main`, tick *Require status checks to pass before merging* and select `ruff`.
156
+
157
+ ```bash
158
+ uv sync
159
+ uv run ruff check . && uv run ruff format --check .
160
+ uv run pytest -q # offline, recorded fixtures
161
+ uv run pytest -m integration -q # real ring.ir
162
+ ```
163
+
164
+ ### Releasing to PyPI
165
+
166
+ `.github/workflows/publish.yml` publishes with PyPI Trusted Publishing (no token). One-time setup: add a publisher for project `ring-mcp`, workflow `publish.yml`, environment `pypi` on pypi.org, and create the `pypi` environment in the GitHub repo settings. Then:
167
+
168
+ 1. Bump `version` in `pyproject.toml` and merge.
169
+ 2. Create a GitHub Release with tag `v<version>` (must match). The workflow runs tests, builds, checks metadata and uploads to PyPI.
170
+
171
+ Run the workflow manually (Actions -> Publish to PyPI -> Run workflow) to push a build to TestPyPI first (needs a `testpypi` publisher/environment).
172
+
173
+ Everything lives directly under `src/` and is installed as the `ring_mcp` package:
174
+
175
+ | Path | Role |
176
+ |---|---|
177
+ | `server.py` | Setup only: instructions, registration of tools, prompts and resources, the entry point |
178
+ | `tools/` | One file per tool |
179
+ | `prompts/`, `resources/` | Prompt templates and read-only resources |
180
+ | `services/http.py` | The only HTTP code: shared client, retries, redirects |
181
+ | `services/core.py` | Text folding, prices, zones, categories, filters, query building, paged fetching |
182
+ | `services/posts.py` | Ad-page parser and comparable-ad search |
183
+ | `services/pricing.py` | Bait detection, deal score, price statistics |
184
+ | `services/store.py` | The local state file |
185
+ | `services/result.py` | The `Ok` / `Err` result type |
186
+ | `services/output.py` | Compact JSON for tool answers |
187
+
188
+ Services never raise for expected failures: they return `Err(message)`, and only the tool layer calls `.unwrap()` to turn it into a tool error the model can read.
189
+
190
+ Tests live in `tests/`, which mirrors `src/`, as `pytest_<subject>.py` files with `test_success_...` / `test_failed_...` names. Shared fixtures are in `tests/conftest.py`, recorded ring.ir responses in `tests/fixtures`, data builders in `tests/factory`. A test checks that the tool tables above match the tools the server actually lists.
191
+
192
+ ## Disclaimer
193
+
194
+ Unofficial and not affiliated with Ring. It reads public data through the endpoints of the ring.ir web app, which can change without notice. Everything it returns is asking prices typed by sellers, not advice. Keep request rates low.
195
+
196
+ MIT licensed.