@@ -147,7 +147,7 @@ const withStdioFixtureScript = Effect.acquireRelease(
147147 yield * Effect . promise ( ( ) =>
148148 Fs . writeFile (
149149 script ,
150- `import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";\nimport { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";\nconst toolName = process.argv[2] ?? "one";\nconst server = new McpServer({ name: "stdio-fixture", version: "1.0.0" }, { capabilities: {} });\nserver.registerTool(toolName, { description: "Stdio fixture tool", inputSchema: {} }, async () => ({ content: [{ type: "text", text: process.env.STDIO_VALUE ?? "ok" }] }));\nawait server.connect(new StdioServerTransport());\n` ,
150+ `import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";\nimport { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";\nconst toolName = process.argv[2] ?? "one";\nconst requiredEnv = process.argv[3];\nif (requiredEnv && process.env[requiredEnv] == null) process.exit(1);\nconst server = new McpServer({ name: "stdio-fixture", version: "1.0.0" }, { capabilities: {} });\nserver.registerTool(toolName, { description: "Stdio fixture tool", inputSchema: {} }, async () => ({ content: [{ type: "text", text: process.env.STDIO_VALUE ?? process.env.STDIO_SECRET ?? "ok" }] }));\nawait server.connect(new StdioServerTransport());\n` ,
151151 ) ,
152152 ) ;
153153 return { dir, script } as const ;
@@ -602,6 +602,95 @@ describe("mcpPlugin", () => {
602602 ) ,
603603 ) ;
604604
605+ it . effect (
606+ "configureServer preflights stdio secret env sources with existing connection values" ,
607+ ( ) =>
608+ Effect . scoped (
609+ Effect . gen ( function * ( ) {
610+ const fixture = yield * withStdioFixtureScript ;
611+ const executor = yield * createExecutor (
612+ makeTestConfig ( {
613+ plugins : [
614+ memoryCredentialsPlugin ( ) ,
615+ mcpPlugin ( { dangerouslyAllowStdioMCP : true } ) ,
616+ ] as const ,
617+ } ) ,
618+ ) ;
619+
620+ yield * executor . mcp . addServer ( {
621+ transport : "stdio" ,
622+ name : "Stdio secret edit" ,
623+ slug : "stdio_secret_edit" ,
624+ command : process . execPath ,
625+ args : [ fixture . script , "one" , "STDIO_SECRET" ] ,
626+ envVars : [ "STDIO_SECRET" ] ,
627+ } ) ;
628+ yield * executor . connections . create ( {
629+ owner : "org" ,
630+ name : ConnectionName . make ( "default" ) ,
631+ integration : IntegrationSlug . make ( "stdio_secret_edit" ) ,
632+ template : AuthTemplateSlug . make ( "env" ) ,
633+ values : { STDIO_SECRET : "secret-value" } ,
634+ } ) ;
635+
636+ yield * executor . mcp . configureServer ( "stdio_secret_edit" , {
637+ transport : "stdio" ,
638+ command : process . execPath ,
639+ args : [ fixture . script , "two" , "STDIO_SECRET" ] ,
640+ authenticationTemplate : [ { slug : "env" , kind : "stdio_env" , vars : [ "STDIO_SECRET" ] } ] ,
641+ } ) ;
642+
643+ const tools = yield * executor . tools . list ( {
644+ integration : IntegrationSlug . make ( "stdio_secret_edit" ) ,
645+ } ) ;
646+ expect ( tools . map ( ( tool ) => String ( tool . name ) ) ) . toContain ( "two" ) ;
647+ expect ( tools . map ( ( tool ) => String ( tool . name ) ) ) . not . toContain ( "one" ) ;
648+ } ) ,
649+ ) ,
650+ ) ;
651+
652+ it . effect ( "configureServer reports missing stdio secret values before preflight" , ( ) =>
653+ Effect . scoped (
654+ Effect . gen ( function * ( ) {
655+ const fixture = yield * withStdioFixtureScript ;
656+ const executor = yield * createExecutor (
657+ makeTestConfig ( {
658+ plugins : [
659+ memoryCredentialsPlugin ( ) ,
660+ mcpPlugin ( { dangerouslyAllowStdioMCP : true } ) ,
661+ ] as const ,
662+ } ) ,
663+ ) ;
664+
665+ yield * executor . mcp . addServer ( {
666+ transport : "stdio" ,
667+ name : "Stdio secret missing" ,
668+ slug : "stdio_secret_missing" ,
669+ command : process . execPath ,
670+ args : [ fixture . script , "one" , "STDIO_SECRET" ] ,
671+ envVars : [ "STDIO_SECRET" ] ,
672+ } ) ;
673+
674+ const result = yield * Effect . result (
675+ executor . mcp . configureServer ( "stdio_secret_missing" , {
676+ transport : "stdio" ,
677+ command : process . execPath ,
678+ args : [ fixture . script , "two" , "STDIO_SECRET" ] ,
679+ authenticationTemplate : [ { slug : "env" , kind : "stdio_env" , vars : [ "STDIO_SECRET" ] } ] ,
680+ } ) ,
681+ ) ;
682+
683+ expect ( Result . isFailure ( result ) ) . toBe ( true ) ;
684+ const failure = Result . isFailure ( result ) ? result . failure : null ;
685+ expect ( failure ) . toMatchObject ( {
686+ _tag : "McpConnectionError" ,
687+ message :
688+ "Cannot validate this command because no visible connection has values for required environment variables: STDIO_SECRET." ,
689+ } ) ;
690+ } ) ,
691+ ) ,
692+ ) ;
693+
605694 it . effect ( "configureServer blocks invalid stdio configs without updating" , ( ) =>
606695 Effect . scoped (
607696 Effect . gen ( function * ( ) {
0 commit comments