MCP Server added#90
Merged
Merged
Conversation
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Introduces an MCP server for OpenTryOn, built on FastMCP 3.x, that makes every model in the toolkit — Virtual Try-On, Image Generation/Editing, Video Generation, Multimodal Understanding (Kimi, LLaVA-NeXT), and Background Removal — available as an MCP tool for agents in Claude Desktop, Cursor, or any other MCP client.
Rather than hand-writing a wrapper function + JSON schema per model, tools are generated dynamically from the same
tryon.cli.registrydata that powers theopentryonCLI. This produces 27 tools at launch and means any model added to the registry going forward shows up as an MCP tool automatically, with zero MCP-server changes required.Related Issue
#89
Type of Change
Component Affected
Changes Made
mcp-server/on FastMCP 3.4+ with a data-driven design from the ground up: no hand-written per-modelTool()definitions or manual dispatch chainmcp-server/server.py: dynamically builds one MCP tool per(service, model)pair straight fromtryon.cli.registry.SERVICES— realinspect.Signatures are generated per model (correct types,Literal[...]enums forchoices, required/optional fields) so FastMCP produces accurate JSON schemas with no hand-written duplicationtryon.cli.runner.invoke_model(): a kwargs-based, non-argv sibling ofrun_service(), shared by both the CLI and the MCP server so they can never drift apart; always returns a structured{"success": ...}dict instead of raisingrun_service()/_split_kwargs()/ result-saving logic intryon/cli/runner.pyto work off plain dicts so both entry points share the exact same execution path (no behavior change for the CLI)list_opentryon_tools()(per-model tool name, required env vars, live configured/not-configured status) andopentryon_status()(human-readable readiness report), both generated from the registry so they can't go staledry_run(preview the resolved adapter call, no API/GPU cost) andoutput_dir, matching the CLI's--dry-run/--output-dirflagsmcp-server/config.py: loads the repo's.envand derives per-model readiness from each model'senv_hint, instead of a hand-maintained list of API keysmcp-server/test_server.py: offline test suite (no network/API keys needed) covering registry↔tool parity, schema correctness (required fields,choices→ enum), dry-run calls across all six services, andalt_method_on_imageswitching (veo / sora / luma-video)fastmcpClient-basedexample_usage.pymcp-server/README.md, rootREADME.md, andCHANGELOG.mdTesting
I have tested these changes locally
I have added/updated tests that prove my fix is effective or my feature works
New and existing unit tests pass locally with my changes
Ran
mcp-server/test_server.pyend to end: 29 tools registered (27 models + 2 discovery tools), every registry model has a matching tool, schemas have correct required/optional fields andchoices→ enum, dry-run calls resolve correctly across vton/generate/edit/understand/video-generate/bg-remove,alt_method_on_imagecorrectly switches to image-to-video only when an image is supplied, and unknown service/model + missing-local-extra cases return structured errors instead of crashingVerified full protocol-level round trips with
fastmcp.Client(in-memory and real stdio subprocess), including a real tool call against the live.envVerified
python server.pyboots cleanly on stdio transportRe-ran the existing
tests/test_cli.pysuite (including a real BFL FLUX VTO API call) after refactoringtryon/cli/runner.pyto confirm zero behavior change on the CLI sideTest Environment
Checklist
Screenshots / Examples
Additional Notes
Full tool list (grouped by service) and architecture notes are in
mcp-server/README.md.