mcp-doubao-image-generator 1.0.0
MCP server for Doubao image generation - generates images from text prompts using Doubao's API
Requires Python: >=3.10
Keywords: ai, api, doubao, image-generation, mcp, mcp-doubao-image-generator, text-to-image

# MCP Doubao Image Generator

[English](README.md) | [中文](README-CN.md)

A [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) server that enables AI assistants to generate images from text prompts using configurable API endpoints supporting multiple providers.

## Features

- **Universal Image Generation**: Generate images from text descriptions using configurable API endpoints
- **Multiple Parameters**: Support for size, style, quality, and quantity options
- **Configurable Providers**: Support for various AI image generation services
- **Cross-Platform**: Works on Windows, Linux, and macOS
- **Easy Integration**: Simple configuration for MCP clients

## Installation

### Using uvx (Recommended)

```bash
uvx mcp-doubao-image-generator
```

### Using pip

```bash
pip install mcp-doubao-image-generator
```

### From Source

```bash
git clone https://github.com/aardpro/doubao-image-generator.git
cd mcp-doubao-image-generator
pip install -e .
```

## Configuration

Add the following to your MCP client configuration (e.g., Claude Desktop, Cursor):

### Option 1: Using uvx (Recommended)

```json
{
  "mcpServers": {
    "McpDoubaoImageGenerator": {
      "command": "uvx",
      "args": ["mcp-doubao-image-generator"]
    }
  }
}
```

### Option 2: Using pip-installed command

```json
{
  "mcpServers": {
    "McpDoubaoImageGenerator": {
      "command": "mcp-doubao-image-generator"
    }
  }
}
```

### Option 3: Windows with Unicode Support

For Windows systems, to ensure proper functionality:

```json
{
  "mcpServers": {
    "McpDoubaoImageGenerator": {
      "command": "cmd",
      "args": [
        "/c",
        "chcp 65001 >nul && uvx doubao-image-generator"
      ]
    }
  }
}
```

### Option 4: Linux/macOS with Python module

```json
{
  "mcpServers": {
    "McpDoubaoImageGenerator": {
      "command": "python",
      "args": ["-m", "main"]
    }
  }
}
```

## Available Tools

### `set_config`

Configure API settings for image generation.

**Parameters:**
- `api_url` (string, optional): API endpoint URL for the image generation service
- `default_model` (string, optional): Default model to use for image generation
- `api_key` (string, optional): API key for authentication
- `output_dir` (string, optional): Directory to save generated images (default: './images')

**Example:**
```json
{
  "name": "set_config",
  "arguments": {
    "api_url": "https://api.openai.com/v1",
    "default_model": "dall-e-3",
    "api_key": "your-api-key-here",
    "output_dir": "./images"
  }
}
```

### `generate_image`

Generate an image from text prompt using configured API.

**Parameters:**
- `prompt` (string, required): Text description of the image to generate
- `model` (string, optional): Model to use for generation (overrides default)
- `n` (integer, optional): Number of images to generate (default: 1, max: 10)
- `size` (string, optional): Size of the generated image (default: '1024x1024')
- `style` (string, optional): Style of the generated image (default: 'vivid')
- `quality` (string, optional): Quality of the generated image (default: 'standard')

**Example:**
```json
{
  "name": "generate_image",
  "arguments": {
    "prompt": "A cute柴犬 playing in the park",
    "size": "1024x1024",
    "style": "vivid",
    "n": 1
  }
}
```

## Usage Examples

Once configured, you can ask your AI assistant to:

- "Generate an image of a futuristic cityscape at night"
- "Create an illustration of a fantasy castle surrounded by floating mountains"
- "Make a cartoon-style drawing of a robot reading a book"

## Development

### Setup Development Environment

```bash
git clone https://github.com/aardpro/doubao-image-generator.git
cd mcp-doubao-image-generator
pip install -e ".[dev]"
```

### Run Tests

```bash
pytest
```

### Build Package

```bash
pip install build
python -m build
```

### Publish to PyPI

```bash
pip install twine
twine upload dist/*
```

## Project Structure

```
doubao-image-generator/
├── src/
│   └── main/
│       ├── __init__.py
│       ├── __main__.py
│       └── server.py
├── examples/
│   ├── mcp_config_pip.json
│   ├── mcp_config_uvx.json
│   ├── mcp_config_windows.json
│   └── mcp_config_linux.json
├── pyproject.toml
├── README.md
└── LICENSE
```

## Troubleshooting

### Configuration Issues

Make sure you have configured the API settings using the `set_config` tool first:

```
/set_config api_url: "https://api.openai.com/v1", api_key: "your-api-key-here", default_model: "dall-e-3"
```

### Image Generation Failures

If image generation fails, check that:
1. Your API key is valid and has sufficient credits
2. The prompt is not too long or contains no prohibited content
3. The requested image size is supported by your chosen API provider

## License

MIT License - see [LICENSE](LICENSE) for details.

## Contributing

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