@@ -3,6 +3,7 @@ import * as NodeServices from "@effect/platform-node/NodeServices";
33import { expect , it } from "@effect/vitest" ;
44import {
55 ANTIGRAVITY_DEFAULT_MODEL ,
6+ EnvironmentId ,
67 ProviderInstanceId ,
78 ProviderSessionId ,
89 ThreadId ,
@@ -82,6 +83,7 @@ const makeHarness = Effect.fn("makeAntigravityDriverHarness")(function* (
8283 /** `data` of the agent's "Internal error" response to `session/new`. */
8384 readonly newSessionErrorData ?: unknown ;
8485 readonly initialMode ?: string ;
86+ readonly httpMcp ?: boolean ;
8587 } = { } ,
8688 ) {
8789 const directory = path . join ( root , name ) ;
@@ -105,6 +107,7 @@ const makeHarness = Effect.fn("makeAntigravityDriverHarness")(function* (
105107 ...( options . initialMode === undefined
106108 ? [ ]
107109 : [ `export T3_ACP_INITIAL_MODE=${ shellQuote ( options . initialMode ) } ` ] ) ,
110+ ...( options . httpMcp ? [ "export T3_ACP_MCP_HTTP=1" ] : [ ] ) ,
108111 `exec ${ shellQuote ( nodePath ) } ${ shellQuote ( mockAgentPath ) } "$@"` ,
109112 "" ,
110113 ] . join ( "\n" ) ,
@@ -142,6 +145,10 @@ const makeHarness = Effect.fn("makeAntigravityDriverHarness")(function* (
142145 credentialKeys : ReadonlyArray < string > ;
143146 geminiApiKey : string | undefined ;
144147 tempDirectory : string | undefined ;
148+ threadId : string | undefined ;
149+ mcpEndpoint : string | undefined ;
150+ mcpAuthorization : string | undefined ;
151+ mcpNode : string | undefined ;
145152 handle : ChildProcessSpawner . ChildProcessHandle ;
146153 } > = [ ] ;
147154
@@ -200,6 +207,10 @@ const makeHarness = Effect.fn("makeAntigravityDriverHarness")(function* (
200207 geminiApiKey : env ( "GEMINI_API_KEY" ) ,
201208 tempDirectory :
202209 environment . ANTIGRAVITY_HARNESS_PATH === undefined ? undefined : env ( "TMPDIR" ) ,
210+ threadId : env ( "T3CODE_THREAD_ID" ) ,
211+ mcpEndpoint : env ( "T3_ACP_MCP_ENDPOINT" ) ,
212+ mcpAuthorization : env ( "T3_ACP_MCP_AUTHORIZATION" ) ,
213+ mcpNode : env ( "T3_ACP_MCP_NODE" ) ,
203214 handle,
204215 } ) ;
205216 return handle ;
@@ -579,4 +590,62 @@ it.layer(layerTest)("AntigravityDriver", (it) => {
579590 expect ( yield * fs . exists ( legacyRoot ) ) . toBe ( false ) ;
580591 } ) ,
581592 ) ;
593+
594+ it . effect . skipIf ( windowsHost ) (
595+ "forwards thread MCP environment and defers MCP tools for Antigravity sessions" ,
596+ ( ) =>
597+ Effect . gen ( function * ( ) {
598+ const h = yield * makeHarness ( ) ;
599+ h . controls . selected = yield * h . makeExecutable ( "runtime http mcp" , { httpMcp : true } ) ;
600+ const mcpSessions = yield * McpProviderSessions . McpProviderSessions ;
601+ const workspace = yield * h . fs . makeTempDirectoryScoped ( { prefix : "t3-ag-mcp-" } ) ;
602+ const threadId = ThreadId . make ( "thread-antigravity-mcp-env" ) ;
603+ const providerSessionId = ProviderSessionId . make ( "provider-session-antigravity-mcp-env" ) ;
604+ const endpoint = "http://127.0.0.1:43210/mcp" ;
605+ const authorizationHeader = "Bearer test-mcp-token" ;
606+ yield * mcpSessions . set ( {
607+ environmentId : EnvironmentId . make ( "env-test" ) ,
608+ threadId,
609+ providerSessionId,
610+ providerInstanceId : h . instance . instanceId ,
611+ endpoint,
612+ authorizationHeader,
613+ browserToolsAvailable : false ,
614+ } ) ;
615+ const runtimePolicy = ProviderAdapter . ProviderAdapterV2RuntimePolicy . make ( {
616+ runtimeMode : "approval-required" ,
617+ interactionMode : "default" ,
618+ cwd : workspace ,
619+ } ) ;
620+ const modelSelection = { instanceId : h . instance . instanceId , model : "gemini-test-low" } ;
621+ const session = yield * h . instance . orchestrationAdapter . openSession ( {
622+ threadId,
623+ providerSessionId,
624+ modelSelection,
625+ runtimePolicy,
626+ } ) ;
627+ yield * session . ensureThread ( { threadId, modelSelection, runtimePolicy } ) ;
628+
629+ const launch = h . launches . at ( - 1 ) ;
630+ expect ( launch ?. threadId ) . toBe ( threadId ) ;
631+ expect ( launch ?. mcpEndpoint ) . toBe ( endpoint ) ;
632+ expect ( launch ?. mcpAuthorization ) . toBe ( authorizationHeader ) ;
633+ expect ( launch ?. mcpNode ) . toBeTruthy ( ) ;
634+
635+ const newSessionRequest = ( yield * h . readRequests ) . findLast (
636+ ( request ) => request . method === "session/new" ,
637+ ) ;
638+ expect ( newSessionRequest ?. params ?. mcpServers ) . toEqual ( [
639+ {
640+ type : "http" ,
641+ name : "t3-code" ,
642+ url : endpoint ,
643+ headers : [
644+ { name : "Authorization" , value : authorizationHeader } ,
645+ { name : "t3-tool-exposure" , value : "deferred" } ,
646+ ] ,
647+ } ,
648+ ] ) ;
649+ } ) ,
650+ ) ;
582651} ) ;
0 commit comments