Skip to main content
Glama

get_footnotes

Read-only

Extract footnotes from DOCX files with IDs, numbers, text, and paragraph references for document analysis.

Instructions

Get all footnotes from the document with IDs, display numbers, text, and anchored paragraph IDs. Read-only.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYesPath to the DOCX file.

Implementation Reference

  • The MCP tool handler for "get_footnotes" that resolves the document session and calls `session.doc.getFootnotes()`.
    export async function getFootnotes(
      manager: SessionManager,
      params: {
        file_path?: string;
      },
    ): Promise<ToolResponse> {
      const resolved = await resolveSessionForTool(manager, params, { toolName: 'get_footnotes' });
      if (!resolved.ok) return resolved.response;
      const { session, metadata } = resolved;
    
      try {
        const footnotes = await session.doc.getFootnotes();
        return ok(mergeSessionResolutionMetadata({
          footnotes: footnotes.map((f) => ({
            id: f.id,
            display_number: f.displayNumber,
            text: f.text,
            anchored_paragraph_id: f.anchoredParagraphId,
          })),
          file_path: manager.normalizePath(session.originalPath),
        }, metadata));
      } catch (e: unknown) {
        return err('FOOTNOTE_ERROR', errorMessage(e));
      }
    }
  • The core implementation logic that parses OOXML footnotes and returns the data structure used by the MCP tool.
    export async function getFootnotes(zip: DocxZip, documentXml: Document): Promise<Footnote[]> {
      const footnotesText = await zip.readTextOrNull('word/footnotes.xml');
      if (!footnotesText) return [];
    
      const footnotesDoc = parseXml(footnotesText);
      const fnEls = footnotesDoc.getElementsByTagNameNS(OOXML.W_NS, W.footnote);
      if (fnEls.length === 0) return [];
    
      const displayMap = buildDisplayNumberMap(documentXml, footnotesDoc);
    
      // Build map of footnoteReference id → anchored paragraph bookmark id
      const anchorMap = new Map<number, string | null>();
      const refs = documentXml.getElementsByTagNameNS(OOXML.W_NS, W.footnoteReference);
      for (let i = 0; i < refs.length; i++) {
        const ref = refs.item(i) as Element;
        const idStr = getWAttr(ref, 'id');
        if (!idStr) continue;
        const id = parseInt(idStr, 10);
        if (anchorMap.has(id)) continue;
    
        // Walk up to enclosing <w:p>
        let parent = ref.parentNode;
        while (parent && parent.nodeType === 1) {
          const pel = parent as Element;
          if (pel.localName === W.p && pel.namespaceURI === OOXML.W_NS) {
            anchorMap.set(id, getParagraphBookmarkId(pel));
            break;
          }
          parent = parent.parentNode;
        }
      }
    
      const footnotes: Footnote[] = [];
    
      for (let i = 0; i < fnEls.length; i++) {
        const el = fnEls.item(i) as Element;
        if (isReservedFootnote(el)) continue;
    
        const idStr = getWAttr(el, 'id');
        if (!idStr) continue;
        const id = parseInt(idStr, 10);
    
        const text = extractFootnoteText(el);
        const displayNumber = displayMap.get(id) ?? 0;
        const anchoredParagraphId = anchorMap.get(id) ?? null;
    
        footnotes.push({ id, displayNumber, text, anchoredParagraphId });
      }
    
      // Sort by display number (document order)
      footnotes.sort((a, b) => a.displayNumber - b.displayNumber);
    
      return footnotes;
    }
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true. Description adds valuable return structure details (IDs, display numbers, text, anchored paragraph IDs) compensating for missing output schema. Clarifies it retrieves ALL footnotes. Does not mention auth needs or rate limits, but safety profile is covered by annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two efficient sentences. First sentence front-loads action and return value details; second confirms read-only nature. Zero waste. Appropriate length for tool complexity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple 1-parameter read operation with no output schema, the description comprehensively covers the return data structure (four specific fields). Combined with strong annotations, no critical information gaps remain.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema has 100% description coverage ('Path to the DOCX file'). Description does not mention file_path parameter, but with full schema coverage, the baseline 3 is appropriate—no additional parameter semantics needed in description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Specific verb 'Get' + resource 'footnotes' + scope 'all' clearly stated. Lists specific return fields (IDs, display numbers, text, anchored paragraph IDs). Distinct from siblings add_footnote, delete_footnote, and update_footnote which imply mutation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Implies read-only usage via verb choice and final 'Read-only' clause, but lacks explicit when-to-use guidance or named alternatives (e.g., doesn't state 'use add_footnote to create new footnotes'). Context is clear from naming but not explicitly guided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/UseJunior/safe-docx'

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