Skip to main content
Glama

get_session_state

Retrieve a unified snapshot of current session state including todos, git status, context files, and session information for programmatic session awareness.

Instructions

Get unified snapshot of current session state including todos, git status, context files, and session info.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
working_directoryNoWorking directory for git operations. Defaults to current directory.

Implementation Reference

  • The `_get_session_state` function gathers various pieces of information about the session (todos, git status, context files, and session duration) and returns them as a unified snapshot.
    async def _get_session_state(arguments: dict[str, Any]) -> dict:
        """Get unified session state."""
        working_dir = arguments.get("working_directory") or _get_working_directory()
    
        # Get transcript info
        transcript_parser = TranscriptParser()
        session_start = transcript_parser.get_session_start_time()
    
        # Get session ID from transcript path for todos
        session_id = None
        if transcript_parser.transcript_path:
            todo_parser = TodoParser()
            session_id = todo_parser.extract_session_id_from_transcript_path(
                transcript_parser.transcript_path
            )
    
        # Get todos
        todo_parser = TodoParser()
        if session_id:
            todos = todo_parser.get_todos_for_session(session_id)
        else:
            todos = todo_parser.get_latest_todos()
    
        # Get git state
        git = GitUtils(working_dir)
        git_state = git.get_state()
    
        # Get context files
        context_plan_path = git.get_context_plan_path()
        context_dir = git.get_context_dir()
    
        # Calculate session duration
        duration_minutes = None
        if session_start:
            delta = datetime.now(session_start.tzinfo) - session_start
            duration_minutes = int(delta.total_seconds() / 60)
    
        return {
            "todos": todos.to_dict(),
            "git": {
                "branch": git_state.branch,
                "has_uncommitted_changes": git_state.has_uncommitted_changes,
                "uncommitted_file_count": git_state.uncommitted_file_count,
                "is_git_repo": git_state.is_git_repo,
            },
            "context_files": {
                "branch_dir": str(context_dir) if context_dir else None,
                "plan_path": str(context_plan_path) if context_plan_path else None,
                "exists": context_plan_path is not None and context_plan_path.exists(),
            },
            "session": {
                "start_time": session_start.isoformat() if session_start else None,
                "duration_minutes": duration_minutes,
                "session_id": session_id,
            },
        }
  • The `get_session_state` tool is registered in the list_tools method of the MCP server, defining its name, description, and input schema.
    Tool(
        name="get_session_state",
        description="Get unified snapshot of current session state including todos, git status, context files, and session info.",
        inputSchema={
            "type": "object",
            "properties": {
                "working_directory": {
                    "type": "string",
                    "description": "Working directory for git operations. Defaults to current directory.",
                }
            },
            "required": [],
        },
    ),
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It describes what the tool returns (a snapshot of session state) but lacks details on behavioral traits such as whether it's read-only, if it requires specific permissions, how it handles errors, or if there are rate limits. This is a significant gap for a tool with no annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the key information ('Get unified snapshot of current session state') and lists specific components without unnecessary details. It is appropriately sized and has zero waste, making it easy for an agent to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (a state snapshot tool with one optional parameter), no annotations, and no output schema, the description is moderately complete. It specifies what the snapshot includes, but lacks details on output format, behavioral context, or usage guidelines. This is adequate as a minimum viable description but has clear gaps in providing full context for effective tool invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with one optional parameter ('working_directory') fully documented in the schema. The description does not add any meaning beyond the schema, as it does not mention parameters or their semantics. Given the high schema coverage, the baseline score of 3 is appropriate, as the schema handles the parameter documentation adequately.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with a specific verb ('Get') and resource ('unified snapshot of current session state'), listing key components like todos, git status, context files, and session info. However, it does not explicitly differentiate from sibling tools like 'get_session_history' or 'check_context_budget', which might also involve session-related data, leaving some ambiguity in sibling differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It does not mention any context for usage, such as when a snapshot is needed, or refer to sibling tools like 'get_session_history' for historical data or 'check_context_budget' for budget checks, leaving the agent without explicit usage instructions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/TimEvans/ccsession'

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