add_task
Create new tasks in your revenue management system with descriptions, priorities, due dates, and time estimates for organized business operations.
Instructions
Add a new task
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dueDate | No | YYYY-MM-DD | |
| estimatedHours | No | ||
| notes | No | ||
| priority | No | ||
| relatedTo | No | ||
| taskDescription | Yes |
Implementation Reference
- index.js:654-656 (handler)Handler for the 'add_task' MCP tool. Dispatches tool arguments to the external Google Apps Script API via the callAPI helper function with action 'addTask'.case "add_task": result = await callAPI("addTask", args); break;
- index.js:267-278 (schema)Input schema validation for the 'add_task' tool, defining parameters like taskDescription (required), priority, dueDate, etc.inputSchema: { type: "object", properties: { taskDescription: { type: "string" }, priority: { type: "string", enum: ["High", "Medium", "Low"] }, dueDate: { type: "string", description: "YYYY-MM-DD" }, relatedTo: { type: "string" }, estimatedHours: { type: "number" }, notes: { type: "string" }, }, required: ["taskDescription"], },
- index.js:264-279 (registration)Registration of the 'add_task' tool in the MCP server's listTools response, including name, description, and input schema.{ name: "add_task", description: "Add a new task", inputSchema: { type: "object", properties: { taskDescription: { type: "string" }, priority: { type: "string", enum: ["High", "Medium", "Low"] }, dueDate: { type: "string", description: "YYYY-MM-DD" }, relatedTo: { type: "string" }, estimatedHours: { type: "number" }, notes: { type: "string" }, }, required: ["taskDescription"], }, },
- index.js:74-131 (helper)Generic helper function callAPI that handles HTTP POST requests to the Google Apps Script backend. Used by the 'add_task' handler and other API tools to execute the actual 'addTask' action remotely.async function callAPI(action, data = {}) { debugLog('=== API CALL START ==='); debugLog(`Action: ${action}`); debugLog(`Data: ${JSON.stringify(data)}`); try { // Build form-encoded body for POST const formData = new URLSearchParams(); formData.append('action', action); // Add all data fields to form for (const [key, value] of Object.entries(data)) { if (value !== undefined && value !== null) { formData.append(key, value.toString()); } } const formString = formData.toString(); debugLog(`FormData: ${formString}`); debugLog(`API_URL: ${API_URL}`); // Use POST with proper content type const response = await fetch(API_URL, { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, body: formString }); debugLog(`Response status: ${response.status}`); debugLog(`Response ok: ${response.ok}`); if (!response.ok) { debugLog(`Response not OK: ${response.status} ${response.statusText}`); throw new Error(`API request failed: ${response.status} ${response.statusText}`); } const text = await response.text(); debugLog(`Response text length: ${text.length}`); debugLog(`Response text: ${text}`); if (!text) { debugLog('ERROR: Empty response from API'); throw new Error('Empty response from API'); } const parsed = JSON.parse(text); debugLog(`Parsed successfully: ${JSON.stringify(parsed)}`); debugLog('=== API CALL END ==='); return parsed; } catch (error) { debugLog(`ERROR in callAPI: ${error.message}`); debugLog(`ERROR stack: ${error.stack}`); throw error; } }