Content
# Reverse Prompt MCP
Picture reverse prompt MCP Server. Input image, output structured analysis + image generation prompts.
For AI agents, a "look and talk" tool that calls through the MCP protocol.
## Features
- 🎯 **Structured Zone Output** — description divided into zones such as [Style], [Composition], [Subject], [Lighting & Color], [Details], etc., for intelligent agents to use by zone
- 📐 **Automatic Aspect Ratio and Title Recognition** — model automatically judges ratio and summarizes title
- 🎨 **Multi-template System** — built-in 3 templates (painting reverse push / poster reverse / product photography), supports user-defined templates
- 🔧 **Model Agnostic** — supports OpenAI compatible interfaces (Qwen/GPT-4V/DeepSeek/MiMo, etc.) and Ollama local models
- 🌐 **Bilingual Support** — outputs both Chinese and English analysis results
- ⚡ **Dual Mode** — fast (~24 seconds) / quality (~140 seconds)
## Quick Start
### 1. Installation
```bash
git clone https://github.com/erduo1998-cell/reverse-prompt-mcp.git
cd reverse-prompt-mcp
python3 -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt
```
### 2. Configure Vision Model
Edit `config.yaml`, fill in your API Key:
```yaml
vision:
provider: openai_compat
openai_compat:
api_key: "Your API Key"
base_url: "https://api.openai.com/v1" # or other compatible interfaces
model: "gpt-4o" # or qwen-vl-plus, deepseek-vl, etc.
```
**Supported Model Providers**:
| Provider | base_url | model Example |
|:---|:---|:---|
| OpenAI | `https://api.openai.com/v1` | `gpt-4o` |
| Qwen | `https://dashscope.aliyuncs.com/compatible-mode/v1` | `qwen-vl-plus` |
| DeepSeek | `https://api.deepseek.com/v1` | `deepseek-vl` |
| MiMo | `https://token-plan-sgp.xiaomimimo.com/v1` | `mimo-v2-omni` |
| Ollama Local | see Ollama configuration below | `llava`, `minicpm-v`, etc. |
**Ollama Local Model Configuration**:
```yaml
vision:
provider: ollama
ollama:
base_url: "http://localhost:11434"
model: "llava"
```
### 3. Configure MCP Client
#### OpenClaw
Add to `openclaw.json`:
```json
{
"mcp": {
"servers": {
"reverse-prompt": {
"command": "/path/to/reverse-prompt-mcp/.venv/bin/python3",
"args": ["-m", "src.server"],
"cwd": "/path/to/reverse-prompt-mcp",
"env": {
"REVERSE_PROMPT_CONFIG": "/path/to/reverse-prompt-mcp/config.yaml"
}
}
}
}
}
```
#### Claude Code
Add to Claude Code's MCP configuration:
```json
{
"mcpServers": {
"reverse-prompt": {
"command": "/path/to/reverse-prompt-mcp/.venv/bin/python3",
"args": ["-m", "src.server"],
"cwd": "/path/to/reverse-prompt-mcp",
"env": {
"REVERSE_PROMPT_CONFIG": "/path/to/reverse-prompt-mcp/config.yaml"
}
}
}
}
```
#### Codex / Other MCP Clients
Refer to the above format, point `command` to your Python path, `args` to `["-m", "src.server"]`, and `cwd` to the project directory.
## Tool Description
### reverse_prompt
Analyze images and generate reverse prompts.
**Parameters**:
| Parameter | Required | Description |
|:---|:---:|:---|
| `image` | ✅ | Image URL (http/https) or local file path |
| `mode` | ❌ | `fast` (fast ~24 seconds) or `quality` (high quality ~140 seconds), default `quality` |
| `language` | ❌ | `zh` / `en` / `both`, default `both` |
| `template` | ❌ | Template name, using custom output format |
**Output Structure**:
```json
{
"title": "6-character Chinese title",
"ratio": "16:9",
"description": {
"zh": "[Style] ... [Composition] ... [Subject] ... [Lighting & Color] ... [Details] ...",
"en": "[Style] ... [Composition] ... [Subject] ... [Lighting & Color] ... [Details] ..."
},
"analysis": {
"subject": "Subject description",
"scene": "Scene description",
"composition": "Composition method",
"camera": "Camera language",
"lighting": "Lighting description",
"color_palette": "Color description",
"material_texture": "Material description",
"style": "Style tag",
"mood": "Atmosphere",
"key_details": ["Visual anchors"],
"negative": ["Unwanted elements"]
},
"prompts": {
"zh": "Chinese image generation prompt",
"en": "English prompt for image generation"
}
}
```
### list_templates
List all available reverse prompt templates.
### create_template
Create a custom template.
**Parameters**:
| Parameter | Required | Description |
|:---|:---:|:---|
| `name` | ✅ | Template name (English, e.g., `painting`) |
| `display_name` | ✅ | Display name (e.g., `Painting Reverse`) |
| `description` | ✅ | Purpose description |
| `output_format` | ✅ | Custom output JSON format description |
| `extra_instructions` | ❌ | Additional analysis instructions |
### delete_template
Delete a custom template.
## Built-in Templates
| Template | Name | Focus |
|:---|:---|:---|
| `painting` | Painting Reverse | Style, composition, lighting, color |
| `poster` | Poster/Infographic Reverse | Layout, color scheme, font, core elements |
| `product` | Product Photography Reverse | Material process, commercial lighting, display method |
Use template: pass `template="painting"` when calling `reverse_prompt`.
## Custom Template Example
Create through `create_template` tool or manually add a JSON file in the `templates/` directory:
```json
{
"name": "anime",
"display_name": "Anime Reverse",
"description": "Focus on line draft, cel shading, and anime-specific style features",
"builtin": false,
"output_format": "Return JSON: { \"title\": \"...\", \"ratio\": \"...\", \"description\": { \"zh\": \"【画风】...【线稿】...【上色】...【角色】...【背景】...\", \"en\": \"...\" }, ... }",
"extra_instructions": "Focus on line art quality, cel shading technique, and anime-specific style features."
}
```
## License
MIT License
## Acknowledgements
Inspiration from: [Promptify](https://chromewebstore.google.com/detail/promptify-ai-prompt-genera/hjlmkhkbljjkhjlgloaofjcbnhfioodb) Chrome plugin, [CLIP Interrogator](https://github.com/pharmapsychotic/clip-interrogator), [ComfyUI-Prompt-Assistant](https://github.com/yawiii/ComfyUI-Prompt-Assistant)