Skip to main content
Glama
ssv445

Lorem Ipsum MCP Server

by ssv445

image

Generate or retrieve customizable images from picsum.photos using parameters like dimensions, filters, and output formats. Supports URLs, file downloads, and metadata retrieval.

Instructions

Generate or fetch images from picsum.photos with various options

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
blurNoApply blur filter (1-10)
formatNoImage format
grayscaleNoApply grayscale filter to the image
heightNoThe height of the image in pixels
idNoThe ID of a specific image to retrieve
infoNoFetch metadata for a specific image
limitNoNumber of results per page for list
listNoFetch list of available images
outputNoOutput type: url returns string URL, file returns binary dataurl
pageNoPage number for list results
seedNoA seed for generating a static random image
widthNoThe width of the image in pixels

Implementation Reference

  • Core handler function that implements the image tool logic: constructs image URLs from picsum.photos based on parameters, handles special modes (list, info), applies filters, and returns URL string, ImageContent, or TextContent.
    public static async generateImage(params: { width?: number; height?: number; id?: string; seed?: string; grayscale?: boolean; blur?: number; format?: 'jpg' | 'webp'; output?: 'url' | 'file'; list?: boolean; page?: number; limit?: number; info?: boolean; }): Promise<string | ImageContent | TextContent> { const { width, height, id, seed, grayscale, blur, format, output = 'url', list, page, limit, info } = params; // Handle list operation if (list) { const result = await this.fetchImageList(page, limit); return { type: "text", text: JSON.stringify(result, null, 2) } as TextContent; } // Handle info operation if (info) { let result: object; if (id) { result = await this.fetchImageInfo(id); } else if (seed) { result = await this.fetchSeedInfo(seed, width, height); } else { throw new Error('Info operation requires either --id or --seed parameter'); } return { type: "text", text: JSON.stringify(result, null, 2) } as TextContent; } // Validate blur parameter if (blur !== undefined && (blur < 1 || blur > 10)) { throw new Error('Blur value must be between 1 and 10'); } // Generate image URL const url = this.constructImageUrl({ width, height, id, seed, grayscale, blur, format }); // Return URL or fetch file data if (output === 'url') { return url; } else { // Use the imageContent helper to return proper ImageContent return await imageContent({ url }); } }
  • Registers the 'image' tool with the FastMCP server, including name, description, Zod input schema, and thin execute handler delegating to ImageService.generateImage.
    server.addTool({ name: "image", description: "Generate or fetch images from picsum.photos with various options", parameters: z.object({ width: z.number().int().positive().optional().describe("The width of the image in pixels"), height: z.number().int().positive().optional().describe("The height of the image in pixels"), id: z.string().optional().describe("The ID of a specific image to retrieve"), seed: z.string().optional().describe("A seed for generating a static random image"), grayscale: z.boolean().optional().describe("Apply grayscale filter to the image"), blur: z.number().int().min(1).max(10).optional().describe("Apply blur filter (1-10)"), format: z.enum(["jpg", "webp"]).optional().describe("Image format"), output: z.enum(["url", "file"]).default("url").describe("Output type: url returns string URL, file returns binary data"), list: z.boolean().optional().describe("Fetch list of available images"), page: z.number().int().positive().optional().describe("Page number for list results"), limit: z.number().int().positive().optional().describe("Number of results per page for list"), info: z.boolean().optional().describe("Fetch metadata for a specific image") }), execute: async (params) => { return await services.ImageService.generateImage(params); } });
  • Zod schema defining all input parameters for the 'image' tool, including dimensions, IDs, seeds, filters, output format, and special operations like list and info.
    parameters: z.object({ width: z.number().int().positive().optional().describe("The width of the image in pixels"), height: z.number().int().positive().optional().describe("The height of the image in pixels"), id: z.string().optional().describe("The ID of a specific image to retrieve"), seed: z.string().optional().describe("A seed for generating a static random image"), grayscale: z.boolean().optional().describe("Apply grayscale filter to the image"), blur: z.number().int().min(1).max(10).optional().describe("Apply blur filter (1-10)"), format: z.enum(["jpg", "webp"]).optional().describe("Image format"), output: z.enum(["url", "file"]).default("url").describe("Output type: url returns string URL, file returns binary data"), list: z.boolean().optional().describe("Fetch list of available images"), page: z.number().int().positive().optional().describe("Page number for list results"), limit: z.number().int().positive().optional().describe("Number of results per page for list"), info: z.boolean().optional().describe("Fetch metadata for a specific image") }),
  • Helper method to construct the picsum.photos image URL based on provided parameters, handling path construction and query parameters for filters and format.
    private static constructImageUrl(params: { width?: number; height?: number; id?: string; seed?: string; grayscale?: boolean; blur?: number; format?: 'jpg' | 'webp'; }): string { const { width, height, id, seed, grayscale, blur, format } = params; let url: string; // Construct base URL path if (id) { if (width && height) { url = `${this.BASE_URL}/id/${id}/${width}/${height}`; } else if (width) { url = `${this.BASE_URL}/id/${id}/${width}`; } else { url = `${this.BASE_URL}/id/${id}`; } } else { if (width && height) { url = `${this.BASE_URL}/${width}/${height}`; } else if (width) { url = `${this.BASE_URL}/${width}`; } else { // Default size if no dimensions specified url = `${this.BASE_URL}/200`; } } // Add query parameters const queryParams: string[] = []; if (seed) { queryParams.push(`seed=${encodeURIComponent(seed)}`); } if (grayscale) { queryParams.push('grayscale'); } if (blur) { queryParams.push(`blur=${blur}`); } if (format) { queryParams.push(`fmt=${format}`); } if (queryParams.length > 0) { url += '?' + queryParams.join('&'); } return url; }

Other Tools

Related 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/ssv445/lorem-ipsum-mcp'

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