@flymyai/mcp-server
v1.0.6
Published
FlyMyAI MCP Server for AI image generation with batch support
Maintainers
Readme
@flymyai/mcp-server
MCP (Model Context Protocol) server for FlyMyAI image generation with batch support.
Features
- Single Image Generation - Generate images from text prompts
- Batch Processing - Generate multiple images in parallel with configurable concurrency
- Automatic Retries - Built-in retry logic with exponential backoff
- Rate Limit Handling - Respects API rate limits with automatic backoff
- Comprehensive Logging - Configurable log levels for debugging
- Highly Configurable - Environment variables for all settings
Installation
npm install -g @flymyai/mcp-server
# or
npx @flymyai/mcp-serverQuick Start
Get your API key from FlyMyAI
Set the environment variable:
export FLYMYAI_API_KEY=your-api-key- Run the server:
flymyai-mcpConfiguration with MCP Clients
opencode
Add to your opencode.jsonc:
{
"mcp": {
"flymyai": {
"type": "local",
"command": ["npx", "@flymyai/mcp-server"],
"environment": {
"FLYMYAI_API_KEY": "your-api-key"
}
}
}
}Claude Desktop
Add to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"flymyai": {
"command": "npx",
"args": ["@flymyai/mcp-server"],
"env": {
"FLYMYAI_API_KEY": "your-api-key"
}
}
}
}Available Tools
flymyai_generate
Generate a single image from a text prompt.
Parameters:
| Name | Type | Required | Default | Description |
|------|------|----------|---------|-------------|
| prompt | string | ✅ | - | Text description of the image |
| model | string | | flymyai/flux-schnell | Model ID |
| width | number | | 1024 | Image width (64-2048) |
| height | number | | 1024 | Image height (64-2048) |
| num_inference_steps | number | | - | Denoising steps (1-100) |
| guidance_scale | number | | - | Prompt adherence (0-20) |
| seed | number | | - | Random seed for reproducibility |
Examples:
Generate an image of a sunset over mountains with dramatic clouds
a cyberpunk city @dev
@schnell a quick sketch of a cat
realistic photo of mountains @hqModel shortcuts in prompt:
| Shortcut | Model |
|----------|-------|
| @schnell, @fast | flymyai/flux-schnell |
| @dev, @hq, @quality | flymyai/flux-dev |
| @sdxl, @lora | flymyai/sdxl-lora |
flymyai_batch
Generate multiple images in parallel.
Parameters:
| Name | Type | Required | Description |
|------|------|----------|-------------|
| prompts | array/string | ✅ | Array of prompts or newline-separated string |
| model | string | | Model ID for all prompts |
Input formats:
// Array of strings
["a red car", "a blue boat", "a green plane"]
// Array of objects with custom params
[
{"prompt": "a cat", "params": {"width": 512}},
{"prompt": "a dog", "params": {"seed": 42}}
]
// Newline-separated string
"a cat\na dog\na bird"flymyai_models
List available image generation models.
Available Models
| Model ID | Name | Speed | Quality |
|----------|------|-------|---------|
| flymyai/flux-schnell | FLUX Schnell | Fast | Good |
| flymyai/flux-dev | FLUX Dev | Slow | High |
| flymyai/sdxl-lora | SDXL LoRA | Medium | High |
Environment Variables
| Variable | Required | Default | Description |
|----------|----------|---------|-------------|
| FLYMYAI_API_KEY | ✅ | - | Your FlyMyAI API key |
| FLYMYAI_BASE_URL | | https://api.flymy.ai/api/v1 | API base URL |
| FLYMYAI_DEFAULT_MODEL | | flymyai/flux-schnell | Default model for generation |
| FLYMYAI_MAX_CONCURRENCY | | 5 | Max parallel requests for batch |
| FLYMYAI_MAX_RETRIES | | 3 | Max retry attempts |
| FLYMYAI_RETRY_DELAY_MS | | 1000 | Initial retry delay (ms) |
| FLYMYAI_TIMEOUT_MS | | 120000 | Request timeout (ms) |
| FLYMYAI_LOG_LEVEL | | info | Log level: debug, info, warn, error, silent |
Programmatic Usage
You can also use the client directly in your Node.js applications:
import { FlyMyAIClient, loadConfig } from '@flymyai/mcp-server'
const config = loadConfig()
const client = new FlyMyAIClient(config)
// Single image
const result = await client.generate({
prompt: "a beautiful sunset",
width: 1024,
height: 1024,
})
console.log(result.image) // base64 string
// Batch generation
const results = await client.generateBatch([
{ id: "1", prompt: "a cat" },
{ id: "2", prompt: "a dog" },
{ id: "3", prompt: "a bird" },
])Error Handling
The server includes comprehensive error handling:
- ValidationError: Invalid input parameters
- APIError: FlyMyAI API errors (with automatic retry for 5xx errors)
- TimeoutError: Request timeout (retryable)
- RateLimitError: Rate limit exceeded (automatic backoff)
Development
# Clone the repository
git clone https://github.com/FlyMyAI/flymyai-mcp-server.git
cd flymyai-mcp-server
# Install dependencies
npm install
# Build
npm run build
# Run locally
FLYMYAI_API_KEY=your-key npm start
# Watch mode
npm run devLicense
MIT © FlyMyAI
