Skip to content

Fix: Startup banner corrupts stdio JSON-RPC stream#8

Merged
ProgramComputer merged 1 commit into
ProgramComputer:mainfrom
Kryptoxic:main
Jul 4, 2026
Merged

Fix: Startup banner corrupts stdio JSON-RPC stream#8
ProgramComputer merged 1 commit into
ProgramComputer:mainfrom
Kryptoxic:main

Conversation

@Kryptoxic

Copy link
Copy Markdown

Summary

When starting up Claude desktop which also starts the MCP server at the same time, the MCP server fails to connect when using the npx method, throwing:

Unexpected token '◇', "◇ injected"... is not valid JSON

Root cause

Looking at the package.json, the json declared "dotenv": "", which is an empty version range that floats to the latest dotenv on every fresh install. Fresh installs (e.g. npx -y @programcomputer/nasa-mcp-server@latest) resolve dotenv v17+, which prints a startup banner to stdout by default:

◇ injected env (1) from .env // tip: ...

A stdio MCP server uses stdout exclusively as its JSON-RPC channel, so this banner corrupts the stream and the client fails to parse the handshake. The committed lockfile pinned the older, silent dotenv 16.4.7, which masked the issue in local development.

Changes

  • Pin dotenv to ^17.2.0 so the version no longer silently floats.
  • Add quiet: true to every dotenv.config() call to suppress the v17 banner:
    • src/utils/api-client.ts (4 calls) — imported by index.ts, so its top-level calls run at startup and were the primary culprit
    • src/index.ts (1 call)
    • src/utils/env-setup.ts (4 calls)

Verification

I have locally built the updated source code and piped a MCP initialize request into dist/index.js with a .env present and verified that the error message does not appear when starting Claude.

@ProgramComputer ProgramComputer merged commit 342cad2 into ProgramComputer:main Jul 4, 2026
1 check failed
ProgramComputer added a commit that referenced this pull request Jul 4, 2026
Fix: Startup banner corrupts stdio JSON-RPC stream
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants