Skip to main content
Glama

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

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

Input Schema (JSON Schema)

{ "properties": { "author_key": { "description": "The Open Library key for the author (e.g., OL23919A).", "type": "string" } }, "required": [ "author_key" ], "type": "object" }

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 }; }

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