Skip to main content
Glama

save_document

Save Microsoft Word documents to disk for persistent storage and future access. This tool stores documents with their formatting, tables, and content intact.

Instructions

Save the document to disk

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
docIdYesDocument identifier

Implementation Reference

  • The handler function for the 'save_document' tool. It calls documentManager.saveDocument with the provided docId and returns a success message with the saved filepath.
    case "save_document": const filepath = await documentManager.saveDocument(args.docId); return { content: [ { type: "text", text: `Document saved successfully to: ${filepath}`, }, ], };
  • Input schema definition for the 'save_document' tool, specifying that it requires a 'docId' string parameter.
    { name: "save_document", description: "Save the document to disk", inputSchema: { type: "object", properties: { docId: { type: "string", description: "Document identifier", }, }, required: ["docId"], }, },
  • src/index.ts:24-28 (registration)
    Registers the list of available tools (from documentTools array, which includes 'save_document') with the MCP server for the ListToolsRequest.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: documentTools, }; });
  • Core implementation of saving the document: reconstructs the DOCX from in-memory paragraphs using docx library, writes buffer to file, returns filepath.
    async saveDocument(docId: string): Promise<string> { const docInfo = this.getDocument(docId); // Recreate document with all paragraphs const document = new Document({ sections: [ { properties: {}, children: docInfo.paragraphs, }, ], }); const buffer = await Packer.toBuffer(document); await fs.writeFile(docInfo.filepath, buffer); return docInfo.filepath; }

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