Skip to main content
Glama

create_document

Create new Microsoft Word documents with custom titles and save them to specified file paths for document management and content creation.

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

  • Tool schema definition including inputSchema for create_document with 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"], }, },
  • Handler case in handleToolCall function that invokes documentManager.createDocument and returns success message with docId.
    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.`, }, ], };
  • Core implementation of createDocument in DocumentManager class: generates docId, creates empty docx Document with optional title heading, stores in memory map.
    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; }
  • src/index.ts:24-28 (registration)
    MCP server registration of tools list handler returning the documentTools array containing create_document.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: documentTools, }; });
  • src/index.ts:31-47 (registration)
    MCP server registration of tool call handler dispatching to handleToolCall based on tool name.
    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