get-book-information
Retrieve book details from the Information Systems Department's Kintone database to access comprehensive book information for management purposes.
Instructions
Get book information in the Information Systems Department
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:23-54 (handler)The main handler function for the 'get-book-information' tool. It calls getAllBookRecods to fetch data, formats it using formatBookRecord, and returns the result as text content or an error message.
async () => { try { const booksInfo = await getAllBookRecods(); // booksInfoがnullや未定義の場合のチェック if (!booksInfo || !Array.isArray(booksInfo)) { throw new Error("書籍データの取得に失敗しました"); } const formattedBooksInfo = booksInfo.map(formatBookRecord).join("\n"); return { content: [ { type: "text", text: formattedBooksInfo, }, ], }; } catch (error) { console.error("書籍情報の取得中にエラーが発生しました:", error); return { content: [ { type: "text", text: "申し訳ございませんが、書籍情報の取得中にエラーが発生しました。しばらく時間をおいて再度お試しください。", }, ], }; } } - src/types.ts:1-26 (schema)Type definitions for BookRecord (structure from Kintone) and KintoneResponse (array of BookRecord), used in apiClient.ts helpers for the tool.
export interface BookRecord { publisher_input: { type: "SINGLE_LINE_TEXT"; value: string; }; memo_input: { type: "MULTI_LINE_TEXT"; value: string; }; description_input: { type: "MULTI_LINE_TEXT"; value: string; }; title_input: { type: "SINGLE_LINE_TEXT"; value: string; }; $id: { type: "__ID__"; value: string; }; [fieldCode: string]: any; } export type KintoneResponse = BookRecord[]; - src/index.ts:14-22 (registration)Registration of the 'get-book-information' tool on the MCP server, including name, description, and empty input schema.
server.tool( "get-book-information", "Get book information in the Information Systems Department", { type: "object", properties: {}, required: [], }, - src/apiClient.ts:43-51 (helper)Helper function to retrieve all book records from the Kintone database via REST API, called by the tool handler.
export async function getAllBookRecods(): Promise<KintoneResponse> { try { const response = await client.record.getAllRecords<BookRecord>(params); return response; } catch (error) { console.error("Error fetching book records:", error); throw error; } } - src/apiClient.ts:53-62 (helper)Helper function to format a single BookRecord into a readable multi-line string, used by the tool handler.
export function formatBookRecord(record: BookRecord): string { return [ `Title: ${record.title_input.value || "Unknown"}`, `Description: ${record.description_input.value || "Unknown"}`, `Memo: ${record.memo_input.value || "Unknown"}`, `Publisher: ${record.publisher_input.value || "Unknown"}`, `Origin: ${KINTONE_BASE_URL}/k/${KINTONE_APP_ID}/show#record=${record["$id"].value || "No headline"}`, "---", ].join("\n"); }