Skip to main content
Glama

docx-save

Save DOCX files to a specified disk path using their unique ID. Enables document management by persisting changes and ensuring files are stored efficiently.

Instructions

Persist the docx to disk path by id.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYes
pathYes

Implementation Reference

  • Main execution logic for the 'docx-save' tool: parses input arguments, retrieves the DOCX buffer from the registry, ensures the output directory exists, writes the file, and returns success info.
    case "docx-save": { const { id, path: outPath } = parseArgs<{ id: string; path: string }>(args, tools["docx-save"].inputSchema); const buf = await registry.packToBuffer(id); const dir = path.dirname(outPath); await mkdir(dir, { recursive: true }); await writeFile(outPath, buf); return ok({ id, path: outPath, bytes: buf.byteLength });
  • Input schema definition for the 'docx-save' tool, specifying required 'id' and 'path' parameters.
    "docx-save": { description: "Persist the docx to disk path by id.", inputSchema: { type: "object", required: ["id", "path"], properties: { id: { type: "string" }, path: { type: "string" } } }
  • Helper method in DocRegistry that converts the in-memory Document object to a Uint8Array buffer using docx Packer, used by the docx-save handler.
    } async packToBuffer(id: DocId): Promise<Uint8Array> { const cur = this.require(id); return await Packer.toBuffer(cur.doc);
  • Utility function to validate and parse tool arguments against the schema, used in all tool handlers including docx-save.
    function parseArgs<T>(args: unknown, schema: any): T { const validate = ajv.compile(schema); if (!validate(args)) { throw new McpError(ErrorCode.InvalidParams, ajv.errorsText(validate.errors)); } return args as T;

Other Tools

Related 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/lihongjie0209/docx-mcp'

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