MCP Server Replicate
by gerred
Verified
# MCP Server Workflow Patterns
## Text-to-Image Generation
The text-to-image workflow is designed to help users find and use the right model for their specific needs. The workflow follows these steps:
1. **Initial User Input**
- User provides their requirements through the `text_to_image` prompt
- System guides them to specify:
- Subject matter
- Style preferences
- Quality requirements
- Technical requirements (size, etc.)
2. **Model Discovery**
- System uses `search_available_models` to find suitable models
- Models are scored based on:
- Popularity (run count)
- Featured status
- Version stability
- Tag matching
- Task relevance
- Results are sorted but presented to user for selection
3. **Model Selection**
- User can view model details using `get_model_details`
- System provides guidance on model capabilities
- User makes final model selection
- System confirms version to use
4. **Parameter Configuration**
- System applies quality presets based on user requirements
- Style presets are applied if specified
- Size and other parameters are configured
- User can override any parameters
5. **Image Generation**
- System uses `generate_image` with selected model and parameters
- Progress is tracked
- Results are validated
- Retry logic handles failures
### Example Flow
```python
# 1. User provides requirements through text_to_image prompt
response = await text_to_image()
# 2. Search for models based on requirements
models = await search_available_models(
query="cat portrait",
style="photorealistic"
)
# 3. Get details for user's chosen model
model = await get_model_details("stability-ai/sdxl")
# 4. Generate image with chosen model
result = await generate_image(
model_version=model.latest_version.id,
prompt="a photorealistic cat portrait",
style="photorealistic",
quality="balanced"
)
```
### Key Principles
1. **User Agency**
- System suggests but doesn't decide
- User makes final model selection
- Parameters can be overridden
2. **Transparency**
- Model scoring is visible
- Capabilities are clearly communicated
- Limitations are disclosed
3. **Flexibility**
- Multiple models can be used
- Parameters are customizable
- Quality/style presets are optional
4. **Reliability**
- Version stability is considered
- Error handling is robust
- Progress is tracked
## Template Usage
Templates provide consistent parameter sets but should be used flexibly:
1. **Quality Presets**
- Provide baseline parameters
- Can be overridden
- Match user's speed/quality needs
2. **Style Presets**
- Enhance prompts
- Add style-specific parameters
- Are optional and customizable
3. **Aspect Ratio Presets**
- Match common use cases
- Ensure valid dimensions
- Can be customized
## Error Handling
1. **Model Selection**
- Handle no matches gracefully
- Provide alternatives
- Explain limitations
2. **Parameter Validation**
- Validate before submission
- Provide clear error messages
- Suggest corrections
3. **Generation Failures**
- Implement retry logic
- Track progress
- Provide status updates
## Best Practices
1. **Model Selection**
- Always let user choose model
- Provide scoring context
- Explain trade-offs
2. **Parameter Configuration**
- Use presets as starting points
- Allow customization
- Validate combinations
3. **Error Handling**
- Be proactive about potential issues
- Provide clear error messages
- Implement proper retry logic
4. **User Interaction**
- Guide don't decide
- Explain options
- Respect user choices
```
```