Skip to main content
Glama

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
NameRequiredDescriptionDefault
docIdYesDocument identifier

Implementation Reference

  • Handler logic in the tool dispatcher function handleToolCall that invokes documentManager.getDocumentStructure for the given docId and formats the result as MCP content response.
    case "get_document_structure": const structure = documentManager.getDocumentStructure(args.docId); return { content: [ { type: "text", text: `Document structure:\n${structure}`, }, ], };
  • Tool definition including name, description, and input schema requiring 'docId' parameter.
    { 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/index.ts:24-28 (registration)
    Registration of tool list handler that returns the documentTools array, which includes the get_document_structure tool.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: documentTools, }; });
  • Helper method in DocumentManager class that generates the document structure outline by extracting paragraph styles and truncated text.
    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"); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/bibash44/word-documet-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server