Skip to main content
Glama

create_document

Create a new Microsoft Word document with optional title and save it to a specified file path. This tool enables AI assistants to generate Word documents programmatically.

Instructions

Create a new Word document with optional title

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filepathYesFull path where document will be saved (e.g., /path/to/document.docx)
titleNoOptional title for the document

Implementation Reference

  • The MCP tool handler case for 'create_document': invokes DocumentManager.createDocument with filepath and title, returns the generated document ID in the response content.
    case "create_document": const docId = documentManager.createDocument(args.filepath, args.title); return { content: [ { type: "text", text: `Document created successfully with ID: ${docId}. Use this ID for all future operations on this document.`, }, ], };
  • Input schema definition for the 'create_document' tool, specifying filepath (required) and optional title.
    name: "create_document", description: "Create a new Word document with optional title", inputSchema: { type: "object", properties: { filepath: { type: "string", description: "Full path where document will be saved (e.g., /path/to/document.docx)", }, title: { type: "string", description: "Optional title for the document", }, }, required: ["filepath"], }, },
  • src/index.ts:24-28 (registration)
    MCP server registration of tools list via ListToolsRequestHandler, which includes the 'create_document' tool schema from documentTools.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: documentTools, }; });
  • Core helper function in DocumentManager class that creates an in-memory docx Document object, optionally adds title heading, stores it with generated ID, and returns the ID.
    createDocument(filepath: string, title?: string): string { const docId = `doc_${++this.idCounter}_${Date.now()}`; const sections: any[] = []; const paragraphs: Paragraph[] = []; if (title) { const titlePara = new Paragraph({ text: title, heading: HeadingLevel.TITLE, }); paragraphs.push(titlePara); } const document = new Document({ sections: [ { properties: {}, children: paragraphs, }, ], }); this.documents.set(docId, { id: docId, filepath, document, paragraphs, created: new Date(), }); return docId; }

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