Skip to main content
Glama

peek_context

View parent tasks and previous steps to understand the current task's purpose and maintain context in hierarchical task management systems.

Instructions

Look at parent task and previous sibling without changing focus (understand WHY you're doing current task)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
include_bodyNoInclude task body content

Implementation Reference

  • Main handler function that peeks at parent and immediate context tasks, formats them optionally including body, and returns as dict.
    async def handle_peek_context(self, include_body: bool = False) -> Dict[str, Any]:
        parent, immediate = self.task_manager.peek_context()
    
        def format_task(task: Optional[Task]) -> Optional[Dict[str, Any]]:
            if not task:
                return None
            result = {
                "id": task.id,
                "title": task.title,
                "status": task.status.value,
                "created_at": task.created_at.isoformat(),
            }
            if include_body:
                result["body"] = task.body
            if task.completed_at:
                result["completed_at"] = task.completed_at.isoformat()
            return result
    
        return {
            "parent_context": format_task(parent),
            "immediate_context": format_task(immediate),
        }
  • Tool schema definition including input schema for include_body parameter.
    Tool(
        name="peek_context",
        description="Look at parent task and previous sibling without changing focus (understand WHY you're doing current task)",
        inputSchema={
            "type": "object",
            "properties": {
                "include_body": {
                    "type": "boolean",
                    "description": "Include task body content",
                    "default": False,
                }
            },
        },
    ),
  • src/server.py:67-69 (registration)
    Registration of the peek_context tool in the server handler map, mapping to the handlers.handle_peek_context method.
    "peek_context": lambda: handlers.handle_peek_context(
        arguments.get("include_body", False)
    ),
  • Helper method in TaskManager that returns the parent task and immediate previous context (sibling or previous main task).
    def peek_context(self) -> Tuple[Optional[Task], Optional[Task]]:
        current = self.current_task
        if not current:
            return None, None
    
        if isinstance(current, SubTask):
            last_main_task = self.global_tasks[-1]
            siblings = self.get_siblings_to_left()
            immediate_context = siblings[-1] if siblings else None
            return last_main_task, immediate_context
        else:
            if len(self.global_tasks) > 1:
                prev_main_task = self.global_tasks[-2]
                prev_immediate_context: Task = (
                    prev_main_task.sub_tasks[-1]
                    if prev_main_task.sub_tasks
                    else prev_main_task
                )
                return prev_main_task, prev_immediate_context
            return None, 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/cheezcake/aidderall_mcp'

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