create_window
Launch a new iTerm2 window. Optionally run a shell command or select a profile.
Instructions
Create a new iTerm2 window.
:param command: Optional shell command to run in the new session. :param profile: Name of the iTerm2 profile to use. Defaults to the default profile.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| command | No | ||
| profile | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/iterm2_mcp/server.py:276-293 (handler)The create_window tool handler - creates a new iTerm2 window. Uses @mcp.tool() decorator (FastMCP) with optional 'command' and 'profile' parameters. Calls iterm2.Window.async_create() and returns the window ID and session ID on success.
@mcp.tool() async def create_window( command: str | None = None, profile: str | None = None, ) -> str: """Create a new iTerm2 window. :param command: Optional shell command to run in the new session. :param profile: Name of the iTerm2 profile to use. Defaults to the default profile. """ conn = await _connection_singleton() win = await iterm2.Window.async_create(conn, profile=profile, command=command) if win is None: return "Error: failed to create window." sess = win.current_tab.current_session if win.current_tab else None suffix = f", session {sess.session_id}" if sess else "" return f"Created window {win.window_id}{suffix}" - src/iterm2_mcp/server.py:21-21 (registration)The FastMCP server instance 'mcp' is created here. The @mcp.tool() decorator on line 276 registers the create_window tool.
mcp = FastMCP("iterm2-mcp")