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));

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