Skip to content

Conversation

@kailashahirwar
Copy link
Collaborator

@kailashahirwar kailashahirwar commented Dec 16, 2025

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

  • ✅ Full MCP protocol-compliant server (700+ lines)
  • ✅ 17 production-ready tools across 5 categories
  • ✅ Modular architecture with clear separation of concerns
  • ✅ Comprehensive error handling and input validation

Features

Virtual Try-On (3 providers)

  • Amazon Nova Canvas (AWS Bedrock)
  • Kling AI (Kolors)
  • Segmind Try-On Diffusion

Image Generation (6 models)

  • Gemini 2.5 Flash & 3 Pro (Nano Banana)
  • FLUX.2 PRO & FLEX (BFL)
  • Luma AI Photon-1 & Photon-Flash-1

Video Generation

  • Luma AI Ray models (Ray 1.6, Ray 2, Ray Flash 2)

Preprocessing Tools

  • Garment segmentation, extraction, human parsing

Dataset Loaders

  • Fashion-MNIST, VITON-HD

Configuration Improvements

  • ✅ Enhanced configuration validation with helpful status messages
  • ✅ Clear distinction between required and optional services
  • ✅ Automatic service status checking on startup
  • ✅ User-friendly error messages and guidance

Documentation

  • ✅ Comprehensive README.md (578 lines) - consolidated from 5 separate docs
  • ✅ Complete API reference for all 17 tools
  • ✅ Quick start guide and installation instructions
  • ✅ Architecture documentation and troubleshooting
  • ✅ Usage examples for all features

Integration Options

  • ✅ Claude Desktop integration (via config file)
  • ✅ Standalone server mode
  • ✅ Programmatic Python API

Testing & Quality

  • ✅ Comprehensive test suite (test_server.py)
  • ✅ Configuration validation
  • ✅ Security best practices (API keys in env vars, path validation)
  • ✅ Example usage scripts

Files Added

  • mcp-server/server.py - Main MCP server
  • mcp-server/config.py - Enhanced configuration management
  • mcp-server/requirements.txt - MCP server dependencies
  • mcp-server/pyproject.toml - Package configuration
  • mcp-server/test_server.py - Test suite
  • mcp-server/README.md - Complete documentation
  • mcp-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):

  • Virtual Try-On: Kling AI OR Segmind
  • Image Generation: Gemini OR FLUX.2

Optional: Amazon Nova Canvas, Luma AI (video), U2Net (preprocessing)

Ready for Release

  • ✅ No credentials exposed (security audit passed)
  • ✅ Version updated to 0.0.1
  • ✅ Documentation complete
  • ✅ Tests passing
  • ✅ Ready for production use

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.

  • Server/Core
    • Add MCP server implementation in mcp-server/server.py registering 17 tools and routing calls.
    • Introduce configuration management and readiness/status reporting in mcp-server/config.py.
  • Tools (17 total)
    • Virtual Try-On (3): virtual_tryon_nova, virtual_tryon_kling, virtual_tryon_segmind in tools/virtual_tryon.py.
    • Image Generation (6): Gemini, FLUX.2, Luma AI adapters in tools/image_gen.py.
    • Video Generation (1): Luma Ray in tools/video_gen.py.
    • Preprocessing (3): segment_garment, extract_garment, segment_human in tools/preprocessing.py.
    • Datasets (2): load_fashion_mnist, load_viton_hd in tools/datasets.py.
  • Utilities
    • Add image I/O and validation helpers in utils/.
  • Docs & Examples
    • Add comprehensive mcp-server/README.md with setup, config, APIs, and troubleshooting.
    • Provide example usage and Claude Desktop config in examples/.
  • Testing
    • Add test_server.py covering config, imports, tool discovery, and structure checks.
  • Packaging
    • Add pyproject.toml and requirements.txt for the MCP server; export script entrypoint.
    • Update root setup.py version to 0.0.1.

Written by Cursor Bugbot for commit 3f4c11d. This will update automatically on new commits. Configure here.

Copy link

@cursor cursor bot left a 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)
Copy link

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.

Fix in Cursor Fix in Web

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))]
Copy link

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)

Fix in Cursor Fix in Web

"train_size": len(train_images),
"test_size": len(test_images),
"num_classes": 10,
"image_shape": train_images.shape[1:],
Copy link

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.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants