get_document_structure
Extract headings and paragraphs to analyze document organization and content flow in Word documents.
Instructions
Get the structure/outline of the document (headings and paragraphs)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| docId | Yes | Document identifier |
Implementation Reference
- src/tools/tool-handlers.ts:100-109 (handler)Handler for the 'get_document_structure' tool: calls documentManager.getDocumentStructure with docId from args and returns the structure as formatted text content.case "get_document_structure": const structure = documentManager.getDocumentStructure(args.docId); return { content: [ { type: "text", text: `Document structure:\n${structure}`, }, ], };
- Core implementation of document structure generation: retrieves document, iterates over paragraphs, extracts style and text preview, joins into string outline.getDocumentStructure(docId: string): string { const docInfo = this.getDocument(docId); const structure: string[] = []; docInfo.paragraphs.forEach((para: any, index) => { const style = para.properties?.style || "Normal"; let text = ""; if (para.root && para.root.length > 0) { text = para.root.map((r: any) => r.text || "").join(""); } if (text) { structure.push(`[${index}] ${style}: ${text.substring(0, 50)}...`); } }); return structure.join("\n"); }
- src/tools/document-tools.ts:187-199 (registration)Tool registration entry defining name, description, and input schema (docId required) for 'get_document_structure'.name: "get_document_structure", description: "Get the structure/outline of the document (headings and paragraphs)", inputSchema: { type: "object", properties: { docId: { type: "string", description: "Document identifier", }, }, required: ["docId"], }, },
- src/tools/document-tools.ts:189-199 (schema)Input schema validation for 'get_document_structure' tool: requires docId string.inputSchema: { type: "object", properties: { docId: { type: "string", description: "Document identifier", }, }, required: ["docId"], }, },