Skip to main content
Glama
andreasHornqvist

MCP Server Template for Cursor IDE

generate_image

Create custom images from text descriptions using DALL-E 3 within Cursor IDE. Specify size, quality, and quantity to generate visual content for your projects.

Instructions

Generate an image using DALL-E 3

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptYesThe description of the image you want to generate
sizeNoImage size (1024x1024, 1024x1792, or 1792x1024)1024x1024
qualityNoImage quality (standard or hd)standard
nNoNumber of images to generate

Implementation Reference

  • The core handler function that implements the generate_image tool logic using OpenAI DALL-E 3 API to generate and return an image URL.
    async def generate_image(
        prompt: str,
        size: str = "1024x1024",
        quality: str = "standard",
        n: int = 1,
    ) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]:
        """Generate an image using DALL-E 3."""
        try:
            api_key = os.getenv("OPENAI_API_KEY")
            if not api_key:
                return [types.TextContent(
                    type="text",
                    text="Error: OPENAI_API_KEY environment variable is not set"
                )]
            
            client = OpenAI(api_key=api_key)
            response = client.images.generate(
                model="dall-e-3",
                prompt=prompt,
                size=size,
                quality=quality,
                n=n,
            )
            return [types.TextContent(
                type="text",
                text=response.data[0].url
            )]
        except Exception as e:
            return [types.TextContent(
                type="text",
                text=f"Error: Failed to generate image: {str(e)}"
            )]
  • The input schema definition for the generate_image tool, specifying parameters like prompt, size, quality, and n.
    inputSchema={
        "type": "object",
        "required": ["prompt"],
        "properties": {
            "prompt": {
                "type": "string",
                "description": "The description of the image you want to generate",
            },
            "size": {
                "type": "string",
                "description": "Image size (1024x1024, 1024x1792, or 1792x1024)",
                "default": "1024x1024",
                "enum": ["1024x1024", "1024x1792", "1792x1024"],
            },
            "quality": {
                "type": "string",
                "description": "Image quality (standard or hd)",
                "default": "standard",
                "enum": ["standard", "hd"],
            },
            "n": {
                "type": "integer",
                "description": "Number of images to generate",
                "default": 1,
                "minimum": 1,
                "maximum": 1,
            },
        },
    },
  • The tool registration in list_tools(), defining name, description, and schema for generate_image.
    types.Tool(
        name="generate_image",
        description="Generate an image using DALL-E 3",
        inputSchema={
            "type": "object",
            "required": ["prompt"],
            "properties": {
                "prompt": {
                    "type": "string",
                    "description": "The description of the image you want to generate",
                },
                "size": {
                    "type": "string",
                    "description": "Image size (1024x1024, 1024x1792, or 1792x1024)",
                    "default": "1024x1024",
                    "enum": ["1024x1024", "1024x1792", "1792x1024"],
                },
                "quality": {
                    "type": "string",
                    "description": "Image quality (standard or hd)",
                    "default": "standard",
                    "enum": ["standard", "hd"],
                },
                "n": {
                    "type": "integer",
                    "description": "Number of images to generate",
                    "default": 1,
                    "minimum": 1,
                    "maximum": 1,
                },
            },
        },
    ),
  • Dispatch logic in the call_tool handler that validates arguments and invokes the generate_image handler.
    elif name == "generate_image":
        if "prompt" not in arguments:
            return [types.TextContent(
                type="text",
                text="Error: Missing required argument 'prompt'"
            )]
        size = arguments.get("size", "1024x1024")
        quality = arguments.get("quality", "standard")
        n = arguments.get("n", 1)
        return await generate_image(arguments["prompt"], size, quality, n)
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the action ('generate') but doesn't disclose traits like whether it's a read-only or destructive operation, authentication needs, rate limits, response format, or error handling. For a tool with no annotation coverage, this leaves significant gaps in understanding its behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste. It front-loads the core purpose ('Generate an image') and specifies the method ('using DALL-E 3'), making it easy to understand quickly without unnecessary details.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (image generation with 4 parameters) and lack of annotations and output schema, the description is incomplete. It doesn't explain what the tool returns (e.g., image URL, binary data), error conditions, or behavioral traits. For a tool with no structured support, the description should provide more context to be fully helpful.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents all parameters (prompt, size, quality, n). The description adds no additional meaning beyond what the schema provides, such as examples or usage tips. Baseline score of 3 is appropriate since the schema handles parameter documentation effectively.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'generate' and the resource 'image', specifying it uses DALL-E 3. This distinguishes it from sibling tools like figma_design, mcp_fetch, and mood, which don't involve image generation. However, it doesn't explicitly mention what type of images (e.g., AI-generated, artistic) or differentiate further from potential unseen tools.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention any prerequisites, constraints (e.g., rate limits, costs), or compare it to sibling tools. Usage is implied only by the tool's name and description, with no explicit context or exclusions provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/andreasHornqvist/MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server