Skip to main content

WaveSpeed MCP Server

Project description

WavespeedMCP

WavespeedMCP is a Model Control Protocol (MCP) server implementation for WaveSpeed AI services. It provides a standardized interface for accessing WaveSpeed's image and video generation capabilities through the MCP protocol.

Features

  • Image Generation: Create high-quality images from text prompts or modify existing images
  • Video Generation: Transform static images into dynamic videos with customizable parameters
  • Modular Architecture: Clean, maintainable code structure with clear separation of concerns
  • Robust Error Handling: Comprehensive exception handling and logging
  • Flexible Configuration: Support for environment variables and configuration files

Installation

Prerequisites

Setup

  1. Clone the repository:

    git clone https://github.com/your-organization/wavespeed-mcp.git
    cd wavespeed-mcp
    
  2. Install the package:

    pip install -e .
    
  3. Create a .env file with your API credentials (see .env.example for reference):

    WAVESPEED_API_KEY=your_api_key_here
    WAVESPEED_API_HOST=https://api.wavespeed.ai
    

Usage

Running the Server

Start the WavespeedMCP server:

python -m wavespeed_mcp --api-key your_api_key_here

Or, if installed via pip:

wavespeed-mcp --api-key your_api_key_here

Client Application

Use the included client application to interact with the server:

python -m wavespeed_mcp.client_app --tool generate_image --params '{"prompt": "A beautiful sunset over mountains"}'

Or, if installed via pip:

wavespeed-mcp-client --tool generate_image --params '{"prompt": "A beautiful sunset over mountains"}'

API Reference

Image Generation

Generate images from text descriptions or modify existing images:

from mcp import ClientSession
from mcp.client.stdio import stdio_client
from mcp import StdioServerParameters

async def generate_image():
    server_params = StdioServerParameters(
        command="python",
        args=["-m", "wavespeed_mcp", "--api-key", "your_api_key_here"]
    )
    
    async with stdio_client(server_params) as (read_stream, write_stream):
        async with ClientSession(read_stream, write_stream) as client:
            await client.initialize()
            
            params = {
                "prompt": "A beautiful mountain landscape",
                "size": "1024*1024",
                "num_images": 1
            }
            
            result = await client.call_tool("generate_image", params)
            
            # Process result
            for item in result:
                if item.type == "image":
                    print(f"Generated image URL: {item.url}")

Video Generation

Generate videos from static images:

async def generate_video():
    # ... setup client as above ...
    
    params = {
        "image_url": "https://example.com/image.jpg",
        "prompt": "A scenic landscape with gentle movement",
        "duration": 5
    }
    
    result = await client.call_tool("generate_video", params)
    
    # Process result
    for item in result:
        if item.type == "text":
            print(item.text)  # Contains URL to generated video

Configuration

WavespeedMCP can be configured through:

  1. Environment variables (see .env.example)
  2. Command-line arguments
  3. Configuration file (see wavespeed_mcp_config_demo.json)

Architecture

WavespeedMCP follows a clean, modular architecture:

  • server.py: Core MCP server implementation with tool definitions
  • client.py: API client for communicating with WaveSpeed services
  • utils.py: Helper functions for file handling and other utilities
  • exceptions.py: Custom exception classes for error handling
  • const.py: Constants and default values

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wavespeed_mcp-0.1.1.tar.gz (16.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wavespeed_mcp-0.1.1-py3-none-any.whl (14.7 kB view details)

Uploaded Python 3

File details

Details for the file wavespeed_mcp-0.1.1.tar.gz.

File metadata

  • Download URL: wavespeed_mcp-0.1.1.tar.gz
  • Upload date:
  • Size: 16.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for wavespeed_mcp-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7b28957d19fea806524b81b4259545ae41ae70af64feade6335ebde0e6619980
MD5 ab54acd5b4281f48044d9058cc5020e6
BLAKE2b-256 a7ac00c6442a150c95c5e047a439b471a10b887dab9f9e321bf089782854359a

See more details on using hashes here.

File details

Details for the file wavespeed_mcp-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: wavespeed_mcp-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 14.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for wavespeed_mcp-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d790a1f313f7818373772123786208825c542d46449a43d1418299597abda282
MD5 9d5cf5a271f26b21d89b087a6188438f
BLAKE2b-256 e1e870705b272b045934edb1984f59aa2835b1bac948ad769a3b1251cbe2a66f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page