@devries-cameron20 / t3code-1 / commits / 6c0698c0af
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(server): Antigravity turns no longer fail on a roots notification to the T3 MCP server (#36439)

Davide Bertoni committed Nov 18, 2026 at 14:25 UTC 6c0698c0af65fbd4563b027175bc80d3718a0e87
2 files changed +66 -2
apps/server/src/mcp/McpHttpServer.test.ts
+32
@@ -1201,6 +1201,38 @@ it.effect("answers 2026-07-28 discovery and keeps 2025-06-18 as the initialize f
1201 expect.arrayContaining([expect.objectContaining({ name: "probe" })]),
1202 );
1203
1204 + // The Go MCP SDK sends this without request metadata, though 2026-07-28 does not define it.
1205 + const rootsChanged = (
1206 + client: HttpClient.HttpClient,
1207 + message: object = {},
1208 + headers: Record<string, string> = {},
1209 + ) =>
1210 + client.post("/mcp", {
1211 + headers: {
1212 + accept: "application/json, text/event-stream",
1213 + "mcp-method": "notifications/roots/list_changed",
1214 + "mcp-protocol-version": "2026-07-28",
1215 + ...headers,
1216 + },
1217 + body: HttpBody.text(
1218 + JSON.stringify({
1219 + jsonrpc: "2.0",
1220 + method: "notifications/roots/list_changed",
1221 + params: {},
1222 + ...message,
1223 + }),
1224 + "application/json",
1225 + ),
1226 + });
1227 + const acknowledged = yield* rootsChanged(httpClient);
1228 + expect(acknowledged.status).toBe(202);
1229 + expect(yield* acknowledged.text).toBe("");
1230 + expect((yield* rootsChanged(yield* HttpClient.HttpClient)).status).toBe(401);
1231 + expect((yield* rootsChanged(httpClient, { id: 7 })).status).toBe(400);
1232 + expect((yield* rootsChanged(httpClient, {}, { origin: "https://example.com" })).status).toBe(
1233 + 403,
1234 + );
1235 +
1236 const initializeResponse = yield* httpClient.post("/mcp", {
1237 headers: { accept: "application/json, text/event-stream" },
1238 body: HttpBody.text(
apps/server/src/mcp/McpHttpServer.ts
+34 -2
@@ -167,6 +167,38 @@ const normalizeMcpHttpResponse = (
167 : response;
168 };
169
170 +// The first protocol is the fallback for clients that offer an unknown version.
171 +const mcpProtocols = [McpProtocol.v2025_06_18, McpProtocol.v2026_07_28] as const;
172 +
173 +/**
174 + * Effect answers 400 to a notification a sessionless protocol does not define, because it requires
175 + * `_meta` before it checks the method. The Go MCP SDK still sends `notifications/roots/list_changed`
176 + * there and closes its connection on that 400. Remove once Effect ignores undefined notifications.
177 + */
178 +const isUndefinedNotification = Effect.fnUntraced(function* (
179 + request: HttpServerRequest.HttpServerRequest,
180 +) {
181 + const method = request.headers["mcp-method"];
182 + const protocol = mcpProtocols.find(
183 + (candidate) => candidate.protocolVersion === request.headers["mcp-protocol-version"],
184 + );
185 + if (
186 + request.method !== "POST" ||
187 + protocol?.runtime._tag !== "Stateless" ||
188 + !method?.startsWith("notifications/") ||
189 + protocol.clientRpcs.requests.has(method)
190 + ) {
191 + return false;
192 + }
193 + const message = yield* Effect.orElseSucceed(request.json, () => undefined);
194 + return (
195 + Predicate.isReadonlyObject(message) &&
196 + message.jsonrpc === "2.0" &&
197 + message.method === method &&
198 + !Predicate.hasProperty(message, "id")
199 + );
200 +});
201 +
202 // Session tokens are `<payload>.<signature>`; registry tokens are a bare base64url secret.
203 const looksLikeProviderToken = (token: string) => token.length > 0 && !token.includes(".");
204
@@ -287,6 +319,7 @@ const makeMcpAuthMiddleware = Effect.gen(function* () {
319 if (request.headers.origin !== undefined) return HttpServerResponse.empty({ status: 403 });
320 const admitted = yield* authenticateRequest(request);
321 if (HttpServerResponse.isHttpServerResponse(admitted)) return admitted;
322 + if (yield* isUndefinedNotification(request)) return HttpServerResponse.empty({ status: 202 });
323 return yield* httpEffect.pipe(
324 Effect.provideService(McpInvocationContext.McpInvocationContext, admitted),
325 Effect.map(normalizeMcpHttpResponse),
@@ -1336,8 +1369,7 @@ export const layerMcpTransport = <RA, RE, RR>(registrations: Layer.Layer<RA, RE,
1369 name: "T3 Code",
1370 version: packageJson.version,
1371 path: MCP_HTTP_PATH,
1339 - // The first protocol is the fallback for clients that offer an unknown version.
1340 - protocols: [McpProtocol.v2025_06_18, McpProtocol.v2026_07_28],
1372 + protocols: mcpProtocols,
1373 allowSessionTermination: true,
1374 registrations,
1375 }).pipe(Layer.provide(layerMcpAuthMiddleware));