blindsbazaar-mcp 0.1.0__py3-none-any.whl
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.
- blindsbazaar_mcp/__init__.py +1 -0
- blindsbazaar_mcp/client.py +76 -0
- blindsbazaar_mcp/server.py +456 -0
- blindsbazaar_mcp-0.1.0.dist-info/METADATA +128 -0
- blindsbazaar_mcp-0.1.0.dist-info/RECORD +7 -0
- blindsbazaar_mcp-0.1.0.dist-info/WHEEL +4 -0
- blindsbazaar_mcp-0.1.0.dist-info/entry_points.txt +2 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""BlindsBazaar MCP server package."""
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"""Thin HTTP client for the BlindsBazaar public storefront API.
|
|
2
|
+
|
|
3
|
+
Read-only: every call hits a public, unauthenticated endpoint, so the MCP
|
|
4
|
+
server carries no secrets and can be shipped to any client. The base URL is
|
|
5
|
+
overridable for local testing (BLINDSBAZAAR_API_URL); everything else comes
|
|
6
|
+
from the server, so prices/policies can never drift from what the site
|
|
7
|
+
actually charges.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
import os
|
|
13
|
+
from typing import Any
|
|
14
|
+
|
|
15
|
+
import httpx
|
|
16
|
+
|
|
17
|
+
DEFAULT_API_URL = "https://api.blindsbazaar.in/api/v1"
|
|
18
|
+
DEFAULT_SITE_URL = "https://blindsbazaar.in"
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class BbApiError(RuntimeError):
|
|
22
|
+
"""A request the API rejected — surfaced to the MCP client verbatim."""
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def api_base() -> str:
|
|
26
|
+
return (os.environ.get("BLINDSBAZAAR_API_URL") or DEFAULT_API_URL).rstrip("/")
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def site_base() -> str:
|
|
30
|
+
return (os.environ.get("BLINDSBAZAAR_SITE_URL") or DEFAULT_SITE_URL).rstrip("/")
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def product_url(slug: str) -> str:
|
|
34
|
+
return f"{site_base()}/product/{slug}/"
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def journal_url(slug: str) -> str:
|
|
38
|
+
return f"{site_base()}/journal/{slug}/"
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class BbClient:
|
|
42
|
+
"""Shared httpx client — one connection pool for the server's lifetime."""
|
|
43
|
+
|
|
44
|
+
def __init__(self) -> None:
|
|
45
|
+
self._http = httpx.Client(base_url=api_base(), timeout=httpx.Timeout(20.0))
|
|
46
|
+
|
|
47
|
+
def get(self, path: str, params: dict[str, Any] | None = None) -> Any:
|
|
48
|
+
return self._request("GET", path, params=params)
|
|
49
|
+
|
|
50
|
+
def post(self, path: str, json_body: dict[str, Any]) -> Any:
|
|
51
|
+
return self._request("POST", path, json=json_body)
|
|
52
|
+
|
|
53
|
+
def _request(self, method: str, path: str, **kwargs: Any) -> Any:
|
|
54
|
+
try:
|
|
55
|
+
response = self._http.request(method, path, **kwargs)
|
|
56
|
+
except httpx.HTTPError as exc:
|
|
57
|
+
raise BbApiError(f"Could not reach the BlindsBazaar API ({api_base()}): {exc}") from exc
|
|
58
|
+
if response.status_code >= 400:
|
|
59
|
+
# Detail payloads are DRF's {"detail": ...} or field errors; pass
|
|
60
|
+
# the useful text through instead of a bare status code.
|
|
61
|
+
try:
|
|
62
|
+
body = response.json()
|
|
63
|
+
except ValueError:
|
|
64
|
+
body = None
|
|
65
|
+
detail = (
|
|
66
|
+
body.get("detail")
|
|
67
|
+
if isinstance(body, dict)
|
|
68
|
+
else (body if isinstance(body, str) else None)
|
|
69
|
+
)
|
|
70
|
+
raise BbApiError(
|
|
71
|
+
f"BlindsBazaar API returned {response.status_code} for {path}"
|
|
72
|
+
+ (f": {detail}" if detail else "")
|
|
73
|
+
)
|
|
74
|
+
if response.status_code == 204 or not response.content:
|
|
75
|
+
return None
|
|
76
|
+
return response.json()
|
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
"""BlindsBazaar MCP server.
|
|
2
|
+
|
|
3
|
+
Exposes the public storefront API to MCP clients as read-only tools:
|
|
4
|
+
catalog search, product detail, the server's authoritative price quote
|
|
5
|
+
(the same quote_blind() the cart charges), taxonomy, configurator options,
|
|
6
|
+
FAQs, journal content and delivery coverage.
|
|
7
|
+
|
|
8
|
+
No secrets, no write access — an assistant can answer real customer
|
|
9
|
+
questions ("what would a 6 ft 3 in × 5 ft 6 in blackout roller for a
|
|
10
|
+
bedroom cost?") against the live catalog without touching anything.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
import logging
|
|
16
|
+
import os
|
|
17
|
+
import re
|
|
18
|
+
from textwrap import dedent
|
|
19
|
+
|
|
20
|
+
from mcp.server.fastmcp import FastMCP
|
|
21
|
+
|
|
22
|
+
from .client import BbApiError, BbClient, journal_url, product_url, site_base
|
|
23
|
+
|
|
24
|
+
_client: BbClient | None = None
|
|
25
|
+
|
|
26
|
+
# HTTP hosting config (BB_MCP_*), read at import: FastMCP passes explicit
|
|
27
|
+
# kwargs straight into its Settings, which override environment variables.
|
|
28
|
+
# stdio mode ignores host/port entirely, so harmless defaults are fine there.
|
|
29
|
+
_HOST = os.environ.get("BB_MCP_HOST", "127.0.0.1")
|
|
30
|
+
_PORT = int(os.environ.get("BB_MCP_PORT", "8817"))
|
|
31
|
+
_PATH = os.environ.get("BB_MCP_PATH", "/mcp")
|
|
32
|
+
_LOOPBACK = _HOST in ("127.0.0.1", "localhost", "::1")
|
|
33
|
+
|
|
34
|
+
mcp = FastMCP(
|
|
35
|
+
"BlindsBazaar",
|
|
36
|
+
instructions=dedent(
|
|
37
|
+
"""
|
|
38
|
+
Tools for the BlindsBazaar online blinds store (blindsbazaar.in) —
|
|
39
|
+
made-to-measure roller and zebra blinds, made in India, delivered
|
|
40
|
+
free pan-India. Use them to look up products, price an exact window
|
|
41
|
+
size, and answer questions from the store's own FAQs and guides.
|
|
42
|
+
|
|
43
|
+
Pricing notes:
|
|
44
|
+
- `quote_blind` calls the store's own pricing engine — its numbers
|
|
45
|
+
are authoritative and match what the checkout charges.
|
|
46
|
+
- Every blind is billed on a minimum area (see get_configurator_options);
|
|
47
|
+
every blind ships with a free installation kit and pelmet, and
|
|
48
|
+
carries a 3-year warranty. Prices include GST.
|
|
49
|
+
- BlindsBazaar sells online only: no installation or site visits
|
|
50
|
+
anywhere. Customers measure themselves (guide / AR tool) and fit
|
|
51
|
+
the blind themselves or with a local carpenter.
|
|
52
|
+
"""
|
|
53
|
+
),
|
|
54
|
+
host=_HOST,
|
|
55
|
+
port=_PORT,
|
|
56
|
+
streamable_http_path=_PATH,
|
|
57
|
+
# A shared public endpoint must be stateless: every request carries its
|
|
58
|
+
# own MCP session, so there's no session affinity to break behind a
|
|
59
|
+
# reverse proxy or load balancer. Local loopback hosting stays stateful
|
|
60
|
+
# (it behaves like any local stdio server).
|
|
61
|
+
stateless_http=not _LOOPBACK,
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
_client: BbClient | None = None
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def _c() -> BbClient:
|
|
68
|
+
global _client
|
|
69
|
+
if _client is None:
|
|
70
|
+
_client = BbClient()
|
|
71
|
+
return _client
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def _product_brief(p: dict) -> dict:
|
|
75
|
+
"""Compact card payload — the list endpoint already shapes this."""
|
|
76
|
+
return {
|
|
77
|
+
"name": p.get("name"),
|
|
78
|
+
"slug": p.get("slug"),
|
|
79
|
+
"url": product_url(p["slug"]),
|
|
80
|
+
"blind_type": p.get("blind_type_name") or p.get("blind_type"),
|
|
81
|
+
"price_per_sqft_inr": p.get("current_price"),
|
|
82
|
+
"regular_price_per_sqft_inr": p.get("base_price"),
|
|
83
|
+
"opacity": p.get("opacity"),
|
|
84
|
+
"material": p.get("material"),
|
|
85
|
+
"color": p.get("color"),
|
|
86
|
+
"rating": p.get("average_rating"),
|
|
87
|
+
"review_count": p.get("review_count"),
|
|
88
|
+
"featured": p.get("is_featured"),
|
|
89
|
+
"bestseller": p.get("is_bestseller"),
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
@mcp.tool()
|
|
94
|
+
def search_products(
|
|
95
|
+
query: str | None = None,
|
|
96
|
+
blind_type: str | None = None,
|
|
97
|
+
room: str | None = None,
|
|
98
|
+
collection: str | None = None,
|
|
99
|
+
opacity: str | None = None,
|
|
100
|
+
max_price_per_sqft: float | None = None,
|
|
101
|
+
limit: int = 10,
|
|
102
|
+
) -> dict:
|
|
103
|
+
"""Search the live BlindsBazaar catalog.
|
|
104
|
+
|
|
105
|
+
Args:
|
|
106
|
+
query: free-text search over name, SKU and descriptions (e.g. "blackout",
|
|
107
|
+
"zebra", a colour or model name).
|
|
108
|
+
blind_type: filter by blind type slug — "roller-blinds" or "zebra-blinds".
|
|
109
|
+
room: filter by room slug (e.g. "bedroom", "kitchen") — see list_rooms.
|
|
110
|
+
collection: filter by collection slug — see list_collections.
|
|
111
|
+
opacity: filter by opacity slug (e.g. "blackout", "sunscreen", "sheer").
|
|
112
|
+
max_price_per_sqft: only products at or below this ₹/sq ft rate.
|
|
113
|
+
limit: max results to return (1–20).
|
|
114
|
+
"""
|
|
115
|
+
limit = max(1, min(int(limit), 20))
|
|
116
|
+
params: dict[str, object] = {"page_size": limit, "channel": "web"}
|
|
117
|
+
if query:
|
|
118
|
+
params["search"] = query
|
|
119
|
+
if blind_type:
|
|
120
|
+
params["blind_type"] = blind_type
|
|
121
|
+
if room:
|
|
122
|
+
params["room"] = room
|
|
123
|
+
if collection:
|
|
124
|
+
params["collection"] = collection
|
|
125
|
+
if opacity:
|
|
126
|
+
params["opacity"] = opacity
|
|
127
|
+
if max_price_per_sqft is not None:
|
|
128
|
+
params["max_price"] = max_price_per_sqft
|
|
129
|
+
data = _c().get("/products/", params=params)
|
|
130
|
+
results = data.get("results", data) if isinstance(data, dict) else data
|
|
131
|
+
return {
|
|
132
|
+
"count": data.get("count") if isinstance(data, dict) else len(results),
|
|
133
|
+
"products": [_product_brief(p) for p in results[:limit]],
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
@mcp.tool()
|
|
138
|
+
def get_product(slug: str) -> dict:
|
|
139
|
+
"""Full detail for one product: prices, size ranges, materials, photos,
|
|
140
|
+
colourways (variants) and the storefront URL. Pass the `slug` from
|
|
141
|
+
search_products, or call list_blind_types + search to find slugs."""
|
|
142
|
+
p = _c().get(f"/products/{slug}/")
|
|
143
|
+
images = [
|
|
144
|
+
i["asset"]["url"]
|
|
145
|
+
for i in (p.get("images") or [])
|
|
146
|
+
if i.get("asset", {}).get("url")
|
|
147
|
+
]
|
|
148
|
+
primary = p.get("primary_image") or {}
|
|
149
|
+
if primary.get("url") and primary["url"] not in images:
|
|
150
|
+
images.insert(0, primary["url"])
|
|
151
|
+
return {
|
|
152
|
+
"name": p.get("name"),
|
|
153
|
+
"slug": p.get("slug"),
|
|
154
|
+
"url": product_url(p["slug"]),
|
|
155
|
+
"blind_type": (p.get("blind_type_detail") or {}).get("name") or p.get("blind_type"),
|
|
156
|
+
"price_per_sqft_inr": p.get("current_price"),
|
|
157
|
+
"regular_price_per_sqft_inr": p.get("base_price"),
|
|
158
|
+
"sale_price_per_sqft_inr": p.get("sale_price") or None,
|
|
159
|
+
"discount_percent": p.get("discount_percentage"),
|
|
160
|
+
"material": p.get("material"),
|
|
161
|
+
"opacity": p.get("opacity"),
|
|
162
|
+
"color": p.get("color"),
|
|
163
|
+
"short_description": p.get("short_description"),
|
|
164
|
+
"features": p.get("features") or [],
|
|
165
|
+
"specifications": p.get("specifications") or {},
|
|
166
|
+
"width_range_ft": [p.get("min_width_ft"), p.get("max_width_ft")],
|
|
167
|
+
"height_range_ft": [p.get("min_height_ft"), p.get("max_height_ft")],
|
|
168
|
+
"variants": [
|
|
169
|
+
{
|
|
170
|
+
"name": v.get("name"),
|
|
171
|
+
"slug": v.get("slug"),
|
|
172
|
+
"price_delta_per_sqft_inr": v.get("price_delta_per_sqft"),
|
|
173
|
+
"in_stock": v.get("is_active"),
|
|
174
|
+
}
|
|
175
|
+
for v in (p.get("variants") or [])
|
|
176
|
+
if v.get("is_active")
|
|
177
|
+
],
|
|
178
|
+
"images": images[:8],
|
|
179
|
+
"average_rating": p.get("average_rating"),
|
|
180
|
+
"review_count": p.get("review_count"),
|
|
181
|
+
"motorizable": (p.get("blind_type_detail") or {}).get("motorizable"),
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
@mcp.tool()
|
|
186
|
+
def quote_blind(
|
|
187
|
+
product: str,
|
|
188
|
+
width_ft: int,
|
|
189
|
+
height_ft: int,
|
|
190
|
+
width_in: int = 0,
|
|
191
|
+
height_in: int = 0,
|
|
192
|
+
variant: str | None = None,
|
|
193
|
+
fabric: str | None = None,
|
|
194
|
+
control: str | None = None,
|
|
195
|
+
mount: str | None = None,
|
|
196
|
+
quantity: int = 1,
|
|
197
|
+
) -> dict:
|
|
198
|
+
"""Price a made-to-measure blind for an exact window size, using the
|
|
199
|
+
store's own pricing engine — the same quote the checkout charges.
|
|
200
|
+
|
|
201
|
+
Args:
|
|
202
|
+
product: product slug (from search_products / get_product).
|
|
203
|
+
width_ft/width_in: window width in feet + extra inches (6 ft 3 in →
|
|
204
|
+
width_ft=6, width_in=3). Inches are 0–11.
|
|
205
|
+
height_ft/height_in: window height the same way.
|
|
206
|
+
variant: colourway slug (from get_product's variants) — some cost
|
|
207
|
+
more per sq ft than the base rate.
|
|
208
|
+
fabric: premium fabric grade slug (see get_configurator_options).
|
|
209
|
+
control: "manual-chain" or a motorised option slug.
|
|
210
|
+
mount: mounting option slug (e.g. inside/outside mount deltas).
|
|
211
|
+
quantity: number of identical windows (1–99).
|
|
212
|
+
"""
|
|
213
|
+
payload = {
|
|
214
|
+
"product": product,
|
|
215
|
+
"width_ft": width_ft,
|
|
216
|
+
"width_in": width_in,
|
|
217
|
+
"height_ft": height_ft,
|
|
218
|
+
"height_in": height_in,
|
|
219
|
+
"quantity": quantity,
|
|
220
|
+
}
|
|
221
|
+
for key in ("variant", "fabric", "control", "mount"):
|
|
222
|
+
value = locals()[key]
|
|
223
|
+
if value:
|
|
224
|
+
payload[key] = value
|
|
225
|
+
quote = _c().post("/configurator/quote/", payload)
|
|
226
|
+
return {
|
|
227
|
+
"product": quote.get("product"),
|
|
228
|
+
"variant": quote.get("variant"),
|
|
229
|
+
"window_size": f"{width_ft} ft {width_in} in × {height_ft} ft {height_in} in",
|
|
230
|
+
"actual_area_sqft": quote.get("area"),
|
|
231
|
+
"billable_area_sqft": quote.get("billable_area"),
|
|
232
|
+
"per_window_inr": quote.get("per_window"),
|
|
233
|
+
"quantity": quote.get("quantity"),
|
|
234
|
+
"total_inr": quote.get("total"),
|
|
235
|
+
"notes": (
|
|
236
|
+
"GST included. Billed on at least the store's minimum area "
|
|
237
|
+
"(see get_configurator_options). Free installation kit and pelmet "
|
|
238
|
+
"included with every blind; 3-year warranty; free delivery "
|
|
239
|
+
"pan-India. Self-fit — no installation visits. Order at "
|
|
240
|
+
f"{site_base()}/product/{product}/"
|
|
241
|
+
),
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
@mcp.tool()
|
|
246
|
+
def list_blind_types() -> dict:
|
|
247
|
+
"""The blind types the store sells (roller, zebra, …) with each type's
|
|
248
|
+
rate card: ₹/sq ft, minimum charge per blind, and whether it can be
|
|
249
|
+
motorised. Product-specific rates may differ — quote_blind is exact."""
|
|
250
|
+
data = _c().get("/catalog/blind-types/", params={"page_size": 50})
|
|
251
|
+
results = data.get("results", data) if isinstance(data, dict) else data
|
|
252
|
+
return {
|
|
253
|
+
"blind_types": [
|
|
254
|
+
{
|
|
255
|
+
"name": t.get("name"),
|
|
256
|
+
"slug": t.get("slug"),
|
|
257
|
+
"base_rate_per_sqft_inr": t.get("rate_per_sqft"),
|
|
258
|
+
"min_charge_per_blind_inr": t.get("min_charge"),
|
|
259
|
+
"motorizable": t.get("motorizable"),
|
|
260
|
+
}
|
|
261
|
+
for t in results
|
|
262
|
+
]
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
@mcp.tool()
|
|
267
|
+
def list_rooms() -> dict:
|
|
268
|
+
"""Rooms the catalog is organised by (bedroom, kitchen, office…), with
|
|
269
|
+
slugs usable as search_products' room filter and storefront URLs."""
|
|
270
|
+
data = _c().get("/catalog/rooms/", params={"page_size": 50})
|
|
271
|
+
results = data.get("results", data) if isinstance(data, dict) else data
|
|
272
|
+
return {
|
|
273
|
+
"rooms": [
|
|
274
|
+
{
|
|
275
|
+
"name": r.get("name"),
|
|
276
|
+
"slug": r.get("slug"),
|
|
277
|
+
"url": f"{site_base()}/rooms/{r['slug']}/",
|
|
278
|
+
}
|
|
279
|
+
for r in results
|
|
280
|
+
]
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
@mcp.tool()
|
|
285
|
+
def list_collections() -> dict:
|
|
286
|
+
"""Curated collections (themed product groupings), with slugs usable as
|
|
287
|
+
search_products' collection filter and storefront URLs."""
|
|
288
|
+
data = _c().get("/catalog/collections/", params={"page_size": 50})
|
|
289
|
+
results = data.get("results", data) if isinstance(data, dict) else data
|
|
290
|
+
return {
|
|
291
|
+
"collections": [
|
|
292
|
+
{
|
|
293
|
+
"name": c.get("name"),
|
|
294
|
+
"slug": c.get("slug"),
|
|
295
|
+
"description": c.get("description"),
|
|
296
|
+
"url": f"{site_base()}/collections/{c['slug']}/",
|
|
297
|
+
}
|
|
298
|
+
for c in results
|
|
299
|
+
]
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
@mcp.tool()
|
|
304
|
+
def get_configurator_options() -> dict:
|
|
305
|
+
"""Everything the configurator offers: the minimum billable area, and
|
|
306
|
+
the fabric grades / control options / mount options with their ₹ add-ons.
|
|
307
|
+
The option slugs feed quote_blind's fabric/control/mount arguments."""
|
|
308
|
+
options = _c().get("/configurator/options/")
|
|
309
|
+
return {
|
|
310
|
+
"pricing": options.get("pricing"),
|
|
311
|
+
"fabric_grades": [
|
|
312
|
+
{"name": f.get("name"), "slug": f.get("slug"), "extra_per_sqft_inr": f.get("delta_per_sqft")}
|
|
313
|
+
for f in (options.get("fabric_grades") or [])
|
|
314
|
+
],
|
|
315
|
+
"control_options": [
|
|
316
|
+
{"name": c.get("name"), "slug": c.get("slug"), "add_on_inr": c.get("add_on"), "motorised": c.get("is_motorised")}
|
|
317
|
+
for c in (options.get("control_options") or [])
|
|
318
|
+
],
|
|
319
|
+
"mount_options": [
|
|
320
|
+
{"name": m.get("name"), "slug": m.get("slug"), "delta_inr": m.get("delta")}
|
|
321
|
+
for m in (options.get("mount_options") or [])
|
|
322
|
+
],
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
@mcp.tool()
|
|
327
|
+
def search_faqs(query: str | None = None, limit: int = 8) -> dict:
|
|
328
|
+
"""Search the store's published FAQs (pricing, measuring, delivery,
|
|
329
|
+
warranty, per-city questions). Answers are the store's own wording —
|
|
330
|
+
quote them rather than paraphrasing policy."""
|
|
331
|
+
params: dict[str, object] = {}
|
|
332
|
+
if query:
|
|
333
|
+
params["search"] = query
|
|
334
|
+
data = _c().get("/content/faqs/", params=params)
|
|
335
|
+
items = data if isinstance(data, list) else data.get("results", [])
|
|
336
|
+
if query:
|
|
337
|
+
# The endpoint searches; but keep a client-side guard so a short
|
|
338
|
+
# query never floods the context with the whole FAQ list.
|
|
339
|
+
needle = query.lower()
|
|
340
|
+
items = [
|
|
341
|
+
f
|
|
342
|
+
for f in items
|
|
343
|
+
if needle in f.get("question", "").lower() or needle in f.get("answer", "").lower()
|
|
344
|
+
]
|
|
345
|
+
return {
|
|
346
|
+
"count": len(items),
|
|
347
|
+
"faqs": [
|
|
348
|
+
{"question": f.get("question"), "answer": f.get("answer"), "group": f.get("group")}
|
|
349
|
+
for f in items[: max(1, min(int(limit), 20))]
|
|
350
|
+
],
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
def _strip_html(html: str) -> str:
|
|
355
|
+
"""Journal bodies are rich text (p/h2/li). Strip tags but keep headings
|
|
356
|
+
and list markers so the text stays skimmable in a chat transcript."""
|
|
357
|
+
text = re.sub(r"<h2[^>]*>", "\n## ", html or "")
|
|
358
|
+
text = re.sub(r"<li[^>]*>", "\n- ", text)
|
|
359
|
+
text = re.sub(r"</?(?:p|div|ul|ol|h[1-6]|strong|em|a|span|br)[^>]*>", "", text)
|
|
360
|
+
text = re.sub(r"<[^>]+>", "", text)
|
|
361
|
+
text = re.sub(r"\n{3,}", "\n\n", text)
|
|
362
|
+
return text.strip()
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
@mcp.tool()
|
|
366
|
+
def search_journal(query: str | None = None, category: str | None = None, limit: int = 8) -> dict:
|
|
367
|
+
"""Search the BlindsBazaar Journal — buying guides, care guides, design
|
|
368
|
+
ideas and per-city guides published on the storefront. Returns title,
|
|
369
|
+
excerpt and URL; use get_journal_story for the full text."""
|
|
370
|
+
params: dict[str, object] = {"page_size": max(1, min(int(limit), 20))}
|
|
371
|
+
if query:
|
|
372
|
+
params["search"] = query
|
|
373
|
+
if category:
|
|
374
|
+
params["category"] = category
|
|
375
|
+
data = _c().get("/content/stories/", params=params)
|
|
376
|
+
results = data.get("results", data) if isinstance(data, dict) else data
|
|
377
|
+
return {
|
|
378
|
+
"count": data.get("count") if isinstance(data, dict) else len(results),
|
|
379
|
+
"stories": [
|
|
380
|
+
{
|
|
381
|
+
"title": s.get("name"),
|
|
382
|
+
"slug": s.get("slug"),
|
|
383
|
+
"url": journal_url(s["slug"]),
|
|
384
|
+
"category": s.get("category"),
|
|
385
|
+
"excerpt": s.get("excerpt"),
|
|
386
|
+
"published": s.get("published_at"),
|
|
387
|
+
"read_minutes": s.get("read_minutes"),
|
|
388
|
+
}
|
|
389
|
+
for s in results
|
|
390
|
+
],
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
@mcp.tool()
|
|
395
|
+
def get_journal_story(slug: str) -> dict:
|
|
396
|
+
"""Full text of one Journal article (slug from search_journal). Rich
|
|
397
|
+
markup is converted to plain text with ## headings and - bullets."""
|
|
398
|
+
s = _c().get(f"/content/stories/{slug}/")
|
|
399
|
+
return {
|
|
400
|
+
"title": s.get("name"),
|
|
401
|
+
"url": journal_url(s["slug"]),
|
|
402
|
+
"category": s.get("category"),
|
|
403
|
+
"excerpt": s.get("excerpt"),
|
|
404
|
+
"published": s.get("published_at"),
|
|
405
|
+
"read_minutes": s.get("read_minutes"),
|
|
406
|
+
"pull_quote": s.get("pull_quote"),
|
|
407
|
+
"body_text": _strip_html(s.get("body") or ""),
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
@mcp.tool()
|
|
412
|
+
def delivery_coverage() -> dict:
|
|
413
|
+
"""Where BlindsBazaar delivers and how orders arrive. Free delivery to
|
|
414
|
+
every pin code in India; made to measure at the Mangolpuri, New Delhi
|
|
415
|
+
workshop in 7–21 days, delivered 3–10 days after dispatch with a free
|
|
416
|
+
fitting kit for self-installation (no installation or site-visit
|
|
417
|
+
service anywhere)."""
|
|
418
|
+
cities = [
|
|
419
|
+
"Delhi NCR", "Mumbai", "Bangalore", "Hyderabad", "Chennai", "Kolkata",
|
|
420
|
+
"Pune", "Ahmedabad", "Jaipur", "Lucknow", "Chandigarh",
|
|
421
|
+
]
|
|
422
|
+
return {
|
|
423
|
+
"delivery": "Free delivery to every pin code in India",
|
|
424
|
+
"making_time_days": "7–21 (made to measure at the Mangolpuri, New Delhi workshop)",
|
|
425
|
+
"transit_time_days": "3–10 after dispatch",
|
|
426
|
+
"installation": "Not offered — every blind ships with a free fitting kit for self-installation (or use a local carpenter)",
|
|
427
|
+
"city_guides": [f"{site_base()}/blinds-in/{slug}/" for slug in
|
|
428
|
+
["delhi", "mumbai", "bangalore", "hyderabad", "chennai",
|
|
429
|
+
"kolkata", "pune", "ahmedabad", "jaipur", "lucknow", "chandigarh"]],
|
|
430
|
+
"featured_cities": cities,
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
def main() -> None:
|
|
435
|
+
"""Entry point.
|
|
436
|
+
|
|
437
|
+
Default: stdio (the transport Claude Desktop / Claude Code / Cursor / pi
|
|
438
|
+
launch themselves). Set BB_MCP_TRANSPORT=streamable-http to instead run
|
|
439
|
+
a hosted HTTP endpoint — nothing for end users to install, they add the
|
|
440
|
+
URL. Bind BB_MCP_HOST=127.0.0.1 (default) and put nginx in front.
|
|
441
|
+
"""
|
|
442
|
+
# httpx logs every request at INFO; on stdio that noise goes to stderr,
|
|
443
|
+
# which MCP clients surface as server logs. Keep the default quiet.
|
|
444
|
+
logging.getLogger("httpx").setLevel(logging.WARNING)
|
|
445
|
+
logging.getLogger("httpcore").setLevel(logging.WARNING)
|
|
446
|
+
transport = os.environ.get("BB_MCP_TRANSPORT", "stdio").strip().lower()
|
|
447
|
+
if transport == "stdio":
|
|
448
|
+
mcp.run()
|
|
449
|
+
elif transport == "streamable-http":
|
|
450
|
+
mcp.run(transport="streamable-http")
|
|
451
|
+
else:
|
|
452
|
+
raise SystemExit(f"Unknown BB_MCP_TRANSPORT: {transport!r} (use stdio or streamable-http)")
|
|
453
|
+
|
|
454
|
+
|
|
455
|
+
if __name__ == "__main__":
|
|
456
|
+
main()
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: blindsbazaar-mcp
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Read-only MCP server for the BlindsBazaar storefront: live catalog, authoritative window-price quotes, FAQs, buying guides and delivery info.
|
|
5
|
+
Project-URL: Homepage, https://blindsbazaar.in/mcp/
|
|
6
|
+
Project-URL: Repository, https://github.com/Kumar-vikalp/blindsbazaar
|
|
7
|
+
Project-URL: Issues, https://github.com/Kumar-vikalp/blindsbazaar/issues
|
|
8
|
+
Author: BlindsBazaar
|
|
9
|
+
License: MIT
|
|
10
|
+
Keywords: blinds,blindsbazaar,e-commerce,llm-tools,mcp,model-context-protocol
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
19
|
+
Requires-Python: >=3.11
|
|
20
|
+
Requires-Dist: httpx>=0.27
|
|
21
|
+
Requires-Dist: mcp<2,>=1.2.0
|
|
22
|
+
Requires-Dist: uvicorn>=0.30
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
|
|
25
|
+
# BlindsBazaar MCP server
|
|
26
|
+
|
|
27
|
+
A [Model Context Protocol](https://modelcontextprotocol.io) server that exposes the
|
|
28
|
+
BlindsBazaar storefront — live catalog, authoritative pricing, FAQs, journal content and
|
|
29
|
+
delivery policies — to MCP clients (Claude Desktop, Claude Code, Codex CLI, Cursor, ChatGPT
|
|
30
|
+
connectors, pi, …).
|
|
31
|
+
|
|
32
|
+
**Distributed without sharing any source code.** Consumers get one of:
|
|
33
|
+
|
|
34
|
+
1. **The hosted URL** (recommended) — `https://api.blindsbazaar.in/mcp` (Streamable HTTP).
|
|
35
|
+
Nothing to install; see `deploy/HOSTING.md` for the systemd + nginx setup.
|
|
36
|
+
2. **The PyPI package** — `pip install blindsbazaar-mcp` / `uvx blindsbazaar-mcp`.
|
|
37
|
+
Publish with the included GitHub Actions workflow (see below).
|
|
38
|
+
|
|
39
|
+
No secrets ship with either: every tool calls the public storefront API, and there is
|
|
40
|
+
**no write access** — no tool can place orders, edit products or touch accounts.
|
|
41
|
+
|
|
42
|
+
## Tools
|
|
43
|
+
|
|
44
|
+
| Tool | What it does |
|
|
45
|
+
|---|---|
|
|
46
|
+
| `search_products` | Search/filter the catalog (text, blind type, room, collection, opacity, price cap) |
|
|
47
|
+
| `get_product` | Full detail: prices, size ranges, materials, photos, colourways, ratings |
|
|
48
|
+
| `quote_blind` | Price an exact window size — calls the store's own pricing engine (the same one checkout charges) |
|
|
49
|
+
| `list_blind_types` | Blind types + rate card (₹/sq ft, minimum charge, motorizable) |
|
|
50
|
+
| `list_rooms` / `list_collections` | Taxonomy slugs for filtering, plus storefront URLs |
|
|
51
|
+
| `get_configurator_options` | Minimum billable area + fabric/control/mount options with ₹ add-ons |
|
|
52
|
+
| `search_faqs` / `search_journal` / `get_journal_story` | The store's own FAQs and buying guides |
|
|
53
|
+
| `delivery_coverage` | Where/how orders are delivered, making + transit times, self-install policy |
|
|
54
|
+
|
|
55
|
+
## Run it
|
|
56
|
+
|
|
57
|
+
**Hosted (no install for consumers):** point the client at the URL —
|
|
58
|
+
`https://api.blindsbazaar.in/mcp`. Hosting setup: [`deploy/HOSTING.md`](deploy/HOSTING.md).
|
|
59
|
+
|
|
60
|
+
**Local stdio (for Claude Desktop / Claude Code / pi / Cursor):**
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
uvx blindsbazaar-mcp # once published to PyPI
|
|
64
|
+
# or, from this folder:
|
|
65
|
+
uv run blindsbazaar-mcp
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
| Variable | Default | Purpose |
|
|
69
|
+
|---|---|---|
|
|
70
|
+
| `BLINDSBAZAAR_API_URL` | `https://api.blindsbazaar.in/api/v1` | Point at a local backend (`http://localhost:8001/api/v1`) while developing |
|
|
71
|
+
| `BLINDSBAZAAR_SITE_URL` | `https://blindsbazaar.in` | Base used for the page URLs returned in tool output |
|
|
72
|
+
| `BB_MCP_TRANSPORT` | `stdio` | `streamable-http` to host |
|
|
73
|
+
| `BB_MCP_HOST` / `BB_MCP_PORT` / `BB_MCP_PATH` | `127.0.0.1` / `8817` / `/mcp` | HTTP hosting bind |
|
|
74
|
+
|
|
75
|
+
## Client configuration
|
|
76
|
+
|
|
77
|
+
**Claude Code:** `claude mcp add --transport http blindsbazaar https://api.blindsbazaar.in/mcp`
|
|
78
|
+
(or stdio: `claude mcp add blindsbazaar -- uvx blindsbazaar-mcp`)
|
|
79
|
+
|
|
80
|
+
**Codex CLI** (`~/.codex/config.toml`):
|
|
81
|
+
|
|
82
|
+
```toml
|
|
83
|
+
[mcp_servers.blindsbazaar]
|
|
84
|
+
url = "https://api.blindsbazaar.in/mcp" # remote; or command/args for stdio
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**Claude Desktop:** Settings → Connectors → Add custom connector → the URL
|
|
88
|
+
(or the stdio `mcpServers` JSON in `claude_desktop_config.json` — see the
|
|
89
|
+
[storefront setup page](https://blindsbazaar.in/mcp/) for every client).
|
|
90
|
+
|
|
91
|
+
## Get listed in the MCP ecosystem
|
|
92
|
+
|
|
93
|
+
The old `modelcontextprotocol/servers` README list is frozen — it now only hosts
|
|
94
|
+
reference implementations. Discovery happens through the
|
|
95
|
+
**[official MCP Registry](https://registry.modelcontextprotocol.io/)** plus directory
|
|
96
|
+
sites (PulseMCP, Smithery, Glama, mcp.so). This folder ships everything needed:
|
|
97
|
+
|
|
98
|
+
- `server.json` — the registry descriptor (`io.github.Kumar-vikalp/blindsbazaar`,
|
|
99
|
+
the hosted remote URL and the PyPI package). Bump `version` together with `pyproject.toml`.
|
|
100
|
+
- `.github/workflows/publish-mcp.yml` — publishes to PyPI on every `v*` tag
|
|
101
|
+
(PyPI trusted publishing; one-time setup: on pypi.org add a pending publisher —
|
|
102
|
+
Owner `Kumar-vikalp`, repo `blindsbazaar`, workflow `publish-mcp.yml`,
|
|
103
|
+
environment `pypi`).
|
|
104
|
+
|
|
105
|
+
Steps:
|
|
106
|
+
|
|
107
|
+
1. **Publish to PyPI** — `git tag v0.1.0 && git push origin v0.1.0` (after the one-time
|
|
108
|
+
trusted-publisher setup), or `cd mcp && uv build --wheel && uv publish` locally.
|
|
109
|
+
2. **Submit to the official registry** — sign in at registry.modelcontextprotocol.io
|
|
110
|
+
with GitHub and submit `server.json`. Note: `io.github.*` names are validated against
|
|
111
|
+
the GitHub repo — if this repo becomes private, prove domain control instead and
|
|
112
|
+
register under the blindsbazaar.in name.
|
|
113
|
+
3. **Optional directories** — PulseMCP, Smithery and Glama accept community submissions
|
|
114
|
+
and are how most users browse; submit the same descriptor there.
|
|
115
|
+
|
|
116
|
+
## Architecture notes
|
|
117
|
+
|
|
118
|
+
- **Read-only by design.** There is deliberately no order/account tool: those endpoints need
|
|
119
|
+
customer tokens and would turn a chat assistant into something that can spend money. If that
|
|
120
|
+
is ever wanted, it should be a separate, authenticated, opt-in server.
|
|
121
|
+
- **Pricing is never reimplemented client-side.** `quote_blind` POSTs to
|
|
122
|
+
`/api/v1/configurator/quote/` — the endpoint the storefront configurator uses — so the cart,
|
|
123
|
+
the site and this server can never quote different numbers.
|
|
124
|
+
- The hosted HTTP endpoint is **stateless** and proxies only public data; `deploy/HOSTING.md`
|
|
125
|
+
includes an nginx rate-limit block so a script can't hammer the API through it.
|
|
126
|
+
- **Source-visibility note:** a PyPI *wheel* contains readable Python; the package ships only
|
|
127
|
+
this thin public-API wrapper — no backend, CRM or business code. The hosted URL is the
|
|
128
|
+
distribution mode that shares nothing at all.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
blindsbazaar_mcp/__init__.py,sha256=EGGvje0vpL9b_2niX62NE0_cAjo_nJhphVTDtPv0xzY,39
|
|
2
|
+
blindsbazaar_mcp/client.py,sha256=WK8ZUiG_QNy5HtbUkMFAijZ0BKn42WXFBGHTv2-Av9s,2599
|
|
3
|
+
blindsbazaar_mcp/server.py,sha256=Dke-MSZ7dCupQqYfsMhKwO-LqNEFR3onzFCZ4EgxM9c,17816
|
|
4
|
+
blindsbazaar_mcp-0.1.0.dist-info/METADATA,sha256=vZJLPzi9jbOhY3JFdvYWqusQO-vzk3Q2Fg_YkDBnEpE,6569
|
|
5
|
+
blindsbazaar_mcp-0.1.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
6
|
+
blindsbazaar_mcp-0.1.0.dist-info/entry_points.txt,sha256=UOUC1oSFOLEuUaIrtrCeupiQlaibpbQXOT-lSkS5iOA,66
|
|
7
|
+
blindsbazaar_mcp-0.1.0.dist-info/RECORD,,
|