Skip to main content
Glama
8enSmith

mcp-open-library

get_book_cover

Retrieve a book’s cover image URL by providing an identifier (ISBN, OCLC, LCCN, OLID, ID) and selecting the desired size (S, M, L).

Instructions

Get the URL for a book's cover image using a key (ISBN, OCLC, LCCN, OLID, ID) and value.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYesThe type of identifier used (ISBN, OCLC, LCCN, OLID, ID).
sizeNoThe desired size of the cover (S, M, or L).
valueYesThe value of the identifier.

Implementation Reference

  • Implements the core logic for the get_book_cover tool: validates input using Zod schema, constructs the Open Library cover image URL based on key (ISBN, OCLC, etc.), value, and size, and returns it as MCP content.
    const handleGetBookCover = async (args: unknown) => {
      const parseResult = GetBookCoverArgsSchema.safeParse(args);
    
      if (!parseResult.success) {
        const errorMessages = parseResult.error.errors
          .map((e) => `${e.path.join(".")}: ${e.message}`)
          .join(", ");
        throw new McpError(
          ErrorCode.InvalidParams,
          `Invalid arguments for get_book_cover: ${errorMessages}`,
        );
      }
    
      const { key, value, size } = parseResult.data;
    
      // Construct the URL according to the Open Library Covers API format
      const coverUrl = `https://covers.openlibrary.org/b/${key.toLowerCase()}/${value}-${size}.jpg`;
    
      return {
        content: [
          {
            type: "text",
            text: coverUrl,
          },
        ],
      };
      // No try/catch needed here as we are just constructing a URL string based on validated input.
    };
  • Zod schema for input validation of get_book_cover tool arguments: key (ISBN/OCLC/etc.), value, optional size (defaults to L).
    // Schema for the get_book_cover tool arguments
    export const GetBookCoverArgsSchema = z.object({
      key: z.enum(["ISBN", "OCLC", "LCCN", "OLID", "ID"], {
        errorMap: () => ({
          message: "Key must be one of ISBN, OCLC, LCCN, OLID, ID",
        }),
      }),
      value: z.string().min(1, { message: "Value cannot be empty" }),
      size: z
        .nullable(z.enum(["S", "M", "L"]))
        .optional()
        .transform((val) => val || "L"),
    });
  • src/index.ts:115-141 (registration)
    MCP tool registration: defines name, description, and JSON inputSchema for get_book_cover in the server's tool list.
    {
      name: "get_book_cover",
      description:
        "Get the URL for a book's cover image using a key (ISBN, OCLC, LCCN, OLID, ID) and value.",
      inputSchema: {
        type: "object",
        properties: {
          key: {
            type: "string",
            // ID is internal cover ID
            enum: ["ISBN", "OCLC", "LCCN", "OLID", "ID"],
            description:
              "The type of identifier used (ISBN, OCLC, LCCN, OLID, ID).",
          },
          value: {
            type: "string",
            description: "The value of the identifier.",
          },
          size: {
            type: "string",
            enum: ["S", "M", "L"],
            description: "The desired size of the cover (S, M, or L).",
          },
        },
        required: ["key", "value"],
      },
    },
  • src/index.ts:178-179 (registration)
    Switch case in CallToolRequestHandler that routes get_book_cover calls to the handler function.
    case "get_book_cover":
      return handleGetBookCover(args);
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. While it states what the tool does (gets a URL), it doesn't describe important behavioral aspects: whether this requires authentication, rate limits, what happens with invalid identifiers, if the URL is permanent or temporary, or what format the URL returns (e.g., direct image link vs. API endpoint). For a tool with zero annotation coverage, this leaves significant gaps in understanding how it behaves.

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 that communicates the core purpose without unnecessary words. It's appropriately sized for a straightforward tool and front-loads the essential information. Every element of the sentence serves a purpose, making it an excellent example of conciseness.

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

Completeness3/5

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

Given the tool's moderate complexity (3 parameters, no output schema, no annotations), the description is adequate but incomplete. It covers the basic purpose and parameters but lacks behavioral context and usage guidance. Without annotations or output schema, the description should ideally provide more about what the URL looks like, error conditions, or typical use cases to be fully complete for agent understanding.

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 description mentions 'using a key (ISBN, OCLC, LCCN, OLID, ID) and value,' which aligns with the schema's 'key' and 'value' parameters. However, with 100% schema description coverage, the schema already fully documents all three parameters including their enums and descriptions. The description adds minimal value beyond what's in the structured schema, meeting the baseline for high schema coverage.

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 action ('Get the URL for a book's cover image') and resource ('book's cover image'), which is specific and unambiguous. It distinguishes itself from sibling tools like 'get_book_by_id' or 'get_book_by_title' by focusing specifically on cover images rather than book metadata. However, it doesn't explicitly contrast with 'get_author_photo' or other image-related tools, preventing a perfect score.

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 this tool is appropriate compared to sibling tools like 'get_book_by_id' (which might also return cover information) or 'get_author_photo' (for author images). There's no context about prerequisites, limitations, or typical use cases for cover images versus other book data.

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

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/8enSmith/mcp-open-library'

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