get_section
Retrieve a specific section from a memory document by providing the memory ID and section name. Simplifies accessing structured project knowledge for agents.
Instructions
Retrieve a specific section from a memory document
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| memory_id | Yes | The ID of the memory document to read from | |
| section | Yes | The section name to retrieve |
Input Schema (JSON Schema)
{
"properties": {
"memory_id": {
"description": "The ID of the memory document to read from",
"type": "string"
},
"section": {
"description": "The section name to retrieve",
"type": "string"
}
},
"required": [
"memory_id",
"section"
],
"type": "object"
}
Implementation Reference
- src/tools/getSection.ts:4-47 (handler)The handler function that executes the get_section tool: validates params, reads memory, finds section, formats and returns content.export async function getSectionTool( storageManager: StorageManager, args: any ): Promise<any> { const params = args as GetSectionParams; if (!params.memory_id || !params.section) { throw new Error('Both memory_id and section are required'); } // Read the memory document const memory = await storageManager.readMemory(params.memory_id); if (!memory) { throw new Error(`Memory document '${params.memory_id}' not found`); } // Find the section const section = storageManager.findSection(memory.content, params.section); if (!section) { // List available sections to help the user const allSections = storageManager.parseSections(memory.content); const sectionNames = allSections.map(s => s.name).join(', '); throw new Error( `Section '${params.section}' not found in memory document '${params.memory_id}'. ` + `Available sections: ${sectionNames}` ); } const sectionContent = section.content || '(This section is empty)'; return { content: [{ type: 'text', text: `## ${section.name} ${sectionContent} --- *From memory document: ${params.memory_id}* *Last updated: ${memory.metadata.updated}*` }] }; }
- src/types/memory.ts:42-45 (schema)TypeScript interface for GetSectionParams used to type-check tool inputs.export interface GetSectionParams { memory_id: string; section: string; }
- src/index.ts:83-99 (registration)MCP tool registration: defines name, description, and JSON input schema for get_section.name: "get_section", description: "Retrieve a specific section from a memory document", inputSchema: { type: "object", properties: { memory_id: { type: "string", description: "The ID of the memory document to read from", }, section: { type: "string", description: "The section name to retrieve", }, }, required: ["memory_id", "section"], }, },
- src/index.ts:265-266 (registration)Switch case in tool call handler that routes get_section calls to the getSectionTool implementation.case "get_section": return await getSectionTool(storageManager, args);
- src/index.ts:12-12 (registration)Import of the getSectionTool handler function.import { getSectionTool } from "./tools/getSection.js";