From 0033eaf7621103e025c1f531f23cede8e33d3f82 Mon Sep 17 00:00:00 2001 From: haosenwang1018 Date: Mon, 16 Mar 2026 19:47:02 +0000 Subject: [PATCH] test: cover MCP_STRICT_ENV leading-tab 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..308e54a 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 leading-tab true as strict mode', async () => { + process.env.MCP_STRICT_ENV = '\r\n\ttrue\r\n'; + + const configPath = join(tempDir, 'missing_env_leading_tab_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;