Skip to content

[Bug] --mcp-stdio mode writes startup log lines to stdout, corrupting the MCP JSON stream #3427

@sdasari-mdvip

Description

@sdasari-mdvip

Summary

When DAB is started with --mcp-stdio, it writes human-readable startup log lines directly to stdout before the first MCP JSON message. MCP stdio transport expects only newline-delimited JSON on stdout, so any client that reads the stream immediately (Claude Code, VS Code MCP extension, etc.) receives non-JSON bytes and fails to parse the stream.

Environment

  • DAB version: 1.7.92
  • OS: Windows 11 Enterprise
  • Transport: --mcp-stdio
  • MCP client: Claude Code 2.1.98

Steps to Reproduce

dab start --config dab-config.json --mcp-stdio 2>/dev/null | head -5

The first bytes on stdout are:

Information: Microsoft.DataApiBuilder 1.7.92
Information: User provided config file: dab-config.json
Information: Loaded config file: dab-config.json
Information: Setting default minimum LogLevel: Debug for Development mode.
...
{"jsonrpc":"2.0","id":0,"result":{"protocolVersion":"2025-06-18",...}}

Note: 0 bytes are written to stderr. All output — logs and MCP JSON alike — goes to stdout.

Expected Behavior

In --mcp-stdio mode, stdout should contain only MCP JSON messages (newline-delimited). Startup logs should go to stderr so they don't corrupt the protocol stream.

Actual Behavior

Startup log lines are interleaved with MCP JSON on stdout. Any MCP client that begins parsing stdout immediately (as required by the spec) receives non-JSON bytes and fails.

Impact

MCP clients cannot connect to DAB via --mcp-stdio without a filtering proxy that strips the log noise. The --LogLevel None flag causes DAB to exit with code 4294967295 (does not suppress the pre-initialization lines anyway).

Workaround

A Node.js wrapper that buffers stdout and discards lines that don't start with { before forwarding to the MCP client.

Suggested Fix

In --mcp-stdio mode, redirect all ASP.NET Core / DAB log output to stderr so that stdout carries only MCP protocol messages.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions