Skip to content

Conversation

aashari
Copy link
Owner

@aashari aashari commented Sep 9, 2025

Problem

The dotenv.config() call was outputting log messages to STDIO, which interfered with MCP's JSON-RPC communication in Claude Desktop. This caused "Unexpected token" JSON parsing errors when using STDIO transport mode.

Error message:

Unexpected token 'd', "[dotenv@17."... is not valid JSON

Root cause:
dotenv was outputting messages like [[email protected]] injecting env (0) from .env to STDIO, which broke the JSON-RPC protocol used by MCP servers.

Solution

Added { quiet: true } option to dotenv.config() call to suppress these log messages.

Changes:

  • Modified src/utils/config.util.ts
  • Added explanatory comment
  • No functional changes to environment variable loading behavior

Testing Results

  • ✅ Formatter: PASS
  • ✅ Linter: PASS
  • ✅ Build: PASS
  • ✅ MCP STDIO transport mode verified working
  • ✅ No regression in environment variable loading

Impact

This fix resolves STDIO interference for all Claude Desktop users without requiring any configuration changes on their part. Critical fix for MCP protocol compatibility.

Based on the fix originally proposed in mcp-server-atlassian-bitbucket#106 by @hansonkim.

- Add { quiet: true } to dotenv.config() call
- Prevents dotenv log messages from interfering with MCP JSON-RPC communication
- Fixes "Unexpected token" JSON parsing errors in Claude Desktop
- No functional changes to environment variable loading behavior

Resolves STDIO pollution that breaks MCP protocol in STDIO transport mode.
@aashari aashari force-pushed the fix/dotenv-quiet-mode branch from 9200edb to c455ff8 Compare September 20, 2025 07:55
@aashari aashari merged commit 9ec8c30 into main Sep 20, 2025
1 check passed
@aashari aashari deleted the fix/dotenv-quiet-mode branch September 20, 2025 07:55
github-actions bot pushed a commit that referenced this pull request Sep 20, 2025
## [2.0.1](v2.0.0...v2.0.1) (2025-09-20)

### Bug Fixes

* prevent dotenv from outputting to STDIO in MCP mode ([#151](#151)) ([9ec8c30](9ec8c30))
Copy link

🎉 This PR is included in version 2.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant