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,
        };
      }
    });
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool creates a document, implying a write operation, but lacks details on permissions required, whether it overwrites existing files, error handling (e.g., invalid filepaths), or response format. This leaves significant gaps for a mutation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero wasted words. It front-loads the core purpose ('Create a new Word document') and includes the key optional parameter, making it appropriately sized and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool with no annotations and no output schema, the description is incomplete. It doesn't explain what happens after creation (e.g., does it return a document ID, save automatically, or require 'save_document'?), error conditions, or interactions with sibling tools, leaving the agent with insufficient context for reliable use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both parameters fully. The description adds minimal value by mentioning the 'title' parameter as optional, but doesn't provide additional context beyond what's in the schema (e.g., format examples for 'filepath' or default behavior if 'title' is omitted).

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Create a new Word document') and resource ('Word document'), with the optional 'title' parameter mentioned. However, it doesn't differentiate from sibling tools like 'add_paragraph' or 'save_document' which also modify documents, making it less specific than a perfect score would require.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., whether a document must be open first), exclusions, or relationships with sibling tools like 'save_document' for saving existing documents or 'add_paragraph' for modifying content.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/bibash44/word-documet-mcp-server'

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