fix(agentic-ai): forward configured env vars for STDIO MCP client transport#7163
Merged
Conversation
Agent-Logs-Url: https://github.com/camunda/connectors/sessions/a5170b84-1cbf-4652-9fab-0a13e6c22f5c Co-authored-by: maff <27403+maff@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix issue with env variables not passed to spawned process
Forward configured env vars for STDIO MCP client transport
May 8, 2026
Agent-Logs-Url: https://github.com/camunda/connectors/sessions/887c1731-fe31-4eab-b4bf-ce11b1eaee87 Co-authored-by: maff <27403+maff@users.noreply.github.com>
Contributor
Author
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Covers default, no-args, and no-env configurations in dedicated stdio client tests instead of a separate env-only test.
maff
approved these changes
May 8, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes STDIO MCP client process spawning so that configured environment variables are forwarded into the MCP SDK ServerParameters, ensuring spawned MCP servers receive required env (e.g., tokens/API keys).
Changes:
- Propagate
StdioMcpClientTransportConfiguration.env()into MCP SDKServerParameterswhen creating STDIO transport. - Extend unit tests to assert the generated
ServerParametersincludes the configuredcommand,args, andenv.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| connectors/agentic-ai/src/main/java/io/camunda/connector/agenticai/mcp/client/framework/mcpsdk/McpSdkClientFactory.java | Wires STDIO env config into ServerParameters for spawned MCP server processes. |
| connectors/agentic-ai/src/test/java/io/camunda/connector/agenticai/mcp/client/framework/mcpsdk/McpSdkClientFactoryTest.java | Adds regression assertions by extracting ServerParameters from the created client and verifying env propagation. |
Replace reflection into McpSyncClient internals with Mockito.mockConstruction(StdioClientTransport) to capture the ServerParameters argument directly. Asserts run against the real built object instead of private SDK fields.
e9b85c6 to
9cf250c
Compare
Contributor
|
Successfully created backport PR for |
maff
added a commit
that referenced
this pull request
May 8, 2026
…nsport (#7163) (#7165) * Initial plan * fix(agentic-ai): forward stdio env into MCP server parameters Agent-Logs-Url: https://github.com/camunda/connectors/sessions/a5170b84-1cbf-4652-9fab-0a13e6c22f5c * test(agentic-ai): assert stdio env via built client path Agent-Logs-Url: https://github.com/camunda/connectors/sessions/887c1731-fe31-4eab-b4bf-ce11b1eaee87 * test(agentic-ai): assert stdio command/args/env across configurations Covers default, no-args, and no-env configurations in dedicated stdio client tests instead of a separate env-only test. * test(agentic-ai): capture stdio ServerParameters via mockConstruction Replace reflection into McpSyncClient internals with Mockito.mockConstruction(StdioClientTransport) to capture the ServerParameters argument directly. Asserts run against the real built object instead of private SDK fields. --------- (cherry picked from commit e68f7f9) Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: maff <27403+maff@users.noreply.github.com> Co-authored-by: Mathias Geat <mathias.geat@camunda.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
STDIO MCP client configuration accepted
envvalues but dropped them when building MCP SDKServerParameters, so spawned MCP server processes did not receive required environment variables (for example tokens/API keys). This change wiresenvthrough and adds a focused regression test.Behavior fix: propagate STDIO env to MCP SDK transport
McpSdkClientFactory#createStdioTransportto passStdioMcpClientTransportConfiguration.env()intoServerParameters.Regression coverage
McpSdkClientFactoryTestthat verifies configured STDIO env entries are present in the generatedServerParameters.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
jfrog-prod-euc1-shared-frankfurt-main.s3.amazonaws.com/opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/21.0.9-10.0.LTS/x64/bin/java /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/21.0.9-10.0.LTS/x64/bin/java --enable-native-access=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.desktop/java.awt.font=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.14/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.14/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.14(dns block)repository.jboss.org/opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/21.0.9-10.0.LTS/x64/bin/java /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/21.0.9-10.0.LTS/x64/bin/java --enable-native-access=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.desktop/java.awt.font=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.14/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.14/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.14(dns block)repository.sonatype.org/opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/21.0.9-10.0.LTS/x64/bin/java /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/21.0.9-10.0.LTS/x64/bin/java --enable-native-access=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.desktop/java.awt.font=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.14/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.14/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.14(dns block)If you need me to access, download, or install something from one of these locations, you can either: