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
| Name | Required | Description | Default |
|---|---|---|---|
| ISBN | Yes | The book's ISBN to query |
Implementation Reference
- src/tools/isbn.ts:20-34 (handler)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}`); } },
- src/tools/isbn.ts:10-12 (schema)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"), };
- src/tools/isbn.ts:16-35 (registration)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); });