Skip to main content
Glama
mauricio-cantu

brasil-api-mcp-server

get_isbn

Retrieve book information using an ISBN number. This tool queries BrasilAPI to provide details about books based on their unique identifier.

Instructions

Get information about a book given an ISBN.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ISBNYesThe book's ISBN to query

Implementation Reference

  • Executes the tool logic by querying the Brasil API for book details using the provided ISBN and formatting the response.
    handler: async ({ ISBN }): Promise<McpResponse> => {
      try {
        const result = await brasilApiClient.isbn.getBy(ISBN);
        const content: McpTextContent = {
          type: "text",
          text: `Book with ISBN ${ISBN} found:\n${prettifyJson(result.data)}`,
        };
        return {
          content: [content],
        };
      } catch (error: any) {
        console.error(error);
        throw new Error(`Failed to fetch book with ISBN ${ISBN}`);
      }
    },
  • Zod schema defining the input parameters for the get_isbn tool (ISBN string).
    const getISBNToolParams = {
      ISBN: z.string().describe("The book's ISBN to query"),
    };
  • MCP tool definition exporting the get_isbn tool with name, description, params, and inline handler.
    export const getBookByISBNTool: McpToolDefinition<GetISBNToolParams> = {
      name: "get_isbn",
      description: "Get information about a book given an ISBN.",
      params: getISBNToolParams,
      handler: async ({ ISBN }): Promise<McpResponse> => {
        try {
          const result = await brasilApiClient.isbn.getBy(ISBN);
          const content: McpTextContent = {
            type: "text",
            text: `Book with ISBN ${ISBN} found:\n${prettifyJson(result.data)}`,
          };
          return {
            content: [content],
          };
        } catch (error: any) {
          console.error(error);
          throw new Error(`Failed to fetch book with ISBN ${ISBN}`);
        }
      },
    };
  • src/index.ts:30-41 (registration)
    The getBookByISBNTool is included in the tools array and registered to the MCP server using registerTool.
    const tools = [
      getCepTool,
      getCepV2Tool,
      getBookByISBNTool,
      getCNPJTool,
      getAllBanksTool,
      getBankByCodeTool,
    ];
    
    tools.forEach((tool) => {
      registerTool(server, tool);
    });

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/mauricio-cantu/brasil-api-mcp-server'

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