Skip to content

Commit c5ef51e

Browse files
t3dotggclaude
andcommitted
fix(web): Copy MCP URL uses the T3 Connect address
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 6417151 commit c5ef51e

3 files changed

Lines changed: 17 additions & 9 deletions

File tree

‎docs/user/outside-agents.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ example:
1616
https://<environment-address>/mcp
1717
```
1818

19-
The copied URL uses the route this device is connected over, so an agent on the
20-
same device can reach it.
19+
When T3 Connect serves the environment, the copied URL is its T3 Connect
20+
address, which agents can reach from anywhere. Otherwise it uses the route this
21+
device is connected over, so an agent on the same device can reach it.
2122

2223
- **An agent on your own computers** can use `localhost` on the host, T3
2324
Connect, or any `https` address, such as

‎packages/client-runtime/src/connection/presentation.test.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function supervisorState(overrides: Partial<SupervisorConnectionState>): Supervi
5050
}
5151

5252
describe("connection presentation", () => {
53-
it("copies the MCP address of the route this device is connected over", () => {
53+
it("copies the T3 Connect MCP address first, then the route this device is connected over", () => {
5454
const route = (connectionId: string, httpBaseUrl: string): ConnectionRoute => {
5555
const target = new BearerConnectionTarget({ ...TARGET, connectionId });
5656
return {
@@ -80,6 +80,13 @@ describe("connection presentation", () => {
8080
"http://100.115.1.44:3773/mcp",
8181
);
8282
expect(environmentMcpUrl({ entry })).toBe("http://192.168.4.53:3773/mcp");
83+
expect(
84+
environmentMcpUrl({
85+
entry,
86+
connectedTarget: lan.target,
87+
relayHttpBaseUrl: "https://tunnel.example.test",
88+
}),
89+
).toBe("https://tunnel.example.test/mcp");
8390
});
8491

8592
// regression: #16909 Copy MCP URL falls back to an alternate route when the relay route has no address

‎packages/client-runtime/src/connection/presentation.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,24 +95,24 @@ export function connectionStatusTitle(connection: EnvironmentConnectionPresentat
9595
}
9696

9797
/**
98-
* SSH connections ride a local forward that disappears with the client, so they have no stable
99-
* address.
98+
* The T3 Connect address wins whenever it is known: it works for agents anywhere, while the
99+
* connected route is often a LAN or loopback address. SSH routes ride a local forward that
100+
* disappears with the client, so they have no stable address.
100101
*/
101102
export function environmentMcpUrl(input: {
102103
readonly entry: ConnectionCatalogEntry;
103104
readonly relayHttpBaseUrl?: string | undefined;
104105
readonly connectedTarget?: ConnectionTarget | null | undefined;
105106
}): string | null {
107+
const relayMcpUrl = input.relayHttpBaseUrl ? mcpUrlFromBase(input.relayHttpBaseUrl) : null;
108+
if (relayMcpUrl !== null) return relayMcpUrl;
106109
const connectedRouteId = input.connectedTarget ? connectionRouteId(input.connectedTarget) : null;
107110
const routes = connectionRoutes(input.entry);
108111
const connectedRoute = routes.find(
109112
(route) => connectionRouteId(route.target) === connectedRouteId,
110113
);
111114
for (const route of connectedRoute ? [connectedRoute, ...routes] : routes) {
112-
const httpBaseUrl =
113-
route.target._tag === "RelayConnectionTarget"
114-
? (input.relayHttpBaseUrl ?? null)
115-
: routeHttpBaseUrl(route);
115+
const httpBaseUrl = routeHttpBaseUrl(route);
116116
const mcpUrl = httpBaseUrl === null ? null : mcpUrlFromBase(httpBaseUrl);
117117
if (mcpUrl !== null) return mcpUrl;
118118
}

0 commit comments

Comments
 (0)