{"slug": "my-mcp-server-prints-a-dotenv-banner-to-stdout-the-fix-has-been-in-git-for-19-t", "title": "My MCP Server Prints a dotenv Banner to stdout. The Fix Has Been in Git for 19 Days and Still Isn't on npm.", "summary": "A developer found that the published npm package @spranab/discord-mcp 1.0.1 calls dotenv.config() without options, causing dotenv 17.3.1 to print an \"injecting env\" banner to stdout ahead of the first JSON-RPC byte on MCP's stdio transport. The fix, adding { quiet: true }, has sat in git for 19 days since commit 986c92d but has never been published to npm, so anyone running npx -y @spranab/discord-mcp still gets the banner. The developer notes no client has been confirmed to break on the stray line and the package saw 48 downloads in the last 30 days.", "body_md": "This morning I pulled the 1.0.1 tarball of `@spranab/discord-mcp` off npm and grepped the built file:\n\n``` python\n$ grep -n dotenv package/dist/index.js\n6:import dotenv from \"dotenv\";\n7:dotenv.config();\n```\n\nBare call, no options. The fix for that line has been in git for nineteen days. It isn't in anything you can install:\n\n``` bash\n$ npm view @spranab/discord-mcp versions\n[ '1.0.0', '1.0.1' ]\n```\n\nBoth of those went out on the same day, 2026-04-03. I don't have a record of why there are two. Nothing has shipped since.\n\ndiscord-mcp depends on `dotenv` `^17.3.1`, and the lockfile resolves it to exactly 17.3.1. To check what that version actually does, I installed `dotenv@17.3.1` into an empty scratch directory and ran a one-line script calling `dotenv.config()`, with stdout and stderr captured to separate files. stdout got this, and only this:\n\n```\n[dotenv@17.3.1] injecting env (1) from .env -- tip: ⚙️  write to custom object with { processEnv: myObject }\n```\n\nstderr got nothing from dotenv. The only line in it was my script's own `console.error`. Then I changed the call to `dotenv.config({ quiet: true })` and ran it again. stdout came back empty.\n\nThat matters because MCP's stdio transport uses stdout for JSON-RPC and nothing else. The client reads that stream expecting protocol messages, and in this package the banner gets there before any of them.\n\nWhat the repro doesn't tell me is whether any real client ever broke on it. I have no transcript of that happening. Nobody filed an issue and nobody complained on npm. The diagnosis is mine, from the commit where I fixed it, and nothing in the wild has confirmed it. So what I can say is that the banner lands on stdout ahead of the protocol, and `quiet: true` removes it. I can't say it broke your client.\n\nI wrote the bug on day one. Commit `5f75ca9`, 2026-04-03 01:45:28, \"Initial commit: Discord MCP server with hierarchical single-tool design.\" The bare `dotenv.config()` was in `src/index.ts` from the start and stayed there for just under seven months.\n\nI found it on 2026-10-31, and I wasn't looking for it. Commit `986c92d` is titled \"Suppress dotenv stdout banner, sync lockfile, add 2 siblings to footer.\" It did three things: the dotenv fix, re-syncing some fields in `package-lock.json` that had drifted (name, version, license, bin), and adding icantmarket-mcp and yantrikos/tier to the README's Related Projects footer. The message says:\n\ndotenv.config() was printing \"[dotenv@x] injecting env...\" to stdout on every startup, ahead of the first JSON-RPC byte on the stdio transport that MCP clients expect. Verified live: the banner appears even with no .env file present.\n\nThe option was already there in the version I depend on. I just didn't use it.\n\nThe package got 48 npm downloads in the last 30 days. I don't know how many of those hit a client that cared about a stray line on stdout. Anyone who follows the README today and runs `npx -y @spranab/discord-mcp` gets 1.0.1, banner included.\n\ndiscord-mcp exposes one MCP tool, `discord`, rather than one tool per Discord operation. Discovery is three levels deep. `discord()` with no arguments returns the category list. `discord(category: \"messages\")` returns that category's actions and their parameters. Add `action` and `params` and it executes.\n\nI counted the `categories` object myself instead of trusting the README. There are 11 categories and 34 actions: server 2, channels 4, messages 8, roles 5, members 3, moderation 5, threads 1, webhooks 2, invites 2, emojis 1, audit 1. The README says \"30+ actions,\" which holds.\n\nHere is one action as it appears in the published build, trimmed:\n\n``` js\nconst categories = {\n  messages: {\n    description: \"Message operations — send, read, edit, delete, pin, react, search\",\n    actions: {\n      send: {\n        description: \"Send a message to a channel\",\n        params: {\n          channel_id: { type: \"string\", description: \"The channel ID\", required: true },\n          content: { type: \"string\", description: \"Message text content\" },\n          // embed_title, embed_description, embed_color\n        },\n        handler: async ({ channel_id, content, embed_title, embed_description, embed_color }) => { /* ... */ },\n      },\n      // 7 more actions\n    },\n  },\n  // 10 more categories\n};\n```\n\nThe handler falls through three branches: no category, no action, or both. When it has both, it checks required params with this line:\n\n```\nif (pDef.required && (p[pName] === undefined || p[pName] === null)) {\n```\n\nThat checks that the param is present, and that's all it checks. The moderation timeout action declares `duration_minutes` as `type: \"number\"`, but nothing confirms it actually is one. The README's Tech Stack section lists \"Zod for validation,\" and zod is a real dependency, but it only covers the outer wrapper:\n\n```\ncategory: z.string().optional(),\naction: z.string().optional(),\nparams: z.record(z.string(), z.any()).optional(),\n```\n\n`z.any()` lets anything through. So the per-action checking is hand-rolled and stops once a param exists. \"Zod for validation\" suggests more than the code does.\n\nThe real cost of the design is round trips. If a model hasn't already seen the shape this session, it has to call `discord()` and then `discord(category=...)` before it can do anything. That's two throwaway calls every time. People who count tokens will probably say a flat list of 34 tools is cheaper overall. I think that's the wrong thing to optimize for Discord moderation, where nothing is latency-critical and a smaller prompt is worth a couple of extra calls. I wouldn't make the same choice for a tool where a user is waiting on every hop.\n\nCommit `01cc993`, 2026-08-18 11:06:45, added the README's first worked example. The prose around it claimed the one-tool design meant the model \"never had 37 tool schemas sitting in its prompt.\" 37 was wrong. The count has been 34 since the first commit. The example also used parameter names (`channel`, `author`, `user`, `message_ids`) that don't match what the code takes: `channel_id`, `guild_id`, `user_id`, `count`.\n\nBoth mistakes lasted 27 seconds. I pushed `256d053` at 11:07:12, which fixed the parameter names and swapped \"37 tool schemas\" for \"30+.\" I'd checked the example against the code right after committing it. It was a quick self-correction, never a long-lived public error.\n\nCommit `bff02ca`, 2026-09-08, added an `mcpName` field to `package.json` so the package could be listed on the Official MCP Registry. That commit's message notes the registry \"rejects publish until this field is present in the LIVE npm package.json, which needs a real npm release.\" There hasn't been one, so `io.github.spranab/discord-mcp` still doesn't appear when I query the registry.\n\nOther packages with the same name do. A registry search for \"discord-mcp\" returns roughly 70 results. Two examples: PaSympa's `@pasympa/discord-mcp` first showed up there on 2026-06-10 at version 1.7.2, describing itself as \"a lightweight, multi-guild Discord MCP server with 95+ tools.\" OrygnsCode's `@orygn/discord-mcp` was published on 2026-11-12. Mine, for the record, has 1 GitHub star and 48 npm downloads in the last 30 days, 12 of them in the last 7.\n\nThe README's Discord Bot Setup section tells you to add the bot with Administrator permission. That's the broadest grant Discord has, and it bypasses per-channel overwrites entirely. I don't think any of the 34 actions needs it. Each one maps to something narrower. But I haven't worked out the replacement set, and it's fiddlier than \"kick, ban, manage roles\" once webhooks, invites, threads and the audit log are in scope. Listing a set that turns out to be incomplete would be worse than the current instructions.\n\nStill, a project whose pitch is letting an AI assistant act on a real server shouldn't open by asking for the most powerful permission available. The banner fix is done and only needs a release. The permission question still needs real work, and it's the one I'd rather spend time on. Someone could reasonably tell me Administrator is just easier to document and support, and they wouldn't be wrong about that part.\n\nPranab Sarkar, Independent Researcher", "url": "https://wpnews.pro/news/my-mcp-server-prints-a-dotenv-banner-to-stdout-the-fix-has-been-in-git-for-19-t", "canonical_source": "https://dev.to/spranab/my-mcp-server-prints-a-dotenv-banner-to-stdout-the-fix-has-been-in-git-for-19-days-and-still-isnt-3mb3", "published_at": "2026-11-19 16:06:59+00:00", "updated_at": "2026-11-19 16:14:32.579552+00:00", "lang": "en", "topics": ["ai-agents", "agent-protocols", "developer-tools", "ai-tools"], "entities": ["@spranab/discord-mcp", "dotenv", "npm", "MCP", "Discord"], "also_reported_by": [], "takeaway": "Call dotenv.config({ quiet: true }) in MCP stdio servers, because dotenv 17.3.1 otherwise writes an \"injecting env\" banner to stdout ahead of the first JSON-RPC message.", "recommendation": {"advice": "When building stdio-transport MCP servers, pass { quiet: true } to dotenv.config() and keep stdout reserved for JSON-RPC, since dotenv 17.3.1 prints its banner even with no .env file present.", "playbook": "agent-architecture", "playbook_url": "https://wpnews.pro/playbooks/agent-architecture"}, "alternates": {"html": "https://wpnews.pro/news/my-mcp-server-prints-a-dotenv-banner-to-stdout-the-fix-has-been-in-git-for-19-t", "markdown": "https://wpnews.pro/news/my-mcp-server-prints-a-dotenv-banner-to-stdout-the-fix-has-been-in-git-for-19-t.md", "text": "https://wpnews.pro/news/my-mcp-server-prints-a-dotenv-banner-to-stdout-the-fix-has-been-in-git-for-19-t.txt", "jsonld": "https://wpnews.pro/news/my-mcp-server-prints-a-dotenv-banner-to-stdout-the-fix-has-been-in-git-for-19-t.jsonld"}}