@@ -478,11 +478,14 @@ describe("ClaudeAdapterV2 MCP query overrides", () => {
478478 type : "http" ,
479479 url : "http://127.0.0.1:43123/mcp" ,
480480 headers : {
481- Authorization : "Bearer secret-claude-token " ,
481+ Authorization : "${T3_CODE_MCP_AUTHORIZATION} " ,
482482 } ,
483483 timeout : ClaudeAdapterV2 . CLAUDE_T3_MCP_TOOL_TIMEOUT_MS ,
484484 } ,
485485 } as const ;
486+ const T3_MCP_ENVIRONMENT = {
487+ T3_CODE_MCP_AUTHORIZATION : "Bearer secret-claude-token" ,
488+ } as const ;
486489
487490 const withMcpSession = ( threadId : ThreadId , run : ( ) => void ) => {
488491 McpProviderSession . setMcpProviderSession ( {
@@ -531,6 +534,7 @@ describe("ClaudeAdapterV2 MCP query overrides", () => {
531534 assert . deepEqual ( overrides , {
532535 allowedTools : [ ClaudeAdapterV2 . CLAUDE_T3_MCP_TOOL_WILDCARD ] ,
533536 mcpServers : T3_MCP_SERVERS ,
537+ mcpEnvironment : T3_MCP_ENVIRONMENT ,
534538 } ) ;
535539 } ) ;
536540 } ) ;
@@ -547,6 +551,7 @@ describe("ClaudeAdapterV2 MCP query overrides", () => {
547551 assert . deepEqual ( overrides , {
548552 allowedTools : [ "Read" , "mcp__t3-code__*" ] ,
549553 mcpServers : T3_MCP_SERVERS ,
554+ mcpEnvironment : T3_MCP_ENVIRONMENT ,
550555 } ) ;
551556 } ) ;
552557 } ) ;
@@ -566,6 +571,7 @@ describe("ClaudeAdapterV2 MCP query overrides", () => {
566571 ...ClaudeAdapterV2 . CLAUDE_READ_ONLY_T3_MCP_ALLOWED_TOOLS ,
567572 ] ,
568573 mcpServers : T3_MCP_SERVERS ,
574+ mcpEnvironment : T3_MCP_ENVIRONMENT ,
569575 } ) ;
570576 assert . isFalse ( overrides . allowedTools ?. includes ( ClaudeAdapterV2 . CLAUDE_T3_MCP_TOOL_WILDCARD ) ) ;
571577 } ) ;
@@ -697,11 +703,12 @@ describe("ClaudeAdapterV2 native protocol logging", () => {
697703 type : "http" ,
698704 url : "http://127.0.0.1:43123/mcp" ,
699705 headers : {
700- Authorization : "Bearer secret-claude-token " ,
706+ Authorization : "${T3_CODE_MCP_AUTHORIZATION} " ,
701707 } ,
702708 timeout : ClaudeAdapterV2 . CLAUDE_T3_MCP_TOOL_TIMEOUT_MS ,
703709 } ,
704710 } ,
711+ mcpEnvironment : { T3_CODE_MCP_AUTHORIZATION : "Bearer secret-claude-token" } ,
705712 } ) ;
706713
707714 const options = ClaudeAdapterV2 . makeClaudeQueryOptions ( {
@@ -712,8 +719,14 @@ describe("ClaudeAdapterV2 native protocol logging", () => {
712719 nativeThreadId : "native-thread-claude-mcp" ,
713720 resume : false ,
714721 cwd : "/workspace" ,
715- ...overrides ,
722+ allowedTools : overrides . allowedTools ?? [ ] ,
723+ mcpServers : overrides . mcpServers ?? { } ,
724+ environment : { ...overrides . mcpEnvironment } ,
716725 } ) ;
726+ // mcpServers becomes a CLI argument, readable by every local user; the
727+ // credential may only travel in the child's environment.
728+ assert . notInclude ( JSON . stringify ( options . mcpServers ) , "secret-claude-token" ) ;
729+ assert . equal ( options . env ?. T3_CODE_MCP_AUTHORIZATION , "Bearer secret-claude-token" ) ;
717730 assert . isObject ( options . systemPrompt ) ;
718731 const systemPrompt = options . systemPrompt as {
719732 readonly type : string ;
0 commit comments