From 6d702dac0e8fb74a98289d326b09522a019ee47e Mon Sep 17 00:00:00 2001 From: haosenwang1018 Date: Mon, 16 Mar 2026 16:19:52 +0000 Subject: [PATCH] test: cover MCP_STRICT_ENV tab-padded uppercase 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..f779a46 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 tab-padded uppercase true as strict mode', async () => { + process.env.MCP_STRICT_ENV = '\r\n\tTRUE\t\r\n'; + + const configPath = join(tempDir, 'missing_env_tab_padded_uppercase_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;