Forward API key env vars to the nanobanana MCP server - #72
Open
ABDI-HILL wants to merge 1 commit into
Open
Conversation
The MCP server reads its API key exclusively from process.env
(NANOBANANA_API_KEY, with GEMINI_API_KEY/GOOGLE_API_KEY fallbacks), but
the server spec declared `"env": {}`, so the gemini CLI did not forward
those variables to the spawned MCP subprocess. As a result, following the
documented setup ("set the NANOBANANA_API_KEY environment variable") fails
with "No valid API key found" because the variable never reaches the child
process.
Forward NANOBANANA_API_KEY and GEMINI_API_KEY via ${VAR} expansion so the
documented env-var workflow works.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
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.
What
Add explicit env-var forwarding to the
nanobananaMCP server spec ingemini-extension.json:Why
The MCP server reads its API key only from
process.env— seemcp-server/src/imageGenerator.tsvalidateAuthentication(), which checksNANOBANANA_API_KEYthen falls back toNANOBANANA_GEMINI_API_KEY/NANOBANANA_GOOGLE_API_KEY/GEMINI_API_KEY/GOOGLE_API_KEY.But the server spec declared
"env": {}, so the Gemini CLI did not forward those variables into the spawned MCP subprocess. Following the documented setup inREADME.md("Set theNANOBANANA_API_KEYenvironment variable") then fails with:because the variable is present in the parent shell but never reaches the child process.
Forwarding the two primary variables via
${VAR}expansion makes the documented env-var workflow actually work. The expansion is a no-op when the variables are unset, so it is safe.Testing
Reproduced on Windows 11 (gemini-cli, nanobanana 1.0.12): with
NANOBANANA_API_KEYexported,/generatefailed with "No valid API key found" until this change was applied; after the change,/generateproduced an image successfully.