fix(mcp): Ensure that stdio MCP server execution has the GEMINI_CLI=1 env variable populated. (#18832)

This commit is contained in:
Richie Foreman
2026-02-11 16:07:51 -08:00
committed by GitHub
parent b8008695db
commit 941691ce72
3 changed files with 42 additions and 2 deletions
@@ -32,6 +32,18 @@ const { Terminal } = pkg;
const MAX_CHILD_PROCESS_BUFFER_SIZE = 16 * 1024 * 1024; // 16MB
/**
* An environment variable that is set for shell executions. This can be used
* by downstream executables and scripts to identify that they were executed
* from within Gemini CLI.
*/
export const GEMINI_CLI_IDENTIFICATION_ENV_VAR = 'GEMINI_CLI';
/**
* The value of {@link GEMINI_CLI_IDENTIFICATION_ENV_VAR}
*/
export const GEMINI_CLI_IDENTIFICATION_ENV_VAR_VALUE = '1';
// We want to allow shell outputs that are close to the context window in size.
// 300,000 lines is roughly equivalent to a large context window, ensuring
// we capture significant output from long-running commands.
@@ -302,7 +314,8 @@ export class ShellExecutionService {
detached: !isWindows,
env: {
...sanitizeEnvironment(process.env, sanitizationConfig),
GEMINI_CLI: '1',
[GEMINI_CLI_IDENTIFICATION_ENV_VAR]:
GEMINI_CLI_IDENTIFICATION_ENV_VAR_VALUE,
TERM: 'xterm-256color',
PAGER: 'cat',
GIT_PAGER: 'cat',