Skip to main content
Glama

set_session_name

Rename an iTerm2 session to a specified name. Optionally target a specific session by UUID, otherwise renames the active session.

Instructions

Set the title/name of an iTerm2 session.

:param name: The new session name. :param session_id: Target session UUID. Defaults to the active session.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
session_idNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The async handler function for the 'set_session_name' tool. Accepts a name and optional session_id, resolves the session via _session(), calls async_set_name() on it, and returns a confirmation string.
    async def set_session_name(name: str, session_id: str | None = None) -> str:
        """Set the title/name of an iTerm2 session.
    
        :param name: The new session name.
        :param session_id: Target session UUID. Defaults to the active session.
        """
        sess = await _session(session_id)
        await sess.async_set_name(name)
        return f"Renamed session {sess.session_id} to {name!r}"
  • Registration of the tool via the @mcp.tool() decorator on the set_session_name function.
    @mcp.tool()
  • The _session() helper used by set_session_name to resolve a session_id (or fall back to the active session).
    async def _session(session_id: str | None) -> iterm2.Session:
        """Resolve a session by ID, falling back to the currently active session.
    
        :param session_id: A specific session UUID to target, or ``None`` to use the
            currently focused window/tab/pane.
        """
        app = await _app()
        if session_id:
            sess = app.get_session_by_id(session_id)
            if sess is None:
                raise ValueError(f"No session found with ID {session_id!r}")
            return sess
        win = app.current_terminal_window
        if win is None:
            raise RuntimeError("No active iTerm2 window.")
        tab = win.current_tab
        if tab is None:
            raise RuntimeError("No active tab in the current window.")
        sess = tab.current_session
        if sess is None:
            raise RuntimeError("No active session in the current tab.")
        return sess
  • Type signature and docstring defining the input schema: name (str, required), session_id (str | None, optional).
    async def set_session_name(name: str, session_id: str | None = None) -> str:
        """Set the title/name of an iTerm2 session.
    
        :param name: The new session name.
        :param session_id: Target session UUID. Defaults to the active session.
        """
Behavior2/5

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

No annotations are present, so the description carries full burden. It only states the action ('Set the title/name') without disclosing side effects, permissions required, or what happens to existing titles. For a mutation tool, this is inadequate.

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

Conciseness4/5

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

The description is short and includes param docs in a structured docstring format. However, it could be more concise by omitting the redundant 'title/name' phrase. Still, it earns its keep without fluff.

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 no annotations and an output schema (unmentioned), the description is somewhat incomplete. It doesn't explain return values, validation of session_id format, or error conditions. However, for a simple setter, the param coverage partly compensates.

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 schema has 0% description coverage, so the param docs in the description add significant meaning: 'name' is the new session name, 'session_id' is the target session UUID with a default of active session. This clarifies the role and default behavior beyond the raw schema.

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 the tool sets a title/name on an iTerm2 session, using a specific verb ('Set') and resource ('title/name of an iTerm2 session'). It distinguishes itself from sibling tools like 'set_badge' (which sets a badge) and 'close_session' (which destroys a session).

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?

No guidance is provided on when to use this tool versus siblings (e.g., 'set_badge' for badge, 'get_variable' for reading). There is no mention of prerequisites, context, or scenarios where alternatives are better.

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