Skip to main content
Glama

save_document

Save Microsoft Word documents to disk to preserve edits and formatting changes made during programmatic manipulation.

Instructions

Save the document to disk

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
docIdYesDocument identifier

Implementation Reference

  • MCP tool handler for 'save_document': calls documentManager.saveDocument(args.docId) and returns formatted success response with filepath.
    case "save_document": const filepath = await documentManager.saveDocument(args.docId); return { content: [ { type: "text", text: `Document saved successfully to: ${filepath}`, }, ], };
  • Tool schema definition for 'save_document', including inputSchema requiring 'docId'.
    { 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 all tools including 'save_document' via documentTools export for ListToolsRequestHandler.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: documentTools, }; });
  • Core implementation of document saving logic: recreates Document from in-memory paragraphs, packs to buffer, writes to 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; }
  • General tool call handler registration that dispatches to specific handleToolCall based on tool name, including 'save_document'.
    server.setRequestHandler(CallToolRequestSchema, async (request) => { try { const result = await handleToolCall(request.params.name, request.params.arguments); return result; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Error: ${errorMessage}`, }, ], isError: true, }; } });

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