klydo-mcp 0.1.3__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.
klydo/server.py ADDED
@@ -0,0 +1,219 @@
1
+ """
2
+ Klydo MCP Server entry point.
3
+
4
+ This module defines the MCP server and tools for fashion discovery.
5
+ Run with: python -m klydo.server or use the `klydo` command.
6
+
7
+ Usage with Claude Desktop:
8
+ Add to your claude_desktop_config.json:
9
+ {
10
+ "mcpServers": {
11
+ "klydo": {
12
+ "command": "uv",
13
+ "args": ["--directory", "/path/to/klydo-mcp-server", "run", "klydo"]
14
+ }
15
+ }
16
+ }
17
+ """
18
+
19
+ import time
20
+
21
+ from fastmcp import FastMCP
22
+
23
+ from klydo.config import settings
24
+ from klydo.logging import logger, log_request, log_response
25
+ from klydo.models.product import Product, ProductSummary
26
+ from klydo.scrapers import get_scraper
27
+
28
+ # Initialize MCP server
29
+ mcp = FastMCP(
30
+ name="Klydo Fashion",
31
+ instructions="""
32
+ Fashion discovery assistant for Indian Gen Z (18-32 age group).
33
+
34
+ You can help users:
35
+ - Search for fashion products (clothes, shoes, accessories)
36
+ - Get detailed product information with images
37
+ - Find trending/popular fashion items
38
+
39
+ All products include:
40
+ - Multiple images (CDN-hosted, directly viewable)
41
+ - Price with discounts
42
+ - Available sizes and colors
43
+ - Product page links (may not always be accessible)
44
+
45
+ IMPORTANT - When presenting products to users:
46
+ - ALWAYS show image URLs (image_url field) as the primary way to view products
47
+ - Image URLs are direct CDN links that are always accessible and viewable
48
+ - The 'url' field may contain product page links that aren't always accessible
49
+ - For product details, display ALL images from the 'images' array so users can see products from multiple angles
50
+ - Format image URLs as clickable/viewable links for easy access
51
+
52
+ Tips for best results:
53
+ - Use specific search terms like "black cotton dress" or "nike running shoes"
54
+ - Filter by gender (men/women) for better results
55
+ - Use price filters to stay within budget
56
+ """,
57
+ )
58
+
59
+ # Get scraper instance
60
+ _scraper = get_scraper(settings.default_scraper)
61
+
62
+ # Log server startup
63
+ logger.info(
64
+ f"Klydo MCP Server initialized | scraper={settings.default_scraper} | debug={settings.debug}"
65
+ )
66
+
67
+
68
+ @mcp.tool
69
+ async def search_products(
70
+ query: str,
71
+ category: str | None = None,
72
+ gender: str | None = None,
73
+ min_price: int | None = None,
74
+ max_price: int | None = None,
75
+ limit: int = 10,
76
+ ) -> list[ProductSummary]:
77
+ """
78
+ Search for fashion products.
79
+
80
+ Args:
81
+ query: Search terms (e.g., "black dress", "nike shoes", "cotton kurta")
82
+ category: Filter by category (e.g., "dresses", "shoes", "tshirts", "kurtas")
83
+ gender: Filter by gender ("men" or "women")
84
+ min_price: Minimum price in INR (e.g., 500)
85
+ max_price: Maximum price in INR (e.g., 2000)
86
+ limit: Maximum number of results (default 10, max 50)
87
+
88
+ Returns:
89
+ List of matching products with:
90
+ - image_url: Direct CDN link to product image (ALWAYS show this to users to view products)
91
+ - price: Current price with discount information
92
+ - brand: Product brand name
93
+ - name: Product name and description
94
+ - url: Product page link (may not always be accessible; prefer showing image_url)
95
+
96
+ IMPORTANT: When presenting results to users, display the image_url as the primary
97
+ way to view products. These are direct CDN links that are always accessible.
98
+
99
+ Example:
100
+ Search for "floral dress" with max price 1500 for women
101
+ """
102
+ start_time = time.time()
103
+ log_request(
104
+ "search_products",
105
+ query=query,
106
+ category=category,
107
+ gender=gender,
108
+ min_price=min_price,
109
+ max_price=max_price,
110
+ limit=limit,
111
+ )
112
+
113
+ result = await _scraper.search(
114
+ query=query,
115
+ category=category,
116
+ gender=gender,
117
+ min_price=min_price,
118
+ max_price=max_price,
119
+ limit=min(limit, 50),
120
+ )
121
+
122
+ duration_ms = (time.time() - start_time) * 1000
123
+ log_response("search_products", duration_ms, result_count=len(result))
124
+
125
+ return result
126
+
127
+
128
+ @mcp.tool
129
+ async def get_product_details(product_id: str) -> Product | None:
130
+ """
131
+ Get complete product information including all images, sizes, and specifications.
132
+
133
+ Args:
134
+ product_id: The product ID from search results
135
+
136
+ Returns:
137
+ Full product details including:
138
+ - images: Array of ALL product images from multiple angles (CRITICAL: Display ALL these image URLs to users)
139
+ - image_url: Primary product image (also accessible)
140
+ - Available sizes and colors
141
+ - Rating and reviews
142
+ - Full description
143
+ - url: Product page link (may not be accessible; images are the primary viewing method)
144
+
145
+ Returns None if product not found.
146
+
147
+ CRITICAL FOR PRESENTATION:
148
+ When showing product details to users, display ALL image URLs from the 'images' array.
149
+ These are direct CDN links that are always accessible and allow users to view the
150
+ product from multiple angles. The image URLs should be formatted as clickable/viewable
151
+ links. Do NOT rely on the 'url' field for viewing products.
152
+
153
+ Example:
154
+ Get details for product ID "STL_HBIVEZLO78F27UG9AFRL"
155
+ """
156
+ start_time = time.time()
157
+ log_request("get_product_details", product_id=product_id)
158
+
159
+ result = await _scraper.get_product(product_id)
160
+
161
+ duration_ms = (time.time() - start_time) * 1000
162
+ log_response(
163
+ "get_product_details",
164
+ duration_ms,
165
+ found=result is not None,
166
+ product_id=product_id,
167
+ )
168
+
169
+ return result
170
+
171
+
172
+ @mcp.tool
173
+ async def get_trending(
174
+ category: str | None = None,
175
+ limit: int = 10,
176
+ ) -> list[ProductSummary]:
177
+ """
178
+ Get currently trending/popular fashion products.
179
+
180
+ Args:
181
+ category: Optional category filter (e.g., "dresses", "shoes", "tshirts")
182
+ limit: Maximum number of results (default 10, max 50)
183
+
184
+ Returns:
185
+ List of trending products sorted by popularity, each with:
186
+ - image_url: Direct CDN link to product image (ALWAYS show this to users to view products)
187
+ - price: Current price with discount information
188
+ - brand: Product brand name
189
+ - name: Product name and description
190
+ - url: Product page link (may not always be accessible; prefer showing image_url)
191
+
192
+ IMPORTANT: When presenting trending products to users, display the image_url as the
193
+ primary way to view products. These are direct CDN links that are always accessible.
194
+
195
+ Example:
196
+ Get trending shoes, or just "get trending" for all categories
197
+ """
198
+ start_time = time.time()
199
+ log_request("get_trending", category=category, limit=limit)
200
+
201
+ result = await _scraper.get_trending(
202
+ category=category,
203
+ limit=min(limit, 50),
204
+ )
205
+
206
+ duration_ms = (time.time() - start_time) * 1000
207
+ log_response("get_trending", duration_ms, result_count=len(result))
208
+
209
+ return result
210
+
211
+
212
+ def main() -> None:
213
+ """Run the MCP server."""
214
+ logger.info("Starting Klydo MCP Server...")
215
+ mcp.run()
216
+
217
+
218
+ if __name__ == "__main__":
219
+ main()
@@ -0,0 +1,262 @@
1
+ Metadata-Version: 2.4
2
+ Name: klydo-mcp
3
+ Version: 0.1.3
4
+ Summary: Fashion discovery MCP server for Indian Gen Z
5
+ Project-URL: Homepage, https://github.com/myselfshravan/klydo-mcp
6
+ Project-URL: Repository, https://github.com/myselfshravan/klydo-mcp
7
+ Project-URL: Issues, https://github.com/myselfshravan/klydo-mcp/issues
8
+ Author-email: Shravan <shravan@klydo.in>
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Keywords: ai,claude,e-commerce,fashion,india,klydo,mcp,myntra,shopping
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Requires-Python: >=3.11
22
+ Requires-Dist: fastmcp>=2.3.0
23
+ Requires-Dist: httpx>=0.27.0
24
+ Requires-Dist: loguru>=0.7.0
25
+ Requires-Dist: pydantic-settings>=2.0.0
26
+ Requires-Dist: pydantic>=2.0.0
27
+ Requires-Dist: selectolax>=0.3.0
28
+ Provides-Extra: dev
29
+ Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
30
+ Requires-Dist: pytest>=8.0.0; extra == 'dev'
31
+ Description-Content-Type: text/markdown
32
+
33
+ # Klydo MCP Server
34
+
35
+ [![CI](https://github.com/myselfshravan/klydo-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/myselfshravan/klydo-mcp/actions/workflows/ci.yml)
36
+ [![PyPI version](https://badge.fury.io/py/klydo-mcp.svg)](https://badge.fury.io/py/klydo-mcp)
37
+ [![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)
38
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
39
+ [![MCP Compatible](https://img.shields.io/badge/MCP-Compatible-green.svg)](https://modelcontextprotocol.io/)
40
+
41
+ **Fashion discovery MCP server for Indian Gen Z (18-32 age group).**
42
+
43
+ Enables AI assistants like Claude to search and discover fashion products from Indian e-commerce sites. Built by [Klydo](https://klydo.in) โ€” a Bangalore-based startup for Gen-Z quick tech fashion commerce.
44
+
45
+ ## โœจ Features
46
+
47
+ - ๐Ÿ” **Search Products** โ€” Search fashion items with filters (category, gender, price range)
48
+ - ๐Ÿ“ฆ **Product Details** โ€” Get complete product info including images, sizes, colors, ratings
49
+ - ๐Ÿ”ฅ **Trending Products** โ€” Discover what's popular right now
50
+ - ๐Ÿ›’ **Sources** โ€” Built-in scrapers for Myntra and the Klydo brand (klydo.in)
51
+ - ๐Ÿ“ **Structured Logging** โ€” Debug-friendly logs with Loguru
52
+ - โšก **Fast & Cached** โ€” In-memory caching for quick responses
53
+
54
+ ## ๐Ÿš€ Quick Start
55
+
56
+ ### Installation
57
+
58
+ #### Option 1: Install from PyPI (Recommended)
59
+
60
+ ```bash
61
+ # Using pip
62
+ pip install klydo-mcp
63
+
64
+ # Or using pipx (isolated environment)
65
+ pipx install klydo-mcp
66
+
67
+ # Or using uvx (no installation needed)
68
+ uvx klydo-mcp
69
+ ```
70
+
71
+ #### Option 2: Install from Source
72
+
73
+ ```bash
74
+ # Clone the repository
75
+ git clone https://github.com/myselfshravan/klydo-mcp.git
76
+ cd klydo-mcp
77
+
78
+ # Install dependencies with uv
79
+ uv sync
80
+ ```
81
+
82
+ ### Usage with Claude Desktop
83
+
84
+ #### If installed via PyPI (pip/pipx)
85
+
86
+ Add to your Claude Desktop configuration:
87
+ - **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
88
+ - **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
89
+
90
+ ```json
91
+ {
92
+ "mcpServers": {
93
+ "klydo": {
94
+ "command": "klydo"
95
+ }
96
+ }
97
+ }
98
+ ```
99
+
100
+ #### If using uvx (recommended for easy updates)
101
+
102
+ ```json
103
+ {
104
+ "mcpServers": {
105
+ "klydo": {
106
+ "command": "uvx",
107
+ "args": ["klydo-mcp"]
108
+ }
109
+ }
110
+ }
111
+ ```
112
+
113
+ #### If installed from source
114
+
115
+ ```json
116
+ {
117
+ "mcpServers": {
118
+ "klydo": {
119
+ "command": "uv",
120
+ "args": ["--directory", "/path/to/klydo-mcp", "run", "klydo"]
121
+ }
122
+ }
123
+ }
124
+ ```
125
+
126
+ Then restart Claude Desktop.
127
+
128
+ ### Run Standalone
129
+
130
+ ```bash
131
+ uv run klydo
132
+ ```
133
+
134
+ ## ๐Ÿ› ๏ธ MCP Tools
135
+
136
+ ### `search_products`
137
+
138
+ Search for fashion products.
139
+
140
+ | Parameter | Type | Required | Description |
141
+ |-----------|------|----------|-------------|
142
+ | `query` | string | โœ… | Search terms (e.g., "black dress", "nike shoes") |
143
+ | `category` | string | โŒ | Filter by category (e.g., "dresses", "shoes") |
144
+ | `gender` | string | โŒ | Filter by gender ("men" or "women") |
145
+ | `min_price` | int | โŒ | Minimum price in INR |
146
+ | `max_price` | int | โŒ | Maximum price in INR |
147
+ | `limit` | int | โŒ | Max results (default 10, max 50) |
148
+
149
+ ### `get_product_details`
150
+
151
+ Get complete product information.
152
+
153
+ | Parameter | Type | Required | Description |
154
+ |-----------|------|----------|-------------|
155
+ | `product_id` | string | โœ… | Product ID from search results |
156
+
157
+ **Returns:** Full product details including all images, sizes, colors, ratings, and purchase link.
158
+
159
+ ### `get_trending`
160
+
161
+ Get currently trending/popular fashion products.
162
+
163
+ | Parameter | Type | Required | Description |
164
+ |-----------|------|----------|-------------|
165
+ | `category` | string | โŒ | Category filter |
166
+ | `limit` | int | โŒ | Max results (default 10, max 50) |
167
+
168
+ ## โš™๏ธ Configuration
169
+
170
+ Copy `.env.example` to `.env` and customize:
171
+
172
+ ```bash
173
+ # Default scraper: "klydo" or "myntra"
174
+ KLYDO_DEFAULT_SCRAPER=klydo
175
+
176
+ # Request settings
177
+ KLYDO_REQUEST_TIMEOUT=30
178
+ KLYDO_CACHE_TTL=3600
179
+
180
+ # Debug mode (set to false in production)
181
+ KLYDO_DEBUG=false
182
+
183
+ # API token for klydo.in scraper (required for Klydo scraper)
184
+ KLYDO_KLYDO_API_TOKEN=your-token
185
+ ```
186
+
187
+ ## ๐Ÿ“ Project Structure
188
+
189
+ ```text
190
+ klydo-mcp/
191
+ โ”œโ”€โ”€ src/klydo/
192
+ โ”‚ โ”œโ”€โ”€ __init__.py
193
+ โ”‚ โ”œโ”€โ”€ server.py # MCP server entry point
194
+ โ”‚ โ”œโ”€โ”€ config.py # Configuration (Pydantic Settings)
195
+ โ”‚ โ”œโ”€โ”€ logging.py # Loguru configuration
196
+ โ”‚ โ”œโ”€โ”€ models/
197
+ โ”‚ โ”‚ โ””โ”€โ”€ product.py # Product, Price models
198
+ โ”‚ โ””โ”€โ”€ scrapers/
199
+ โ”‚ โ”œโ”€โ”€ base.py # Scraper protocol (interface)
200
+ โ”‚ โ”œโ”€โ”€ cache.py # In-memory cache with TTL
201
+ โ”‚ โ”œโ”€โ”€ klydo_store.py # Klydo.in scraper
202
+ โ”‚ โ””โ”€โ”€ myntra.py # Myntra scraper
203
+ โ”œโ”€โ”€ tests/ # Test suite
204
+ โ”œโ”€โ”€ .github/workflows/ # CI/CD pipelines
205
+ โ”œโ”€โ”€ pyproject.toml
206
+ โ””โ”€โ”€ README.md
207
+ ```
208
+
209
+ ## ๐Ÿงช Testing
210
+
211
+ ```bash
212
+ # Run all tests
213
+ uv run pytest
214
+
215
+ # Run with verbose output
216
+ uv run pytest -v
217
+
218
+ # Run specific test file
219
+ uv run pytest tests/test_models.py
220
+ ```
221
+
222
+ ## ๐Ÿ”ง Development
223
+
224
+ ```bash
225
+ # Install dev dependencies
226
+ uv sync --dev
227
+
228
+ # Run linting
229
+ uv run ruff check src/
230
+
231
+ # Format code
232
+ uv run ruff format src/
233
+
234
+ # Run the server locally
235
+ uv run klydo
236
+ ```
237
+
238
+ ## ๐Ÿค Contributing
239
+
240
+ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
241
+
242
+ 1. Fork the repository
243
+ 2. Create a feature branch (`git checkout -b feature/amazing-feature`)
244
+ 3. Commit your changes (`git commit -m 'Add amazing feature'`)
245
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
246
+ 5. Open a Pull Request
247
+
248
+ ## ๐Ÿ” Security
249
+
250
+ For security issues, please see our [Security Policy](SECURITY.md).
251
+
252
+ ## ๐Ÿ“„ License
253
+
254
+ MIT License โ€” see [LICENSE](LICENSE) for details.
255
+
256
+ ## ๐Ÿข About Klydo
257
+
258
+ [Klydo](https://klydo.in) is a Bangalore-based startup building quick tech fashion commerce for Gen-Z. This MCP server is part of our mission to make fashion discovery seamless across AI interfaces.
259
+
260
+ ---
261
+
262
+ **Made with โค๏ธ in Bangalore, India**
@@ -0,0 +1,16 @@
1
+ klydo/__init__.py,sha256=3OQmIe621dZH9ib_w4dag9FAmQ2eQzHcwUDFWD7ZDdo,216
2
+ klydo/config.py,sha256=t0x9dq2zlZ9PVtzR4qURwNMQmU_wofOZtUJdqm8NMRw,1012
3
+ klydo/logging.py,sha256=ZLJT_be3KDn_AvZXbf3T1VUL9a0f_N7fHpX_gvrPoIk,3270
4
+ klydo/server.py,sha256=Y80V0iu0tED1NhF--5JAGJ1U9o1MQtqsrAp-MDRaOUc,6969
5
+ klydo/models/__init__.py,sha256=q-Nz-bVADv_6xsZlug3bnhRGQ3GPH4PH_ozDhEUo92g,302
6
+ klydo/models/product.py,sha256=MsnctocltK5w4H8qQNs7aTkaQ11U82dg8r9QFcbssl0,3438
7
+ klydo/scrapers/__init__.py,sha256=73ZpqVQpA1RJdafGP2fqi81IdLm3X2gb_HTABdwGXTw,1765
8
+ klydo/scrapers/base.py,sha256=xuECczHL_Euu028YShv4hPzV_9Nf9B3d_0RLrH75MUw,2753
9
+ klydo/scrapers/cache.py,sha256=QbZQ3w9VnK4XmU4rk7KN-Y2-ed8Ci8iC4qF2wLjdtmY,5037
10
+ klydo/scrapers/klydo_store.py,sha256=a1nGgt7pDf-pkRKCiSS5BwA-CgnGIp0PMDNfpgYD-FI,16656
11
+ klydo/scrapers/myntra.py,sha256=D_sUjaWccLrqpnPMVNYYQ8tbrUWsk6ZeejVLeIOM1pk,24576
12
+ klydo_mcp-0.1.3.dist-info/METADATA,sha256=quKbsRWnyHT7OO__jDiV9JO0hALM-sfFK8W37oI1zh8,7302
13
+ klydo_mcp-0.1.3.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
14
+ klydo_mcp-0.1.3.dist-info/entry_points.txt,sha256=gD6x0O0Lcmmpqn60HoCDKXBrLz-NTY883ve_LEOU2RI,44
15
+ klydo_mcp-0.1.3.dist-info/licenses/LICENSE,sha256=CJasrlXAk_f3YoFAqXpD1W6pnRw-SeKvXR-bqySdz1I,1086
16
+ klydo_mcp-0.1.3.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.28.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ klydo = klydo.server:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Klydo MCP Server Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.