Skip to main content
Glama

get_random_photo

Retrieve a random photo from a unified MCP server, optionally filtered by category. Access multiple APIs through Multi-MCPs to simplify photo retrieval across integrated services.

Instructions

Get a random photo optionally filtered by category

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
categoryNo

Implementation Reference

  • The main handler function for the 'get_random_photo' tool. It validates the Unsplash access key configuration, extracts the optional 'category' parameter from the input arguments, converts it to a string if present, and delegates to the Unsplash client's getRandomPhoto method to fetch the photo.
    async get_random_photo(args: Record<string, unknown>) { if (!cfg.unsplashAccessKey) throw new Error("UNSPLASH_ACCESS_KEY is not configured"); const category = args.category ? String(args.category) : undefined; return client.getRandomPhoto(category); },
  • Input schema definition for the 'get_random_photo' tool, specifying an optional 'category' property of type string.
    inputSchema: { type: "object", properties: { category: { type: "string" } }, },
  • Tool registration entry for 'get_random_photo' within the tools array returned by the registerUnsplash function.
    { name: "get_random_photo", description: "Get a random photo optionally filtered by category", inputSchema: { type: "object", properties: { category: { type: "string" } }, }, },
  • Supporting helper method in the UnsplashClient class that makes the API request to Unsplash's /photos/random endpoint, optionally passing a category as a query parameter.
    getRandomPhoto(category?: string) { return this.request("/photos/random", { headers: this.headers(), query: category ? { query: category } : undefined }); }

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/TaylorChen/muti-mcps'

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