Skip to main content
Glama
tusharpatil2912

Pollinations Multimodal MCP Server

generateImageUrl

Create images from text descriptions using AI, with options to customize model, dimensions, and seed for reproducible results.

Instructions

Generate an image URL from a text prompt

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptYesThe text description of the image to generate
optionsNoAdditional options for image generation

Implementation Reference

  • Main handler function for the 'generateImageUrl' tool. Validates the prompt parameter, calls the internal helper to generate the image URL and metadata, and returns an MCP-formatted response.
    async function generateImageUrl(params) {
        const { prompt, options = {} } = params;
    
        if (!prompt || typeof prompt !== "string") {
            throw new Error("Prompt is required and must be a string");
        }
    
        // Generate the image URL and metadata
        const result = await _generateImageUrlInternal(prompt, options);
    
        // Return the response in MCP format
        return createMCPResponse([createTextContent(result, true)]);
    }
  • Internal helper function that constructs the Pollinations Image API URL using the prompt and options, encodes parameters, and returns the URL with metadata.
    async function _generateImageUrlInternal(prompt, options = {}) {
        const { model, seed, width = 1024, height = 1024 } = options;
    
        // Construct the URL with query parameters
        const encodedPrompt = encodeURIComponent(prompt);
        const path = `prompt/${encodedPrompt}`;
        const queryParams = { model, seed, width, height };
    
        const url = buildUrl(IMAGE_API_BASE_URL, path, queryParams);
    
        // Return the URL with metadata
        return {
            imageUrl: url,
            prompt,
            width,
            height,
            model,
            seed,
        };
    }
  • Zod schema defining the input parameters for the generateImageUrl tool: required 'prompt' string and optional 'options' object with model, seed, width, height.
    {
        prompt: z
            .string()
            .describe("The text description of the image to generate"),
        options: z
            .object({
                model: z
                    .string()
                    .optional()
                    .describe("Model name to use for generation"),
                seed: z
                    .number()
                    .optional()
                    .describe("Seed for reproducible results"),
                width: z
                    .number()
                    .optional()
                    .describe("Width of the generated image"),
                height: z
                    .number()
                    .optional()
                    .describe("Height of the generated image"),
            })
            .optional()
            .describe("Additional options for image generation"),
    },
  • Registration entry in imageTools array: [name, description, schema, handler]. This array is spread into toolDefinitions and registered via server.tool(...tool) in src/index.js.
    [
        "generateImageUrl",
        "Generate an image URL from a text prompt",
        {
            prompt: z
                .string()
                .describe("The text description of the image to generate"),
            options: z
                .object({
                    model: z
                        .string()
                        .optional()
                        .describe("Model name to use for generation"),
                    seed: z
                        .number()
                        .optional()
                        .describe("Seed for reproducible results"),
                    width: z
                        .number()
                        .optional()
                        .describe("Width of the generated image"),
                    height: z
                        .number()
                        .optional()
                        .describe("Height of the generated image"),
                })
                .optional()
                .describe("Additional options for image generation"),
        },
        generateImageUrl,
    ],
  • src/index.js:87-88 (registration)
    Generic registration loop that calls server.tool(name, description, inputSchema, handler) for all tools, including generateImageUrl from imageTools.
    toolDefinitions.forEach((tool) => server.tool(...tool));
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 an image URL') but lacks details on traits like rate limits, authentication requirements (implied by sibling tools), error handling, or what the generated URL entails (e.g., temporary vs. permanent). This is inadequate for a tool with potential costs or restrictions.

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: 'Generate an image URL from a text prompt.' It is front-loaded with the core purpose, has zero waste, and is appropriately sized for the tool's complexity. Every word earns its place, making it easy for an agent to parse quickly.

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 no annotations, no output schema, and the tool's complexity (involving image generation with multiple options), the description is incomplete. It doesn't cover behavioral aspects like authentication needs (implied by siblings), rate limits, or output details (e.g., URL format or validity). For a generative tool with potential side effects, more context is needed to ensure safe and effective use.

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%, with clear descriptions for 'prompt' and 'options' (including nested properties like 'model', 'seed', 'width', 'height'). The description adds no additional meaning beyond the schema, such as examples or constraints (e.g., prompt length limits). With high schema coverage, a baseline score of 3 is appropriate, as the schema does the heavy lifting.

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 tool's purpose: 'Generate an image URL from a text prompt.' It specifies the verb ('Generate') and resource ('image URL'), distinguishing it from siblings like 'generateImage' (which may return the image itself) and 'generateText'. However, it doesn't explicitly differentiate from all siblings, such as 'listImageModels', which is related but serves a different function.

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 when to choose it over 'generateImage' (e.g., for URL vs. direct image output) or other siblings like 'listImageModels' for model selection. There's no context on prerequisites, such as authentication status, which is implied by 'checkAuthStatus' and 'startAuth' in the sibling list.

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/tusharpatil2912/pollinations-mcp'

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