Tools Reference

Complete reference for all 23 MCP tools exposed by Forge, organized in 7 categories.

Categories

Session Lifecycle

create_terminal, create_from_template, spawn_claude, spawn_codex, spawn_gemini, close_terminal, close_group, list_terminals, list_templates

I/O

write_terminal, read_terminal, read_screen, read_multiple, send_control, resize_terminal

Search & Wait

grep_terminal, wait_for

Execution

run_command

Events

subscribe_events, unsubscribe_events

Agent Delegation

delegate_task

Ops

health_check, get_session_history, clear_history

Session Lifecycle

create_terminal

Create a new persistent terminal session. Returns session info including the id used by all other tools.

ParameterTypeDefaultDescription
commandstringUser's $SHELLCommand to run
argsstring[][]Command arguments
cwdstringProcess cwdWorking directory
envobject{}Additional env vars
colsnumber120Terminal width
rowsnumber24Terminal height
namestringHuman-readable name
tagsstring[]Tags for filtering (max 10)
bufferSizenumberServer defaultRing buffer size (1KB–10MB)

create_from_template

Create a terminal session from a predefined template.

ParameterTypeDefaultDescription
templatestringrequiredTemplate name
cwdstringWorking directory override
envobjectAdditional env vars
namestringTemplate nameSession name override

spawn_claude

Spawn a Claude Code sub-agent in its own terminal session.

ParameterTypeDefaultDescription
promptstringrequiredPrompt to send
cwdstringWorking directory
fromSessionstringCopy cwd from existing session
modelstringModel (e.g. "sonnet", "opus")
namestringAutoSession name
tagsstring[]["claude-agent"]Tags
maxBudgetnumberMax budget in USD
bufferSizenumberServer defaultRing buffer size
worktreebooleanfalseCreate git worktree
branchstringBranch name for worktree
oneShotbooleanfalseRun in --print mode

spawn_codex

Spawn a Codex sub-agent. Same parameters as spawn_claude but for Codex. Tags default to ["codex-agent"].

ParameterTypeDefaultDescription
promptstringrequiredPrompt to send
cwdstringWorking directory
fromSessionstringCopy cwd from existing session
modelstringModel override
namestringAutoSession name
tagsstring[]["codex-agent"]Tags
maxBudgetnumberMax budget in USD
bufferSizenumberServer defaultRing buffer size
worktreebooleanfalseCreate git worktree
branchstringBranch name for worktree
oneShotbooleanfalseRun in --print mode

spawn_gemini

Spawn a Gemini CLI sub-agent. Same parameters as spawn_claude but for Gemini CLI. Tags default to ["gemini-agent"].

ParameterTypeDefaultDescription
promptstringrequiredPrompt to send
cwdstringWorking directory
fromSessionstringCopy cwd from existing session
modelstringModel override
namestringAutoSession name
tagsstring[]["gemini-agent"]Tags
maxBudgetnumberMax budget in USD
bufferSizenumberServer defaultRing buffer size
worktreebooleanfalseCreate git worktree
branchstringBranch name for worktree
oneShotbooleanfalseRun in --print mode

close_terminal

Close a terminal session and clean up its resources.

ParameterTypeDefaultDescription
idstringrequiredSession ID

close_group

Close all terminal sessions matching a tag.

ParameterTypeDefaultDescription
tagstringrequiredTag to match

list_terminals

List all active terminal sessions, optionally filtered by tag.

ParameterTypeDefaultDescription
tagstringFilter by tag

list_templates

List all available session templates. No parameters.

I/O

write_terminal

Send text input to a terminal session.

ParameterTypeDefaultDescription
idstringrequiredSession ID
inputstringrequiredText to send
newlinebooleantrueAppend \n

read_terminal

Read incremental output from a terminal session. Returns { status, data, bytes, droppedBytes? }.

ParameterTypeDefaultDescription
idstringrequiredSession ID

read_screen

Read the current rendered viewport as plain text (no ANSI escape codes).

ParameterTypeDefaultDescription
idstringrequiredSession ID

read_multiple

Read output from multiple sessions in a single call.

ParameterTypeDefaultDescription
idsstring[]requiredSession IDs (1–20)
modestring"incremental""incremental" or "screen"

send_control

Send a control key or special key to a terminal session.

ParameterTypeDefaultDescription
idstringrequiredSession ID
keystringrequiredControl key name
Available keys: ctrl+c, ctrl+d, ctrl+z, ctrl+\, ctrl+l, ctrl+a, ctrl+e, ctrl+k, ctrl+u, ctrl+w, ctrl+r, ctrl+p, ctrl+n, up, down, right, left, home, end, tab, enter, escape, backspace, delete, pageup, pagedown

resize_terminal

Resize a terminal session's viewport.

ParameterTypeDefaultDescription
idstringrequiredSession ID
colsnumberrequiredNew width (1–500)
rowsnumberrequiredNew height (1–200)

grep_terminal

Search terminal output with regex. Returns { matches: [{ lineNumber, text, context? }], totalMatches }.

ParameterTypeDefaultDescription
idstringrequiredSession ID
patternstringrequiredRegex pattern
contextnumber0Context lines (0–10)

wait_for

Wait for a pattern to appear in terminal output or for the process to exit. Returns { matched, data?, reason?, elapsed }.

ParameterTypeDefaultDescription
idstringrequiredSession ID
patternstringRegex pattern
timeoutnumber30000Timeout ms (100–300000)
waitForExitbooleanfalseWait for exit instead

Execution

run_command

Run a command and wait for it to complete. Creates a temporary session, executes, and returns the output.

ParameterTypeDefaultDescription
commandstringrequiredCommand to run
cwdstringWorking directory
timeoutnumber300000Timeout ms (max 5min)

Events

subscribe_events

Subscribe to terminal events (exit, pattern match).

ParameterTypeDefaultDescription
idstringrequiredSession ID
eventsstring[]required["exit"] and/or ["pattern_match"]
patternstringRegex (required if pattern_match)

unsubscribe_events

Remove an event subscription.

ParameterTypeDefaultDescription
subscriptionIdstringrequiredSubscription ID

Agent Delegation

delegate_task

Delegate a task to a sub-agent (Claude or Codex) with optional git worktree isolation.

ParameterTypeDefaultDescription
promptstringrequiredTask prompt
agentstring"claude""claude" or "codex"
modestring"oneshot""oneshot" or "interactive"
sessionIdstringExisting session for follow-ups
cwdstringWorking directory
fromSessionstringCopy cwd from session
worktreebooleanfalseGit worktree isolation
branchstringBranch for worktree
modelstringModel override
fromstringOrchestrator attribution

Ops

health_check

Check server health. No parameters.

Returns { version, uptime, sessions: { active, max }, memory: { rss, heapUsed, heapTotal } }.

get_session_history

Get the command history for a session.

ParameterTypeDefaultDescription
idstringrequiredSession ID

clear_history

Clear all session history. No parameters.

MCP Resources

Sessions are also exposed as MCP resources, allowing clients to read session data through the standard resource protocol.

URI: terminal://sessions/{sessionId}