get_by_id
Retrieve a specific knowledge base entry using its unique ID to access precise information quickly.
Instructions
Get a specific knowledge base entry by its ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | The ID of the entry to retrieve |
Implementation Reference
- src/index.ts:182-195 (registration)Registers the 'get_by_id' tool in the ListTools response, defining its name, description, and input schema (object with required 'id' string).{ name: "get_by_id", description: "Get a specific knowledge base entry by its ID", inputSchema: { type: "object", properties: { id: { type: "string", description: "The ID of the entry to retrieve", }, }, required: ["id"], }, },
- src/index.ts:371-421 (handler)Executes the 'get_by_id' tool: retrieves entry by ID from knowledgeBase, returns formatted JSON with content/category/metadata or error if not found, includes caching.if (name === "get_by_id") { const id = args?.id as string; if (!id) { throw new Error("ID parameter is required"); } const entry = knowledgeBase.find((item) => item.id === id); if (!entry) { const responseText = JSON.stringify({ id, error: "Entry not found", availableIds: knowledgeBase.map((item) => item.id), }); // Don't cache errors return { content: [ { type: "text", text: responseText, }, ], isError: true, }; } const responseText = JSON.stringify( { id: entry.id, content: entry.content, category: entry.category, metadata: entry.metadata, }, null, 2 ); // Cache the response setCache(cacheKey, responseText); return { content: [ { type: "text", text: responseText, }, ], }; }