Skip to main content
Glama
8enSmith

mcp-open-library

get_authors_by_name

Retrieve detailed author information from Open Library by entering the author's name to facilitate efficient book-related searches and research.

Instructions

Search for author information on Open Library.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesThe name of the author to search for.

Implementation Reference

  • The handler function that executes the tool: validates input with Zod, queries Open Library /search/authors.json API with author name, processes docs into AuthorInfo array, returns JSON string or error.
    const handleGetAuthorsByName = async (
      args: unknown,
      axiosInstance: AxiosInstance,
    ): Promise<CallToolResult> => {
      const parseResult = GetAuthorsByNameArgsSchema.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_authors_by_name: ${errorMessages}`,
        );
      }
    
      const authorName = parseResult.data.name;
    
      try {
        const response = await axiosInstance.get<OpenLibraryAuthorSearchResponse>(
          "/search/authors.json", // Use the author search endpoint
          {
            params: { q: authorName }, // Use 'q' parameter for author search
          },
        );
    
        if (
          !response.data ||
          !response.data.docs ||
          response.data.docs.length === 0
        ) {
          return {
            content: [
              {
                type: "text",
                text: `No authors found matching name: "${authorName}"`,
              },
            ],
          };
        }
    
        const authorResults: AuthorInfo[] = response.data.docs.map((doc) => ({
          key: doc.key,
          name: doc.name,
          alternate_names: doc.alternate_names,
          birth_date: doc.birth_date,
          top_work: doc.top_work,
          work_count: doc.work_count,
        }));
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(authorResults, null, 2),
            },
          ],
        };
      } catch (error) {
        let errorMessage = "Failed to fetch author data from Open Library.";
        if (axios.isAxiosError(error)) {
          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_authors_by_name:", error);
        return {
          content: [
            {
              type: "text",
              text: errorMessage,
            },
          ],
          isError: true,
        };
      }
    };
  • Zod schema for input validation: requires a non-empty 'name' string.
    // Schema for the get_authors_by_name tool arguments
    export const GetAuthorsByNameArgsSchema = z.object({
      name: z.string().min(1, { message: "Author name cannot be empty" }),
    });
  • src/index.ts:70-82 (registration)
    Tool registration in MCP ListTools handler: defines name, description, and JSON schema matching the Zod schema.
      name: "get_authors_by_name",
      description: "Search for author information on Open Library.",
      inputSchema: {
        type: "object",
        properties: {
          name: {
            type: "string",
            description: "The name of the author to search for.",
          },
        },
        required: ["name"],
      },
    },
  • src/index.ts:172-173 (registration)
    Dispatches tool calls to the handler in MCP CallToolRequestHandler switch statement.
    case "get_authors_by_name":
      return handleGetAuthorsByName(args, this.axiosInstance);
  • Type definitions for API response structures and processed author information used by the handler.
    export interface OpenLibraryAuthorDoc {
      key: string;
      type: string;
      name: string;
      alternate_names?: string[];
      birth_date?: string;
      top_work?: string;
      work_count: number;
      top_subjects?: string[];
      _version_?: number;
    }
    
    export interface OpenLibraryAuthorSearchResponse {
      numFound: number;
      start: number;
      numFoundExact: boolean;
      docs: OpenLibraryAuthorDoc[];
    }
    
    export interface AuthorInfo {
      key: string;
      name: string;
      alternate_names?: string[];
      birth_date?: string;
      top_work?: string;
      work_count: number;
    }
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. It states the tool is for searching, implying it's a read operation, but lacks details on permissions, rate limits, response format, or error handling. This is a significant gap for a tool with no annotation coverage.

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 with no wasted words. It is appropriately sized and front-loaded, clearly stating the tool's purpose without unnecessary elaboration.

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

Completeness2/5

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

Given the lack of annotations and output schema, the description is incomplete. It doesn't explain what 'author information' includes, how results are returned, or any limitations, leaving gaps in understanding the tool's behavior and output.

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 schema description coverage is 100%, so the schema already documents the single parameter 'name'. The description adds no additional meaning beyond what the schema provides, such as search behavior or result details, 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 tool's purpose: 'Search for author information on Open Library.' It specifies the verb ('search') and resource ('author information'), though it doesn't explicitly differentiate from sibling tools like 'get_author_info' or 'get_author_photo'.

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?

No guidance is provided on when to use this tool versus alternatives. The description doesn't mention sibling tools or specify use cases, leaving the agent to infer usage based on the tool name alone.

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