azmcp: write missing-subcommand diagnostics to stderr
- Dominant language
- C#
- Stars
- 3.7k
- Forks
- 624
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 220
Description
## 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:
```sh
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.
Contributor guide
Research direction
Start with the @azure/mcp CLI handling for the bare invocation, --help, and server start entry points, then run the automated CLI tests described by the issue. Add coverage for exit codes and stdout/stderr routing: the bare invocation should emit no stdout and put the error and help on stderr, while --help stays on stdout and server start framing remains unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- cli, testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100