get_project_tasks
Retrieve tasks from a specific project using project ID. Optionally include closed tasks and subfolder tasks for comprehensive project tracking.
Instructions
Get tasks from a specific project.
Args: project_id: The ID of the project closed: Set to true to retrieve all open and closed tasks subfolders: Set to true to return tasks from project subfolders
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| closed | No | ||
| project_id | Yes | ||
| subfolders | No |
Implementation Reference
- goodday_mcp/main.py:393-423 (handler)The core handler function for the 'get_project_tasks' MCP tool. It fetches tasks from the Goodday API for a given project ID, handles optional parameters for closed tasks and subfolders, processes the response, and formats the output using helper functions.async def get_project_tasks(project_id: str, closed: bool = False, subfolders: bool = False) -> str: """Get tasks from a specific project. Args: project_id: The ID of the project closed: Set to true to retrieve all open and closed tasks subfolders: Set to true to return tasks from project subfolders """ params = [] if closed: params.append("closed=true") if subfolders: params.append("subfolders=true") endpoint = f"project/{project_id}/tasks" if params: endpoint += "?" + "&".join(params) data = await make_goodday_request(endpoint) if not data: return "No tasks found." if isinstance(data, dict) and "error" in data: return f"Unable to fetch tasks: {data.get('error', 'Unknown error')}" if not isinstance(data, list): return f"Unexpected response format: {str(data)}" tasks = [format_task(task) for task in data] return "\n---\n".join(tasks)
- goodday_mcp/main.py:94-113 (helper)Helper function used by get_project_tasks to format individual task data into a readable markdown string.def format_task(task: dict) -> str: """Format a task into a readable string with safe checks.""" if not isinstance(task, dict): return f"Invalid task data: {repr(task)}" # Defensive defaults in case nested keys are not dicts status = task.get('status') if isinstance(task.get('status'), dict) else {} project = task.get('project') if isinstance(task.get('project'), dict) else {} return f""" **Task ID:** {task.get('shortId', 'N/A')} **Title:** {task.get('name', 'N/A')} **Status:** {status.get('name', 'N/A')} **Project:** {project.get('name', 'N/A')} **Assigned To:** {task.get('assignedToUserId', 'N/A')} **Priority:** {task.get('priority', 'N/A')} **Start Date:** {task.get('startDate', 'N/A')} **End Date:** {task.get('endDate', 'N/A')} **Description:** {task.get('message', 'No description')} """.strip()
- goodday_mcp/main.py:15-57 (helper)Core helper function that makes authenticated HTTP requests to the Goodday API, used by get_project_tasks to fetch task data.async def make_goodday_request(endpoint: str, method: str = "GET", data: dict = None, subfolders: bool = True) -> dict[str, Any] | list[Any] | None: """Make a request to the Goodday API with proper error handling.""" api_token = os.getenv("GOODDAY_API_TOKEN") if not api_token: raise ValueError("GOODDAY_API_TOKEN environment variable is required") headers = { "User-Agent": USER_AGENT, "gd-api-token": api_token, "Content-Type": "application/json" } # Automatically add subfolders=true for project task and document endpoints if not already present if subfolders and endpoint.startswith("project/") and ("/tasks" in endpoint or "/documents" in endpoint): if "?" in endpoint: if "subfolders=" not in endpoint: endpoint += "&subfolders=true" else: endpoint += "?subfolders=true" url = f"{GOODDAY_API_BASE}/{endpoint.lstrip('/')}" async with httpx.AsyncClient() as client: try: if method.upper() == "POST": response = await client.post(url, headers=headers, json=data, timeout=30.0) elif method.upper() == "PUT": response = await client.put(url, headers=headers, json=data, timeout=30.0) elif method.upper() == "DELETE": response = await client.delete(url, headers=headers, timeout=30.0) else: response = await client.get(url, headers=headers, timeout=30.0) response.raise_for_status() return response.json() except httpx.HTTPStatusError as e: raise Exception(f"HTTP error {e.response.status_code}: {e.response.text}") except httpx.RequestError as e: raise Exception(f"Request error: {str(e)}") except Exception as e: raise Exception(f"Unexpected error: {str(e)}")