get_chunk
Retrieve full content from a knowledge base by specifying a chunk ID. Use this tool to access detailed information after identifying relevant content through search.
Instructions
Retrieve a specific chunk from the knowledge base by its ID. Use this when you need the full content of a previously found chunk.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chunk_id | Yes | The ID of the chunk to retrieve (e.g., 'chunk-42') |
Implementation Reference
- src/index.ts:83-130 (handler)The MCP tool registration and handler implementation for "get_chunk".
server.tool( "get_chunk", "Retrieve a specific chunk from the knowledge base by its ID. Use this when you need the full content of a previously found chunk.", { chunk_id: z.string().describe("The ID of the chunk to retrieve (e.g., 'chunk-42')"), }, async ({ chunk_id }) => { try { const chunk = getChunkById(chunk_id); if (!chunk) { return { content: [ { type: "text" as const, text: `Chunk not found with ID: "${chunk_id}"`, }, ], }; } return { content: [ { type: "text" as const, text: `# ${chunk.title} **Category:** ${chunk.category} **Chunk ID:** ${chunk.id} ${chunk.content}`, }, ], }; } catch (error) { const errorMessage = error instanceof Error ? error.message : "Unknown error"; return { content: [ { type: "text" as const, text: `Error retrieving chunk: ${errorMessage}`, }, ], isError: true, }; } } ); - src/search.ts:132-140 (helper)The helper function that performs the actual logic of retrieving the chunk by ID.
export function getChunkById(chunkId: string): Chunk | null { // Validate chunk ID format to prevent potential issues if (!CHUNK_ID_PATTERN.test(chunkId)) { return null; } const knowledge = getKnowledge(); return knowledge.chunks.find((chunk) => chunk.id === chunkId) || null; }