Skip to main content

Module 18: Terminal Operations

Execute shell commands on the client through the terminal API.

What You’ll Learn

  • The four-step terminal lifecycle: create, wait, output, release
  • Implementing terminal handlers on the client
  • Using the terminal API from the agent side

The Code

Client: Implement terminal handlers

Agent: Use terminal API

Terminal Lifecycle

The agent requests command execution, but the client controls what actually runs. This keeps command execution under the user’s control β€” the client decides whether to allow, sandbox, or deny terminal requests.
The SDK also provides context.execute() as a convenience method that combines all four steps.

Source Code

View on GitHub

Running the Example

Next Module

Module 19: MCP Servers β€” pass MCP server configurations to agents.