outsource_image
Generate high-quality or quick concept images using OpenAI's DALL-E models. Input a detailed prompt and select the model to create visual content for sharing or use in responses.
Instructions
Delegate image generation to an external AI model. Use this when you need to create
visual content.
Args:
provider: The AI provider to use (currently only "openai" is supported)
model: The image model to use ("dall-e-3" for high quality, "dall-e-2" for faster/cheaper)
prompt: A detailed description of the image you want to generate
Returns:
The URL of the generated image, which can be shared with users or used in responses
Example usage:
For high-quality images: provider="openai", model="dall-e-3", prompt="A photorealistic rendering of..."
For quick concepts: provider="openai", model="dall-e-2", prompt="A simple sketch showing..."
Note: Only OpenAI currently supports image generation. Other providers will return an error.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| model | Yes | ||
| prompt | Yes | ||
| provider | Yes |
Implementation Reference
- server.py:111-175 (handler)The main handler function for the 'outsource_image' tool, decorated with @mcp.tool() for automatic registration. It handles image generation requests using OpenAI's DALL-E models, returning the generated image URL or an error message.@mcp.tool() async def outsource_image(provider: str, model: str, prompt: str) -> str: """ Delegate image generation to an external AI model. Use this when you need to create visual content. Args: provider: The AI provider to use (currently only "openai" is supported) model: The image model to use ("dall-e-3" for high quality, "dall-e-2" for faster/cheaper) prompt: A detailed description of the image you want to generate Returns: The URL of the generated image, which can be shared with users or used in responses Example usage: For high-quality images: provider="openai", model="dall-e-3", prompt="A photorealistic rendering of..." For quick concepts: provider="openai", model="dall-e-2", prompt="A simple sketch showing..." Note: Only OpenAI currently supports image generation. Other providers will return an error. """ try: provider_lower = provider.lower() # Currently only OpenAI supports image generation through our integration if provider_lower == "openai": if model in ["dall-e-3", "dall-e-2"]: import openai # Use OpenAI directly for more control client = openai.AsyncOpenAI() # Generate image with appropriate parameters for each model try: if model == "dall-e-3": response = await client.images.generate( model=model, prompt=prompt, n=1, size="1024x1024", response_format="url" ) else: # dall-e-2 response = await client.images.generate( model=model, prompt=prompt, n=1, size="512x512", response_format="url" ) # Get the image URL image_url = response.data[0].url return image_url except openai.OpenAIError as e: return f"Error: OpenAI API error - {str(e)}" else: return f"Error: Model '{model}' is not a supported OpenAI image generation model. Supported models: dall-e-3, dall-e-2" else: return f"Error: Provider '{provider}' does not support image generation through this tool. Currently only 'openai' is supported." except Exception as e: return f"Error generating image: {str(e)}"
- server.py:111-111 (registration)The @mcp.tool() decorator registers the outsource_image function as an MCP tool.@mcp.tool()
- server.py:112-130 (schema)The function signature and docstring define the input schema (provider: str, model: str, prompt: str) and output (str: image URL), with detailed descriptions and examples.async def outsource_image(provider: str, model: str, prompt: str) -> str: """ Delegate image generation to an external AI model. Use this when you need to create visual content. Args: provider: The AI provider to use (currently only "openai" is supported) model: The image model to use ("dall-e-3" for high quality, "dall-e-2" for faster/cheaper) prompt: A detailed description of the image you want to generate Returns: The URL of the generated image, which can be shared with users or used in responses Example usage: For high-quality images: provider="openai", model="dall-e-3", prompt="A photorealistic rendering of..." For quick concepts: provider="openai", model="dall-e-2", prompt="A simple sketch showing..." Note: Only OpenAI currently supports image generation. Other providers will return an error. """