# My MCP Server Prints a dotenv Banner to stdout. The Fix Has Been in Git for 19 Days and Still Isn't on npm.

> 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: 2026-11-19 16:06:59+00:00

**Recommendation:** 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.
More in the playbook "Designing agent systems": <https://wpnews.pro/playbooks/agent-architecture>

This morning I pulled the 1.0.1 tarball of `@spranab/discord-mcp` off npm and grepped the built file:

``` python
$ grep -n dotenv package/dist/index.js
6:import dotenv from "dotenv";
7:dotenv.config();
```

Bare call, no options. The fix for that line has been in git for nineteen days. It isn't in anything you can install:

``` bash
$ npm view @spranab/discord-mcp versions
[ '1.0.0', '1.0.1' ]
```

Both 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.

discord-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:

```
[dotenv@17.3.1] injecting env (1) from .env -- tip: ⚙️  write to custom object with { processEnv: myObject }
```

stderr 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.

That 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.

What 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.

I 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.

I 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:

dotenv.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.

The option was already there in the version I depend on. I just didn't use it.

The 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.

discord-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.

I 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.

Here is one action as it appears in the published build, trimmed:

``` js
const categories = {
  messages: {
    description: "Message operations — send, read, edit, delete, pin, react, search",
    actions: {
      send: {
        description: "Send a message to a channel",
        params: {
          channel_id: { type: "string", description: "The channel ID", required: true },
          content: { type: "string", description: "Message text content" },
          // embed_title, embed_description, embed_color
        },
        handler: async ({ channel_id, content, embed_title, embed_description, embed_color }) => { /* ... */ },
      },
      // 7 more actions
    },
  },
  // 10 more categories
};
```

The handler falls through three branches: no category, no action, or both. When it has both, it checks required params with this line:

```
if (pDef.required && (p[pName] === undefined || p[pName] === null)) {
```

That 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:

```
category: z.string().optional(),
action: z.string().optional(),
params: z.record(z.string(), z.any()).optional(),
```

`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.

The 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.

Commit `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`.

Both 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.

Commit `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.

Other 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.

The 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.

Still, 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.

Pranab Sarkar, Independent Researcher
