Skip to main content
Glama

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';

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