From 10d2a5cea0c78ac6828cd8426bf19c7216ca95eb Mon Sep 17 00:00:00 2001 From: haosenwang1018 Date: Mon, 16 Mar 2026 19:31:21 +0000 Subject: [PATCH] test: cover MCP_STRICT_ENV trailing-space mixed-case true-with-surrounding-CRLF semantics --- tests/config.test.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/config.test.ts b/tests/config.test.ts index a48602c..6fa61d4 100644 --- a/tests/config.test.ts +++ b/tests/config.test.ts @@ -108,6 +108,28 @@ describe('config', () => { delete process.env.MCP_STRICT_ENV; }); + + test('treats MCP_STRICT_ENV with surrounding-CRLF trailing-space mixed-case true as strict mode', async () => { + process.env.MCP_STRICT_ENV = '\r\nTrue \r\n'; + + const configPath = join(tempDir, 'missing_env_trailing_space_mixed_case_true_surrounded_crlf.json'); + await writeFile( + configPath, + JSON.stringify({ + mcpServers: { + test: { + command: 'echo', + env: { TOKEN: '${NONEXISTENT_VAR}' }, + }, + }, + }) + ); + + await expect(loadConfig(configPath)).rejects.toThrow('Missing environment variable'); + + delete process.env.MCP_STRICT_ENV; + }); + test('throws error on missing env vars in strict mode (default)', async () => { // Ensure strict mode is enabled (default) delete process.env.MCP_STRICT_ENV;