Open History to see the last commit
1# Outside agents
2
3Agents that T3 Code did not start can work with an environment through its MCP
4server. They can read projects and threads, start and message threads, and
5check which providers and models are available. This covers Claude Code or
6Codex in your own terminal, ChatGPT, and bots that support MCP. Each agent signs
7in once, and you choose what it may do.
8
9## Add T3 Code to an assistant app
10
11Open the command palette (`Cmd/Ctrl+K`) and choose **Use T3 Code in another
12app (MCP)**, or use the button in **Settings → Sharing & access**. Pick the
13app and follow the step for that app. Assistants like
14Poke and Claude run in the cloud, so the wizard first asks you to sign in to T3
15Connect and turn it on for the environment. To reach your other machines through
16the same connection, turn on **Linked environments** in Labs and
17[link them](./remote-access.md#link-another-environment).
18
19When the app opens the sign-in page, choose what it may do and approve with your
20T3 Connect account. On an older environment, the wizard asks for the level and
21gives you a code to paste instead. A code works once, for 5 minutes, and
22approves only that level.
23
24For an app that is not listed, choose **Something else…**, add a remote MCP
25server with OAuth in that app, and paste the URL. Apps that require their own
26client ID cannot connect.
27
28## Get the MCP URL
29
30In **Settings → Environments**, open a saved environment's menu and choose
31**Copy MCP URL**. The URL is the environment's address followed by `/mcp`, for
32example:
33
34```text
35https://<environment-address>/mcp
36```
37
38When T3 Connect serves the environment, the copied URL is its T3 Connect
39address, which agents can reach from anywhere. Otherwise it uses the route this
40device is connected over, so an agent on the same device can reach it.
41
42- **An agent on your own computers** can use `localhost` on the host, T3
43 Connect, or any `https` address, such as
44 [Tailscale HTTPS](./remote-access.md#tailscale-https). Signing in sends the
45 agent's credentials to the environment, and agents only do that over `https`
46 or to `localhost`. A plain-`http` LAN or Tailscale address, like
47 `http://100.x.y.z:3773`, lets an agent find the environment but not finish
48 signing in.
49- **A hosted agent**, such as ChatGPT or a bot running in the cloud, must reach
50 the environment from the internet. Use the T3 Connect address. A Tailscale
51 address only works from your own tailnet.
52
53## Approve a sign-in
54
55The first time an agent connects, it opens a sign-in page. When the agent
56reaches the environment through T3 Connect, the page opens on the T3 Code web
57app: sign in with the T3 Connect account the environment is linked to and
58approve there, without a code. Otherwise the page opens on the environment.
59Either page names the agent and where its access goes:
60
61- For an agent on your computer, approval returns to a `localhost` address on
62 the computer that opened the page.
63- For a hosted agent, approval goes to that service, such as `chatgpt.com`.
64 Anyone who runs that service gets the access.
65
66Only approve a sign-in you just started. On the environment's own page, enter a
67code from **Use T3 Code in another app (MCP)**, **Settings → Sharing & access**,
68or `t3 auth pairing create` on the host. A browser already signed in to the
69environment with permission to manage access can approve without a code. On the
70web app, **Use a sign-in code instead** opens the environment's own page.
71
72A code from **Use T3 Code in another app (MCP)** already carries the level you
73picked there. With another code, choose what the agent may do here: **Auto** is
74selected by default, or the closest lower mode allowed by your organization’s
75policy. Approving without a code starts at **Read only**:
76
77- **Read only** lets the agent read projects and threads and see
78 the available providers and models. It cannot change anything.
79- **Supervised** through **Full access** also let it start, message and stop
80 threads in every project. A thread it starts or steers cannot run with more
81 permissions than the mode you chose. [Workflow runs](workflows.md) choose
82 their own modes, so only **Full access** (or the highest mode your
83 organization's policy allows) can start, answer, resume or cancel them,
84 change what workflows store, or read webhook paths. Lower modes can still
85 read runs.
86
87## What outside agents can call
88
89Some tools only work for an agent running inside a T3 thread, because they act
90as that thread: subagents, secret requests, rendered HTML, the browser preview,
91devices, and worktree handoff. They still appear in an outside agent's tool
92list, but calling one returns an error saying it needs an agent running inside
93T3 Code.
94
95- To hand off work, start a thread with `t3_thread_launch`, then follow it with
96 `t3_thread_wait` or `t3_thread_read`, instead of `create_threads` or
97 `delegate_task`.
98- Tools that default to the caller's own project or thread need an explicit
99 `projectId` or `threadId`.
100- To list threads across projects, call `t3_thread_list` with
101 `allProjects: true`, or use `t3_thread_search`.
102
103## Claude Code
104
105```sh
106claude mcp add --transport http t3 https://<environment-address>/mcp
107claude mcp login t3
108```
109
110`claude mcp login` opens the sign-in page in your browser. On a machine
111without a browser, add `--no-browser`, open the printed URL elsewhere, and
112paste the final URL back when asked. `claude mcp list` shows `t3` as connected
113once you approve.
114
115## Codex
116
117```sh
118codex mcp add t3 --url https://<environment-address>/mcp
119codex mcp login t3
120```
121
122`codex mcp login --no-browser` prints the sign-in URL instead of opening it.
123`codex mcp list` shows `t3` with OAuth once you approve.
124
125## ChatGPT
126
127Add the environment as a custom MCP app in ChatGPT's apps settings:
128
1291. Create a new app or plugin with a custom MCP server.
1302. Set the server URL to `https://<environment-address>/mcp`, using the T3
131 Connect address.
1323. Choose **OAuth** for authentication. ChatGPT discovers the rest; you do not
133 need a client ID or secret.
1344. Create the app, then approve the sign-in page that opens.
135
136## Other agents and bots
137
138Any agent that supports remote MCP servers over HTTP with OAuth can connect. Give
139it the MCP URL and choose OAuth, and the agent finds the sign-in settings itself.
140Agents without OAuth support cannot connect.
141
142A bot that supports MCP Events (`io.modelcontextprotocol/events`) can learn
143when something happens without reading threads over and over: a turn ended, an
144agent waits on a person, a guest asked something, a watched pull request woke
145its thread. [Workflow runs](workflows.md) are events too: a run started, paused,
146resumed or ended, or waits on a person. A bot can poll, stream, or receive each
147event type by webhook, narrowed to projects and threads or to workflows and
148runs; runs another run started are left out unless asked for, as subagent
149threads are, and narrowing thread events to a run picks out its agent steps.
150The environment keeps its latest 1,000 milestones in memory, so a bot that was
151away longer, or reconnects after a restart, is told some may be missing and
152should reread what it cares about. Webhooks go only to public `https` addresses,
153a subscription lasts at most an hour before the bot must renew it, and signing
154the bot out ends its subscriptions. To test with a receiver on your own machine
155or network, start the environment with `T3CODE_MCP_WEBHOOK_ALLOWED_HOSTS` set to
156its host names, for example `localhost,127.0.0.1`; those hosts may also use
157plain `http`.
158
159## Scripts on the host
160
161On the machine that runs the environment, `t3 thread` uses the same tools
162without a sign-in:
163
164```sh
165id=$(t3 thread start . "Find why the tests are slow")
166t3 thread send "$id" "Now fix it" --wait
167t3 thread show "$id"
168t3 thread list
169```
170
171`.` means the project that contains the current folder, or a git worktree of
172its repository; a project id also works. A new thread uses the project's
173default model and permission mode, and runs in the project folder unless you
174pass `--worktree <base-branch>`. Its title is the message's first line, or
175`--title`; add `--generate-title` to have it named from the message, as threads
176started in the app are. `send` never interrupts: a busy thread gets the message
177as its next turn. Pass `-` as the message to read it from stdin.
178
179To choose the model, pass `--provider <instance-id> --model <slug>`. Add
180`--option id=value` for each model option. For reasoning effort, Codex uses
181`--option reasoningEffort=high`, while Claude uses `--option effort=high`.
182Option ids and allowed values depend on the provider and model; use those
183reported by `orchestrator_capabilities`. `true` and `false` set on/off options.
184
185`--wait` prints the agent's reply. It exits 1 when the run fails or stops, and
1862 when the agent waits for an answer you give in the app. Add `--json` for a
187result that always includes the thread id.
188
189## Remove an agent
190
191Approved agents appear under **Settings → Sharing & access** like other clients.
192Revoke one there to cut off its access immediately. A sign-in lasts 30 days;
193after that the agent asks you to approve it again.