rework-mcp-server
Version:
Rework MCP Server - Integrate rework tasks with AI through Model Context Protocol
63 lines (62 loc) • 3.28 kB
JavaScript
import { reworkProjectFetcher } from '../../../utils/api/fetcher.js';
import Responder from '../../../utils/responder.js';
/**
* Tool definition for creating a single task
*/
import { z } from 'zod';
// Define the Zod schema for creating a task
export const getTasksSchema = {
q: z.string().optional().describe("Optional search query to filter tasks by name."),
board_id: z.string().optional().describe("Optional ID of the board that the tasks belong to."),
project_id: z.string().optional().describe("Optional ID of the project that the tasks belong to."),
deadline_from: z.string().optional().describe("Optional deadline from. Supports Unix timestamps (seconds)"),
deadline_to: z.string().optional().describe("Optional deadline to. Supports Unix timestamps (seconds)"),
page: z.number().optional().describe("Optional page number. Defaults to 0, each page has 100 tasks"),
created_from: z.string().optional().describe("Optional created from. Supports Unix timestamps (seconds)"),
created_to: z.string().optional().describe("Optional created to. Supports Unix timestamps (seconds)"),
creator: z.string().optional().describe("Optional username of the creator. This will be used to indicate the task creator."),
assign: z.string().optional().describe("Optional user ID of the assignee. This will be used to assign the task to the user."),
status: z.enum([TaskStatus.ACTIVE, TaskStatus.DONE, TaskStatus.REVIEW, TaskStatus.TODO, TaskStatus.DOING, TaskStatus.DONELATE, TaskStatus.OVERDUE, TaskStatus.NOTREVIEW, TaskStatus.TODAY]).optional().describe("Optional status of the tasks. Can be one of: 'active' (not done), 'done', 'review' (In review process), 'todo' (not started), 'doing' (started), 'donelate' (completed after deadline), 'overdue' (not done and past deadline), 'notreview' (not in review), 'today' (due today)"),
};
export const getTasksTool = {
name: "get_tasks",
description: `Get tasks from a all boards. Can filtered by q, board_id, project_id, deadline_from, deadline_to, created_from, created_to, page, creator, assign, status`,
inputSchema: getTasksSchema
};
/**
* Handler for creating a task
*/
export async function getBoardsHandler(params) {
const { q, board_id, project_id, deadline_from, deadline_to, created_from, created_to, page, creator, assign, status } = params;
// Prepare task data
const taskData = {};
// Add optional fields if they exist
if (q)
taskData.q = q;
if (board_id)
taskData.board_id = board_id;
if (project_id)
taskData.project_id = project_id;
if (deadline_from)
taskData.deadline_from = deadline_from;
if (deadline_to)
taskData.deadline_to = deadline_to;
if (created_from)
taskData.created_from = created_from;
if (created_to)
taskData.created_to = created_to;
if (page)
taskData.page = page;
if (creator)
taskData.creator = creator;
if (assign)
taskData.assign = assign;
if (status)
taskData.status = status;
// Use the fetcher to create the task
const data = await reworkProjectFetcher.request({
endpoint: '/projects/v1/task/list',
data: taskData
});
return Responder.createResponse(data);
}