Skip to main content
Glama
8enSmith

mcp-open-library

get_author_info

Retrieve detailed information about an author using their Open Library Author Key. This tool helps users access key data such as bio, works, and related metadata for authors in the Open Library database.

Instructions

Get detailed information for a specific author using their Open Library Author Key (e.g. OL23919A).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
author_keyYesThe Open Library key for the author (e.g., OL23919A).

Implementation Reference

  • The handler function that parses arguments, fetches detailed author information from the Open Library API using the provided author_key, processes the bio if needed, and returns the data as JSON or an error message.
    const handleGetAuthorInfo = async (
      args: unknown,
      axiosInstance: AxiosInstance,
    ): Promise<CallToolResult> => {
      const parseResult = GetAuthorInfoArgsSchema.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_author_info: ${errorMessages}`,
        );
      }
    
      const authorKey = parseResult.data.author_key;
    
      try {
        const response = await axiosInstance.get<DetailedAuthorInfo>(
          `/authors/${authorKey}.json`,
        );
    
        if (!response.data) {
          // Should not happen if API returns 200, but good practice
          return {
            content: [
              {
                type: "text",
                text: `No data found for author key: "${authorKey}"`,
              },
            ],
          };
        }
    
        // Optionally format the bio if it's an object
        const authorData = { ...response.data };
        if (typeof authorData.bio === "object" && authorData.bio !== null) {
          // eslint-disable-next-line @typescript-eslint/no-explicit-any
          authorData.bio = (authorData.bio as any).value; // Adjust type assertion if needed
        }
    
        return {
          content: [
            {
              type: "text",
              // Return the full author details as JSON
              text: JSON.stringify(authorData, null, 2),
            },
          ],
        };
      } catch (error) {
        let errorMessage = `Failed to fetch author data for key ${authorKey}.`;
        if (axios.isAxiosError(error)) {
          if (error.response?.status === 404) {
            errorMessage = `Author with key "${authorKey}" not found.`;
          } else {
            errorMessage = `Open Library API error: ${
              error.response?.statusText ?? error.message
            }`;
          }
        } else if (error instanceof Error) {
          errorMessage = `Error processing request: ${error.message}`;
        }
        console.error(`Error in get_author_info (${authorKey}):`, error);
    
        return {
          content: [
            {
              type: "text",
              text: errorMessage,
            },
          ],
          isError: true,
        };
      }
    };
  • Zod schema defining and validating the input parameter 'author_key' which must match the Open Library author key format (e.g., OL123A).
    // Schema for the get_author_info tool arguments
    export const GetAuthorInfoArgsSchema = z.object({
      author_key: z
        .string()
        .min(1, { message: "Author key cannot be empty" })
        .regex(/^OL\d+A$/, {
          message: "Author key must be in the format OL<number>A",
        }),
    });
  • src/index.ts:83-98 (registration)
    Registration of the 'get_author_info' tool in the MCP server's list of tools, including name, description, and input schema for ListTools requests.
    {
      name: "get_author_info",
      description:
        "Get detailed information for a specific author using their Open Library Author Key (e.g. OL23919A).",
      inputSchema: {
        type: "object",
        properties: {
          author_key: {
            type: "string",
            description:
              "The Open Library key for the author (e.g., OL23919A).",
          },
        },
        required: ["author_key"],
      },
    },
  • src/index.ts:174-175 (registration)
    Dispatch logic in the CallToolRequest handler that routes 'get_author_info' calls to the handleGetAuthorInfo function.
    case "get_author_info":
      return handleGetAuthorInfo(args, this.axiosInstance);
  • TypeScript interface defining the structure of the detailed author information returned by the Open Library API.
    export interface DetailedAuthorInfo {
      name: string;
      personal_name?: string;
      birth_date?: string;
      death_date?: string;
      bio?: string | { type: string; value: string }; // Bio can be string or object
      alternate_names?: string[];
      links?: { title: string; url: string; type: { key: string } }[];
      photos?: number[]; // Array of cover IDs
      source_records?: string[];
      wikipedia?: string;
      key: string;
      remote_ids?: {
        amazon?: string;
        librarything?: string;
        viaf?: string;
        goodreads?: string;
        storygraph?: string;
        wikidata?: string;
        isni?: string;
      };
      latest_revision?: number;
      revision: number;
      created?: { type: string; value: string };
      last_modified: { type: string; value: string };
    }
Behavior3/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. It specifies the required input format (Open Library Author Key) and implies a read-only operation ('Get'), but doesn't describe potential errors (e.g., invalid keys), rate limits, authentication needs, or the structure/format of the returned information. It adds basic context but lacks richer behavioral details.

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, well-structured sentence that front-loads the core purpose and efficiently includes the key constraint (using the Open Library Author Key) with a helpful example. Every word earns its place with zero waste.

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 low complexity (single parameter, no output schema, no annotations), the description is adequate but has gaps. It covers the purpose and input requirement clearly, but without annotations or output schema, it doesn't address behavioral aspects like error handling or return format, leaving the agent with incomplete context for reliable use.

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?

Schema description coverage is 100%, so the schema already fully documents the single parameter 'author_key' with its description and type. The description adds minimal value by restating the parameter's purpose and providing an example (OL23919A), but doesn't go beyond what the schema provides in terms of semantics or constraints.

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 the specific action ('Get detailed information') and target resource ('for a specific author'), using a precise verb+resource combination. It distinguishes this tool from siblings like 'get_author_photo' (which retrieves photos) and 'get_authors_by_name' (which searches by name rather than key).

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 for when to use this tool: when you have an Open Library Author Key and need detailed author information. It implicitly suggests alternatives (e.g., use 'get_authors_by_name' if you don't have a key), but doesn't explicitly state when not to use it or name alternatives directly.

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