freedcamp_add_task
Create new tasks in Freedcamp with title, description, priority, due date, and assignee. Supports bulk operations for adding multiple tasks simultaneously.
Instructions
Create one or more new tasks in Freedcamp with support for title, description, priority, due date, and assignee. Supports bulk operations for creating multiple tasks at once.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tasks | Yes |
Implementation Reference
- src/mcpServer.ts:145-154 (handler)The main execution handler for the freedcamp_add_task tool. It extracts the tasks array from args, builds authentication parameters, processes each task using processSingleAddTask in parallel, and formats the results as content blocks.async (args) => { const tasksToAdd = args.tasks; const authParams = buildFreedcampAuthParams({ api_key: config.apiKey, api_secret: config.apiSecret, }); const results = await Promise.all(tasksToAdd.map((taskArg: any) => processSingleAddTask(taskArg, authParams, config.projectId))); return { content: results.map(r => ({ type: "text", text: JSON.stringify(r) })) }; }
- src/mcpServer.ts:14-20 (schema)Zod schema defining the structure for a single task input, used within the tool's inputSchema as z.array(singleAddTaskSchema).const singleAddTaskSchema = z.object({ title: z.string().describe("Title of the task (required) - should be clear and descriptive"), description: z.string().optional().describe("Detailed description of what the task involves (optional)"), due_date: z.string().optional().describe("Due date as Unix timestamp string (optional) - e.g., '1735689600' for 2025-01-01"), assigned_to_id: z.string().optional().describe("User ID to assign the task to (optional) - must be valid Freedcamp user ID"), priority: z.number().int().min(0).max(3).optional().describe("Task priority level (optional): 0=Low, 1=Normal, 2=High, 3=Urgent") });
- src/mcpServer.ts:135-155 (registration)The server.registerTool call that registers the freedcamp_add_task tool, including its description, input schema, annotations, and handler function.server.registerTool("freedcamp_add_task", { description: "Create one or more new tasks in Freedcamp with support for title, description, priority, due date, and assignee. Supports bulk operations for creating multiple tasks at once.", inputSchema: { tasks: z.array(singleAddTaskSchema) }, annotations: { title: "Create Task" } }, async (args) => { const tasksToAdd = args.tasks; const authParams = buildFreedcampAuthParams({ api_key: config.apiKey, api_secret: config.apiSecret, }); const results = await Promise.all(tasksToAdd.map((taskArg: any) => processSingleAddTask(taskArg, authParams, config.projectId))); return { content: results.map(r => ({ type: "text", text: JSON.stringify(r) })) }; } );
- src/mcpServer.ts:67-89 (helper)Core helper function that implements the logic for adding a single task: constructs the request data, invokes the Freedcamp API via executeFreedcampRequest, processes the response, and returns formatted result or error.async function processSingleAddTask(taskArgs: z.infer<typeof singleAddTaskSchema>, authParams: Record<string, string>, projectId: string) { try { const data: Record<string, any> = { project_id: projectId, title: taskArgs.title, }; if (taskArgs.description) data.description = taskArgs.description; if (taskArgs.due_date) data.due_date = taskArgs.due_date; if (taskArgs.assigned_to_id) data.assigned_to_id = taskArgs.assigned_to_id; if (typeof taskArgs.priority === "number") data.priority = taskArgs.priority; const result = await executeFreedcampRequest("https://freedcamp.com/api/v1/tasks", "POST", authParams, data); if (result.error) { return { type: "text", text: `Error adding task "${taskArgs.title}": ${result.error}`, details: result.details }; } const taskId = result.data?.tasks?.[0]?.id; return { type: "text", text: `Task "${taskArgs.title}" created with ID: ${taskId}`, task_id: taskId }; } catch (err: any) { console.error(`Error processing add task "${taskArgs.title}":`, err); return { type: "text", text: `Failed to add task "${taskArgs.title}": ${err.message}`, error_details: err }; } }
- src/mcpServer.ts:35-65 (helper)Shared utility function for making authenticated HTTP requests to the Freedcamp API using FormData for POST/PUT/DELETE operations.async function executeFreedcampRequest(url: string, method: string, authParams: Record<string, string>, bodyData?: Record<string, any>) { const form = new FormData(); if (bodyData) { form.append("data", JSON.stringify(bodyData)); } for (const [k, v] of Object.entries(authParams)) { form.append(k, v); } let requestUrl = url; let requestBody: any = form; if (method === "DELETE" && !bodyData) { const params = new URLSearchParams(authParams); requestUrl = `${url}?${params.toString()}`; requestBody = undefined; } console.log(`Making ${method} request to Freedcamp API: ${requestUrl}`); const resp = await fetch(requestUrl, { method: method, body: requestBody, }); const json = (await resp.json()) as any; console.log("Freedcamp API response:", json); if (!resp.ok || (json && json.http_code >= 400)) { return { error: json?.msg || resp.statusText, details: json }; } return { success: true, data: json?.data }; }