Skip to content

azmcp: write missing-subcommand diagnostics to stderr #3098

Description

@varun29ankuS

Summary

Invoking @azure/mcp without a command exits with code 1, but writes the generated root help to stdout. Only Required command was not provided. is written to stderr.

For MCP clients using stdio, stdout is reserved for newline-delimited JSON-RPC messages. A client configured with a bare npx -y @azure/mcp command therefore receives hundreds of non-JSON lines and may fail before surfacing the actionable diagnostic.

Reproduction

Reproduced with the latest published package on July 23, 2026:

npx -y @azure/mcp@3.0.0-beta.26 >stdout.txt 2>stderr.txt
echo $?

Observed:

  • Exit code: 1
  • stdout: 297 lines of version and root help text
  • stderr: Required command was not provided.

The valid invocation, npx -y @azure/mcp server start, is not affected.

Expected behavior

For an invalid invocation caused by a missing command:

  • Exit nonzero.
  • Write no output to stdout.
  • Write the error and generated help/usage text to stderr.

Explicit help requests such as npx -y @azure/mcp --help should continue to exit successfully and write help to stdout.

Acceptance criteria

  • A bare invocation exits nonzero with empty stdout.
  • The missing-command error and root help are written to stderr.
  • Explicit --help behavior remains unchanged.
  • Valid server start stdio framing remains unchanged.
  • Automated tests assert exit codes and stdout/stderr routing for the bare invocation and explicit help path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcliserver-Azure.McpAzure.Mcp.Servertools-CoreAZMCP Core functionality that all other tools build on top of

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions