Skip to main content
Glama

list_sessions

List all iTerm2 windows, tabs, and sessions, returning a tree with session IDs. Highlights the focused window, tab, and session with an asterisk.

Instructions

List all iTerm2 windows, tabs, and sessions.

Returns a tree with session IDs that can be passed to other tools. The * marker shows the currently focused window, tab, and session.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Handler for the 'list_sessions' MCP tool. Iterates over iTerm2 windows, tabs, and sessions, building an indented tree string. Marks the currently focused window/tab/session with '*'. Returns a descriptive string.
    @mcp.tool()
    async def list_sessions() -> str:
        """List all iTerm2 windows, tabs, and sessions.
    
        Returns a tree with session IDs that can be passed to other tools. The
        ``*`` marker shows the currently focused window, tab, and session.
        """
        app = await _app()
        out: list[str] = []
        for win in app.terminal_windows:
            is_active_win = win is app.current_terminal_window
            out.append(f"Window {win.window_id}{' *' if is_active_win else ''}")
            for tab in win.tabs:
                is_active_tab = is_active_win and tab is win.current_tab
                out.append(f"  Tab {tab.tab_id}{' *' if is_active_tab else ''}")
                for sess in tab.sessions:
                    is_active_sess = is_active_tab and sess is tab.current_session
                    name = sess.name or ""
                    out.append(
                        f"    Session {sess.session_id}{' *' if is_active_sess else ''}  [{name}]"
                    )
        return "\n".join(out) if out else "(no iTerm2 windows open)"
  • Registration: the @mcp.tool() decorator on line 80 registers 'list_sessions' with the FastMCP server.
    @mcp.tool()
Behavior4/5

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

No annotations provided, but the description discloses the return format (tree with IDs) and the presence of a focused marker. It does not cover possible side effects, but being a read-only listing, this is sufficient.

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 two sentences with the key information front-loaded. Every sentence serves a purpose with no wasted words.

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

Completeness5/5

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

Given the tool's simplicity (no parameters, clear output), the description provides all necessary information: what is listed, the return format, and the marker meaning.

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

Parameters4/5

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

The tool has no parameters, so the baseline is 4. The description does not need to add parameter information.

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

Purpose5/5

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

The description clearly states it lists all windows, tabs, and sessions, and mentions it returns a tree with session IDs and a marker for the focused item, distinguishing it from siblings like get_active_session.

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

Usage Guidelines4/5

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

The description implies usage by stating session IDs can be passed to other tools, but does not explicitly state when to use or provide alternatives. However, the context is clear enough for a listing tool.

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/lorencarvalho/iterm2-mcp'

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