Skip to main content
Glama

cover_image

Search Unsplash for cover images to use in your posts. Specify query, orientation, and count. Returns image URLs, photographer details, and attribution.

Instructions

Search Unsplash for cover images. FREE. Requires Unsplash access_key via setup. Subject to Unsplash's 50 req/h demo or 5000 req/h production rate limit. Returns: { results: [{ url_full, url_regular, url_small, photographer, photographer_url, attribution_html, alt }] }. Common errors: missing Unsplash key (VALIDATION_ERROR), rate-limit exceeded (PLATFORM_ERROR).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch terms for the image
orientationNoImage orientation (default: landscape)
countNoNumber of results 1-5 (default: 3)

Implementation Reference

  • Main handler for the 'cover_image' tool. Searches Unsplash for cover images matching a query. Validates query, checks for Unsplash API key config, calls the Unsplash search API, maps results with attribution, and returns success data.
    export async function handleCoverImage(input: z.infer<typeof coverImageSchema>) {
      const queryErr = validateRequired(input.query, "query");
      if (queryErr) return makeError("VALIDATION_ERROR", queryErr);
    
      const config = readConfig();
      const accessKey = config.images?.unsplash_access_key;
    
      if (!accessKey) {
        return makeError(
          "VALIDATION_ERROR",
          'Unsplash API key not configured. Run: setup unsplash with credentials { "access_key": "your_unsplash_access_key" }. Get a free key at https://unsplash.com/developers'
        );
      }
    
      const orientation = input.orientation ?? "landscape";
      const count = input.count ?? 3;
    
      const url = `https://api.unsplash.com/search/photos?query=${encodeURIComponent(input.query)}&orientation=${orientation}&per_page=${count}`;
    
      const result = await httpRequest(url, {
        method: "GET",
        headers: { Authorization: `Client-ID ${accessKey}` },
      });
    
      if (!result.success) return result;
    
      const data = result.data as UnsplashSearchResponse;
      const photos = (data.results ?? []).map((photo) => {
        // Fire and forget download tracking for Unsplash API compliance
        httpRequest(`https://api.unsplash.com/photos/${photo.id}/download`, {
          method: "GET",
          headers: { Authorization: `Client-ID ${accessKey}` },
        }).catch(() => {});
    
        return {
          id: photo.id,
          description: photo.description ?? photo.alt_description ?? "",
          urls: {
            regular: photo.urls.regular,
            small: photo.urls.small,
          },
          attribution: {
            photographer: photo.user.name,
            profile_url: photo.user.links.html,
            text: `Photo by ${photo.user.name} on Unsplash`,
          },
        };
      });
    
      return makeSuccess({
        query: input.query,
        orientation,
        total_available: data.total,
        results: photos,
      });
    }
  • Zod schema defining the cover_image tool input: query (string), orientation (landscape|portrait|squarish, optional), count (1-5, optional, default 3).
    export const coverImageSchema = z.object({
      query: z.string().describe("Search terms for the image"),
      orientation: z
        .enum(["landscape", "portrait", "squarish"])
        .optional()
        .describe("Image orientation (default: landscape)"),
      count: z
        .number()
        .min(1)
        .max(5)
        .optional()
        .describe("Number of results 1-5 (default: 3)"),
    });
  • src/index.ts:131-135 (registration)
    Registration of the 'cover_image' tool on the MCP server with description, schema, and handler that parses input, calls handleCoverImage, and formats the response.
    server.tool("cover_image", "Search Unsplash for cover images. FREE. Requires Unsplash access_key via setup. Subject to Unsplash's 50 req/h demo or 5000 req/h production rate limit. Returns: { results: [{ url_full, url_regular, url_small, photographer, photographer_url, attribution_html, alt }] }. Common errors: missing Unsplash key (VALIDATION_ERROR), rate-limit exceeded (PLATFORM_ERROR).", coverImageSchema.shape, async (input) => {
      const parsed = coverImageSchema.parse(input);
      const result = await handleCoverImage(parsed);
      return { content: [{ type: "text", text: formatToolResponse("cover_image", result, formatCoverImage) }] };
    });
  • Formatter that converts the cover_image tool's result into a Markdown response for the MCP client, showing query info, image results with thumbnails, and Unsplash attribution.
    export function formatCoverImage(data: unknown): string {
      const d = data as {
        query: string;
        orientation: string;
        total_available: number;
        results: Array<{
          id: string;
          description: string;
          urls: { regular: string; small: string };
          attribution: { photographer: string; profile_url: string; text: string };
        }>;
      };
    
      const lines = [
        successHeader("Cover Images Found"),
        "",
        field("Query", `"${d.query}"`),
        field("Results", `${d.results.length} of ${d.total_available.toLocaleString()}+`),
      ];
    
      for (let i = 0; i < d.results.length; i++) {
        const photo = d.results[i];
        lines.push(
          "",
          `### ${i + 1}. ${photo.description || "Untitled"}`,
          `![](${photo.urls.small})`,
          `\ud83d\udcf7 Photo by ${photo.attribution.photographer} on [Unsplash](${photo.attribution.profile_url})`,
          `\`${photo.urls.regular}\``
        );
      }
    
      lines.push("", note("Use the full-size URL in your frontmatter's `featured_image` field."));
      return lines.join("\n");
    }
  • Import of coverImageSchema and handleCoverImage from image-tools.ts into the main server file.
    import {
      coverImageSchema, handleCoverImage,
    } from "./tools/image-tools.js";
Behavior4/5

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

With no annotations, the description carries the full burden. It discloses that the tool is free, requires an access key, has rate limits, and returns specific data. It also mentions common errors. It does not explicitly state that it is read-only, but the context implies it.

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

Conciseness4/5

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

The description is concise, using two sentences plus a compact representation of return format and errors. It is front-loaded with the core purpose. The return format could be more formal, but it is still efficient.

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

Completeness4/5

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

For a simple external API search tool with three parameters, the description covers setup, rate limits, common errors, and return format. It could include pagination or ordering details, but it is largely complete for the tool's complexity.

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?

The input schema has 100% description coverage, so the description adds no new information beyond the schema. It repeats the high-level purpose but does not provide additional semantic value for parameters.

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

Purpose5/5

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

The description clearly states 'Search Unsplash for cover images,' specifying the external service, action, and resource. It distinguishes itself from sibling tools that perform different actions like 'get_draft' or 'publish'.

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

Usage Guidelines4/5

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

The description provides clear context by mentioning the free nature, required setup of an access key, and rate limits. It also lists common errors. However, it does not explicitly guide when to use this tool versus alternatives like other social media posting tools.

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/MendleM/pipepost'

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