Skip to main content
Glama
code-rabi

Mews MCP

by code-rabi

addTask

Create new tasks in Mews hospitality platform with details like name, description, department assignment, deadlines, and service order associations.

Instructions

Adds a new task to the enterprise, optionally to a specified department

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
NameYesTask name or title
DescriptionNoDetailed task description
DepartmentIdNoDepartment ID to assign the task to
ServiceOrderIdNoService order ID (reservation or product service order) to associate with
DeadlineUtcNoTask deadline (ISO 8601)
TypeNoTask type or category
StateNoInitial task state (defaults to Open)

Implementation Reference

  • The core handler function that validates input, prepares the API payload, calls the Mews API to add a task, and formats a success or error response.
    async execute(config: any, args: AddTaskParams) {
      try {
        // Validate required fields
        if (!args.Name || args.Name.trim().length === 0) {
          throw new Error('Task name is required and cannot be empty');
        }
    
        // If no deadline is provided, set a default deadline 1 week in the future
        let deadlineUtc = args.DeadlineUtc;
        if (!deadlineUtc) {
          const oneWeekFromNow = new Date();
          oneWeekFromNow.setDate(oneWeekFromNow.getDate() + 7);
          deadlineUtc = oneWeekFromNow.toISOString();
        }
    
        // Validate deadline format if provided
        const deadline = new Date(deadlineUtc);
        
        // Check if the date is valid
        if (isNaN(deadline.getTime())) {
          throw new Error('Invalid DeadlineUtc format. Please use ISO 8601 format (e.g., "2025-01-10T18:00:00Z")');
        }
    
        // Ensure deadline is in the future (allowing for some timezone flexibility)
        const now = new Date();
        const fiveMinutesFromNow = new Date(now.getTime() + (5 * 60 * 1000));
        
        if (deadline < fiveMinutesFromNow) {
          // Automatically adjust to 1 hour from now
          const oneHourFromNow = new Date(now.getTime() + (60 * 60 * 1000));
          deadlineUtc = oneHourFromNow.toISOString();
        }
    
        // Prepare request payload, excluding undefined fields
        const requestPayload: any = {
          Name: args.Name,
          DeadlineUtc: deadlineUtc
        };
    
        if (args.Description) requestPayload.Description = args.Description;
        if (args.DepartmentId) requestPayload.DepartmentId = args.DepartmentId;
        if (args.ServiceOrderId) requestPayload.ServiceOrderId = args.ServiceOrderId;
        if (args.Type) requestPayload.Type = args.Type;
        if (args.State) requestPayload.State = args.State;
    
        const response = await mewsRequest<any, AddTaskResponse>(
          config,
          '/api/connector/v1/tasks/add',
          requestPayload
        );
    
        const task = response.Task;
    
        return {
          content: [{
            type: 'text',
            text: `✅ **Task Created Successfully**\n\n` +
              `📋 **${task.Name}**\n` +
              `   Task ID: ${task.Id}\n` +
              `   State: ${task.State}\n` +
              `   Created: ${new Date(task.CreatedUtc).toLocaleString()}\n` +
              `   Department: ${task.DepartmentId || 'Not assigned'}\n` +
              `   Service Order: ${task.ServiceOrderId || 'None'}\n` +
              `   Type: ${task.Type || 'Not specified'}\n` +
              `   Deadline: ${task.DeadlineUtc ? new Date(task.DeadlineUtc).toLocaleString() : 'Not set'}\n` +
              `   Description: ${task.Description || 'No description'}\n\n` +
              `The task has been created and is ready for assignment and tracking.`
          }]
        };
      } catch (error) {
        return {
          content: [{
            type: 'text',
            text: `Error creating task: ${error instanceof Error ? error.message : 'Unknown error occurred'}`
          }]
        };
      }
    }
  • JSON schema defining the input parameters for the addTask tool, including types, descriptions, and required fields.
    inputSchema: {
      type: 'object',
      properties: {
        Name: {
          type: 'string',
          description: 'Task name or title'
        },
        Description: {
          type: 'string',
          description: 'Detailed task description'
        },
        DepartmentId: {
          type: 'string',
          description: 'Department ID to assign the task to'
        },
        ServiceOrderId: {
          type: 'string',
          description: 'Service order ID (reservation or product service order) to associate with'
        },
        DeadlineUtc: {
          type: 'string',
          description: 'Task deadline (ISO 8601)'
        },
        Type: {
          type: 'string',
          description: 'Task type or category'
        },
        State: {
          type: 'string',
          description: 'Initial task state (defaults to Open)'
        }
      },
      required: ['Name']
    },
  • TypeScript interface defining the expected parameters for the addTask tool handler.
    interface AddTaskParams {
      Name: string;
      Description?: string;
      DepartmentId?: string;
      ServiceOrderId?: string;
      DeadlineUtc?: string;
      Type?: string;
      State?: string;
    }
  • Registration of the addTaskTool in the central allTools array used for tool discovery and execution.
    // Task tools
    getAllTasksTool,
    addTaskTool,
  • Import statement that brings the addTaskTool into the index module for registration.
    import { addTaskTool } from './tasks/addTask.js';
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states it 'adds a new task' but doesn't disclose behavioral traits like required permissions, whether tasks are editable after creation, default values beyond State, error conditions, or what happens on success (e.g., returns a task ID). 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 that front-loads the core action ('Adds a new task') and includes a key optional feature ('optionally to a specified department'). There is no wasted verbiage or redundancy.

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 cover success responses, error handling, authentication needs, or system constraints. Given the complexity of adding tasks in an enterprise context, more behavioral and contextual information is needed.

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 all 7 parameters thoroughly. The description adds minimal value beyond implying optional department assignment, but doesn't provide additional context like parameter interactions or examples. Baseline 3 is appropriate when schema does the heavy lifting.

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 verb ('Adds') and resource ('new task to the enterprise'), making the purpose understandable. It distinguishes from siblings by focusing on tasks rather than other entities like companies or reservations, though it doesn't explicitly contrast with 'getAllTasks' or other task-related tools.

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 like 'getAllTasks' or 'update' operations. It mentions optional department assignment but doesn't specify prerequisites, dependencies, or contextual triggers for task creation.

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/code-rabi/mews-mcp'

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