Skip to main content
Glama

get_subtasks

Extract subtasks from Notion task pages to manage project workflows. Parses task body content to retrieve subtask names, status, and priority for organized tracking.

Instructions

获取任务的子目标列表(解析任务页面 body 中的子目标 Markdown)。

Args: task_id: 任务的 Notion 页面 ID

Returns: 子目标列表 [{name, status, priority}],status: todo | doing | done

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
task_idYes

Implementation Reference

  • The workflow tool handler that calls the Notion client to retrieve subtasks.
    def get_subtasks(task_id: str) -> list[dict]:
        """
        获取任务的子目标列表(解析任务页面 body 中的子目标 Markdown)。
    
        Args:
            task_id: 任务的 Notion 页面 ID
    
        Returns:
            子目标列表 [{name, status, priority}],status: todo | doing | done
        """
        subtasks = get_client().get_subtasks(task_id)
        return [s.model_dump() for s in subtasks]
  • server.py:44-44 (registration)
    Registration of the get_subtasks function as an MCP tool.
    mcp.tool(get_subtasks)
  • The actual implementation of parsing subtasks from Notion page blocks.
    def get_subtasks(self, task_id: str) -> list[Subtask]:
        """Parse subtasks from the ## 子目标 section in a task page body."""
        blocks = self._get_all_child_blocks(task_id)
        start, end = self._find_subtask_section(blocks)
        if start is None:
            return []
    
        section = blocks[start + 1 : end]  # skip heading itself
        subtasks: list[Subtask] = []
        for block in section:
            if block.get("type") != "paragraph":
                continue
            rich_text = block.get("paragraph", {}).get("rich_text", [])
            text = "".join(t["plain_text"] for t in rich_text)
            m = self._SUBTASK_RE.match(text)
            if m:
                status_char, name, priority_str = m.group(1), m.group(2), m.group(3)
                status = self._SUBTASK_STATUS_MAP.get(status_char, SubtaskStatus.TODO)
                priority = TaskPriority(priority_str) if priority_str else TaskPriority.NORMAL
                subtasks.append(Subtask(name=name, status=status, priority=priority))
        return subtasks
    
    def update_subtasks(self, task_id: str, subtasks: list[Subtask]) -> list[Subtask]:
        """Rewrite the ## 子目标 section in the task page body."""
        blocks = self._get_all_child_blocks(task_id)
        start, end = self._find_subtask_section(blocks)
    
        # Delete old section blocks (heading + content within boundaries)
        if start is not None:

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/wauwaya/notion-workflow-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server