-
Notifications
You must be signed in to change notification settings - Fork 48
Add OpenTryOn MCP Server v0.0.1 #77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is being reviewed by Cursor Bugbot
Details
You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
|
|
||
| # Temporary files | ||
| TEMP_DIR = Path("/tmp/opentryon_mcp") | ||
| TEMP_DIR.mkdir(exist_ok=True, parents=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Hardcoded Unix temp path causes Windows import failure
The TEMP_DIR is set to a hardcoded Unix path /tmp/opentryon_mcp and mkdir() is called at class definition time (during module import). This causes two problems: (1) the path is not portable - on Windows, /tmp doesn't exist as a standard temp directory, so the server will attempt to create an incorrect path like C:\tmp\opentryon_mcp; (2) executing mkdir() as a class-level statement means any permission errors or filesystem issues will crash the module import entirely, preventing the server from starting. The temp directory creation could be deferred to first use, and tempfile.gettempdir() provides a cross-platform solution.
| elif mode == "img_ref": | ||
| if not images: | ||
| return {"success": False, "error": "Images required for img_ref mode"} | ||
| image_ref = [{"url": img, "weight": w} for img, w in zip(images, weights or [0.8] * len(images))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Zip truncates images when weights list is shorter
When using img_ref or style_ref modes in the Luma Photon functions, the code uses zip(images, weights or [0.8] * len(images)) to pair images with weights. If a user provides a non-empty weights list that is shorter than images, zip silently truncates to the shorter length, causing some images to be dropped without any warning. For example, with 3 images and 1 weight, only the first image would be processed. The fallback [0.8] * len(images) only triggers when weights is falsy (None or empty list), not when it's a non-empty but incomplete list.
Additional Locations (2)
| "train_size": len(train_images), | ||
| "test_size": len(test_images), | ||
| "num_classes": 10, | ||
| "image_shape": train_images.shape[1:], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Numpy array shape causes JSON serialization failure
The load_fashion_mnist function returns train_images.shape[1:] in the result dictionary. Since Fashion-MNIST data is loaded as numpy arrays, this returns a tuple containing numpy.int64 types rather than native Python integers. When server.py attempts to serialize this result using json.dumps(), it will raise a TypeError because numpy integer types aren't JSON serializable by default. This causes the tool to always fail with a serialization error rather than returning the expected dataset information.
Overview
Complete Model Context Protocol (MCP) server implementation that exposes OpenTryOn's AI-powered fashion tech capabilities to AI agents and applications.
What's Added
Core Implementation
Features
Virtual Try-On (3 providers)
Image Generation (6 models)
Video Generation
Preprocessing Tools
Dataset Loaders
Configuration Improvements
Documentation
Integration Options
Testing & Quality
test_server.py)Files Added
mcp-server/server.py- Main MCP servermcp-server/config.py- Enhanced configuration managementmcp-server/requirements.txt- MCP server dependenciesmcp-server/pyproject.toml- Package configurationmcp-server/test_server.py- Test suitemcp-server/README.md- Complete documentationmcp-server/tools/- Tool implementations (5 files)mcp-server/utils/- Utility modules (2 files)mcp-server/examples/- Usage examples (2 files)Configuration
Minimum required (choose ONE from each):
Optional: Amazon Nova Canvas, Luma AI (video), U2Net (preprocessing)
Ready for Release
Testing
cd mcp-server
python test_server.py # All tests should pass## Integration Example
{
"mcpServers": {
"opentryon": {
"command": "python",
"args": ["/path/to/opentryon/mcp-server/server.py"],
"env": {"PYTHONPATH": "/path/to/opentryon"}
}
}
}---
Part of OpenTryOn v0.0.1 release
bash
cd mcp-server
python test_server.py # All tests should pass
{
Integration Example{ "mcpServers": { "opentryon": { "command": "python", "args": ["/path/to/opentryon/mcp-server/server.py"], "env": {"PYTHONPATH": "/path/to/opentryon"} } }}
Note
Introduces a full MCP server with 17 tools (VTON, image/video gen, preprocessing, datasets), configuration/status reporting, tests, examples, and comprehensive README, plus packaging and version updates.
mcp-server/server.pyregistering 17 tools and routing calls.mcp-server/config.py.virtual_tryon_nova,virtual_tryon_kling,virtual_tryon_segmindintools/virtual_tryon.py.tools/image_gen.py.tools/video_gen.py.segment_garment,extract_garment,segment_humanintools/preprocessing.py.load_fashion_mnist,load_viton_hdintools/datasets.py.utils/.mcp-server/README.mdwith setup, config, APIs, and troubleshooting.examples/.test_server.pycovering config, imports, tool discovery, and structure checks.pyproject.tomlandrequirements.txtfor the MCP server; export script entrypoint.setup.pyversion to0.0.1.Written by Cursor Bugbot for commit 3f4c11d. This will update automatically on new commits. Configure here.