Cover image
Try Now
2025-03-07

Server MCP (Protocole de contexte modèle léger basé sur Python pour Comfyui local

3 years

Works with Finder

1

Github Watches

7

Github Forks

29

Github Stars

ComfyUI MCP Server

A lightweight Python-based MCP (Model Context Protocol) server that interfaces with a local ComfyUI instance to generate images programmatically via AI agent requests.

Overview

This project enables AI agents to send image generation requests to ComfyUI using the MCP protocol over WebSocket. It supports:

  • Flexible workflow selection (e.g., basic_api_test.json).
  • Dynamic parameters: prompt, width, height, and model.
  • Returns image URLs served by ComfyUI.

Prerequisites

  • Python 3.10+
  • ComfyUI: Installed and running locally (e.g., on localhost:8188).
  • Dependencies: requests, websockets, mcp (install via pip).

Setup

  1. Clone the Repository: git clone cd comfyui-mcp-server

  2. Install Dependencies:

    pip install requests websockets mcp

  3. Start ComfyUI:

  • Install ComfyUI (see ComfyUI docs).
  • Run it on port 8188:
    cd <ComfyUI_dir>
    python main.py --port 8188
    
  1. Prepare Workflows:
  • Place API-format workflow files (e.g., basic_api_test.json) in the workflows/ directory.
  • Export workflows from ComfyUI’s UI with “Save (API Format)” (enable dev mode in settings).

Usage

  1. Run the MCP Server: python server.py
  • Listens on ws://localhost:9000.
  1. Test with the Client: python client.py
  • Sends a sample request: "a dog wearing sunglasses" with 512x512 using sd_xl_base_1.0.safetensors.
  • Output example:
    Response from server:
    {
      "image_url": "http://localhost:8188/view?filename=ComfyUI_00001_.png&subfolder=&type=output"
    }
    
  1. Custom Requests:
  • Modify client.py’s payload to change prompt, width, height, workflow_id, or model.
  • Example:
    "params": json.dumps({
        "prompt": "a cat in space",
        "width": 768,
        "height": 768,
        "workflow_id": "basic_api_test",
        "model": "v1-5-pruned-emaonly.ckpt"
    })
    

Project Structure

  • server.py: MCP server with WebSocket transport and lifecycle support.
  • comfyui_client.py: Interfaces with ComfyUI’s API, handles workflow queuing.
  • client.py: Test client for sending MCP requests.
  • workflows/: Directory for API-format workflow JSON files.

Notes

  • Ensure your chosen model (e.g., v1-5-pruned-emaonly.ckpt) exists in <ComfyUI_dir>/models/checkpoints/.
  • The MCP SDK lacks native WebSocket transport; this uses a custom implementation.
  • For custom workflows, adjust node IDs in comfyui_client.py’s DEFAULT_MAPPING if needed.

Contributing

Feel free to submit issues or PRs to enhance flexibility (e.g., dynamic node mapping, progress streaming).

License

Apache License

相关推荐

  • NiKole Maxwell
  • I craft unique cereal names, stories, and ridiculously cute Cereal Baby images.

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Beniyam Berhanu
  • Therapist adept at identifying core issues and offering practical advice with images.

  • Khalid kalib
  • Write professional emails

  • https://tovuti.be
  • Oede knorrepot die vasthoudt an de goeie ouwe tied van 't boerenleven

  • INFOLAB OPERATIONS 2
  • A medical specialist offering assistance grounded in clinical guidelines. Disclaimer: This is intended for research and is NOT safe for clinical use!

  • ANGEL LEON
  • A world class elite tech co-founder entrepreneur, expert in software development, entrepreneurship, marketing, coaching style leadership and aligned with ambition for excellence, global market penetration and worldy perspectives.

  • apappascs
  • Découvrez la collection la plus complète et la plus à jour de serveurs MCP sur le marché. Ce référentiel sert de centre centralisé, offrant un vaste catalogue de serveurs MCP open-source et propriétaires, avec des fonctionnalités, des liens de documentation et des contributeurs.

  • ShrimpingIt
  • Manipulation basée sur Micropython I2C de l'exposition GPIO de la série MCP, dérivée d'Adafruit_MCP230XX

  • OffchainLabs
  • Aller la mise en œuvre de la preuve de la participation Ethereum

  • huahuayu
  • Une passerelle API unifiée pour intégrer plusieurs API d'explorateur de blockchain de type étherscan avec la prise en charge du protocole de contexte modèle (MCP) pour les assistants d'IA.

  • deemkeen
  • Contrôlez votre MBOT2 avec un combo d'alimentation: MQTT + MCP + LLM

  • jae-jae
  • MCP Server pour récupérer le contenu de la page Web à l'aide du navigateur sans tête du dramwright.

    Reviews

    1 (1)
    Avatar
    user_gLoTVYp3
    2025-04-15

    I've recently watched the tutorial video by TahaBakhtari on creating an MCP server, and it was incredibly helpful! The instructions were clear and easy to follow, which made the whole process smooth. Highly recommended for anyone looking to set up their own server. You can check it out at: https://mcp.so/server/TorobjoMCP/TahaBakhtari.