You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds --mcp-stdio, a headless MCP server for clients that launch and own the process, and centralizes shell output so stdio, --quiet, and machine mode follow one policy.
Why
HTTP MCP (--mcp [port]) needs a listening localhost port that any local user can reach, and its lifetime is separate from the client. With stdio, the client owns the process and its pipes: no port, per-client state, and shutdown when the client closes stdin.
easy local setup/no open http
clear life cycle with seperate by client states
Open Question: If it is really needed.
Stdio contract
stdin: MCP JSON-RPC requests only. Commands can never read it.
stdout: MCP messages only. Managed console output is redirected to stderr before startup, and Spectre is configured for stderr without ANSI.
stderr: startup errors, logs, warnings, and required instructions (such as device-code sign-in).
Closing stdin stops the server, including with open subscriptions or pending confirmations.
Supported: startup --connect/--database/--container, protocol 2025-11-25 and earlier (initialize) and 2026-07-28 (server/discover), destructive-command confirmations, and location subscriptions. Rejected at startup: --mcp, --lsp, -c, -k, --clear-history, and --mcp-stdio passed through a response file.
Removed from the tool list, help, and direct invocation, including aliases: jq, theme, and commands restricted from MCP that cannot be confirmed (exit, edit, watch, welcome, sproc, udf, trigger). Destructive commands (delete, rm, rmdb, rmcon) stay available through MCP confirmation. HTTP mode keeps its existing tool list.
Stdio mode does not load or record shell history.
Sign-in never opens a browser. A headless server has no user at the terminal, and the browser launcher (for example xdg-open) inherits the process stdout. --tenant/--hint connections use device code sign-in, and endpoint-only connections use DefaultAzureCredential without its interactive browser step. Cancelling the tool call ends a pending sign-in.
Centralized output
User-facing output now goes through ShellOutput with an explicit category: Information, Progress, Warning, Error, RequiredInstruction, or Result.
--quiet suppresses information, progress, banners, and command echoes. Results, warnings, errors, and required instructions stay visible, including code previews shown before a confirmation prompt.
Machine-mode stdout carries only the interpreter's final result. Tables that commands draw for interactive users no longer appear there.
theme, help, and edit now throw errors instead of printing and returning them. In machine mode their failures previously exited with code 1 and no message; they now produce one {"status":"error",...} object on stderr. Interactive and script errors are reported once.
New analyzer rule CZ0003 fails the build on direct Console/AnsiConsole output outside ShellOutput. Line-editor drawing keeps scoped suppressions.
Commits
Add headless MCP stdio mode
Disable shell history in MCP stdio mode
Centralize shell output through a category-based policy
Update Copilot instructions for MCP stdio and output policy
Keep MCP stdio sign-in non-interactive
Known limitations
Device-code instructions appear only on stderr, so someone must read them from the client's server log. Surfacing them through MCP could be a follow-up.
Stdio isolates the protocol stream but is not a sandbox. The client still acts with the process owner's file and Cosmos permissions.
Reserve stdin and stdout for MCP, support confirmations and subscriptions, and stop on input EOF. Omit unsupported commands from stdio tools and help while preserving HTTP behavior.
Route all user-facing output through ShellOutput so --quiet, machine mode, and MCP stdio are decided in one place. Quiet suppresses information and progress but keeps results, warnings, errors, and required instructions. Machine-mode stdout carries only the interpreter result, and theme, help, and edit failures are reported once through the central error reporter. Add analyzer rule CZ0003 to reject direct console output.
Never open a browser in stdio mode: tenant or hint connections use device code sign-in with instructions on stderr, and endpoint-only connections use DefaultAzureCredential without its interactive browser step.
Cancel startup on stdin EOF, enforce a shared 60-second connection and navigation deadline, and preserve buffered protocol input. Add lifecycle and cancellation regression tests and update documentation.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep stdio history untouched and route HTTP command echoes through the output policy.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Invalid arguments in watch, bucket, and query produce exit code 1 instead of the documented usage-error code 2, preventing automation from distinguishing argument errors from operational failures.
Report structured usage errors before typed option access or help/LSP early returns, including response-file input.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Static review cannot establish the cross-platform guarantees for stdio EOF/cancellation with pending requests or real device-code/default-credential sign-in, so runtime validation is needed.
* Centralize shell output and preserve machine-mode contracts
Extract the output policy and command migrations from #239 without MCP stdio. Preserve diagnostics and required instructions in quiet mode, report command errors consistently, and require bounded machine-mode watch results.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Preserve required prompts and theme validation diagnostics
Address review feedback in #254 without changing singleton lifetime or cleanup.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Enforce console clearing policy and preserve quiet editor history
Address the previously missed overview findings in #254 and add focused analyzer and editor-history regression coverage.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Preserve machine-mode write and output error details
Address remaining overview findings in #254.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Bound machine-mode import diagnostics
* Use the executing shell for command output and disable CI ANSI enrichers
mkitem, replace, import, and theme now read machine mode and output from the shell passed to ExecuteAsync instead of the singleton. ShellOutput's plain console no longer lets Spectre's CI profile enrichers re-enable ANSI escapes in machine-mode stderr.
* Return client bucket selection and honor interactive 2> for diagnostics
Client bucket commands now return a clientBucket result for machine mode. Outside machine mode, ShellOutput routes warnings and errors to an active 2>/2>> redirect while keeping confirmation prompts on the terminal.
* Classify info RBAC permission diagnostics as errors
Interactive info 2> now captures the permission failure and its remediation text.
* Address code-quality findings in new tests
Fault the bad-status stream mock instead of returning an undisposed ResponseMessage, and use Path.Join for the theme test path.
* Defer changelog updates in #254 until release preparation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Preserve redirected batch failure diagnostics in #254
Use the executing shell for batch renderers and avoid rendering an error a second time after PrintState reports it to stderr redirection.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Localize bulk item diagnostic prefixes in #254
Format insert, upsert, and replacement item positions through the existing localization catalog entry.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Reuse the existing bulk diagnostic localization entry
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Use executing shell output for bucket selection in #254
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Classify bucket and watch argument failures as usage errors in #254
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
MCP stdio mode suppresses explicitly requested help and version output, breaking documented stderr behavior and process tests, while a connection test incorrectly expects a deliberately suppressed informational banner.
Copilot resolve the merge conflicts in this pull request
Resolved in merge commit c36c168, with follow-up fixes in f49fd73 and 5c67718. Both builds and the offline suite pass (5,940 passed, 6 skipped). The final CodeQL scan timed out; an earlier scan reported no alerts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
--mcp-stdio, a headless MCP server for clients that launch and own the process, and centralizes shell output so stdio,--quiet, and machine mode follow one policy.Why
HTTP MCP (
--mcp [port]) needs a listening localhost port that any local user can reach, and its lifetime is separate from the client. With stdio, the client owns the process and its pipes: no port, per-client state, and shutdown when the client closes stdin.Open Question: If it is really needed.
Stdio contract
Supported: startup
--connect/--database/--container, protocol2025-11-25and earlier (initialize) and2026-07-28(server/discover), destructive-command confirmations, and location subscriptions. Rejected at startup:--mcp,--lsp,-c,-k,--clear-history, and--mcp-stdiopassed through a response file.Removed from the tool list,
help, and direct invocation, including aliases:jq,theme, and commands restricted from MCP that cannot be confirmed (exit,edit,watch,welcome,sproc,udf,trigger). Destructive commands (delete,rm,rmdb,rmcon) stay available through MCP confirmation. HTTP mode keeps its existing tool list.Stdio mode does not load or record shell history.
Sign-in never opens a browser. A headless server has no user at the terminal, and the browser launcher (for example
xdg-open) inherits the process stdout.--tenant/--hintconnections use device code sign-in, and endpoint-only connections useDefaultAzureCredentialwithout its interactive browser step. Cancelling the tool call ends a pending sign-in.Centralized output
User-facing output now goes through
ShellOutputwith an explicit category: Information, Progress, Warning, Error, RequiredInstruction, or Result.--quietsuppresses information, progress, banners, and command echoes. Results, warnings, errors, and required instructions stay visible, including code previews shown before a confirmation prompt.theme,help, andeditnow throw errors instead of printing and returning them. In machine mode their failures previously exited with code 1 and no message; they now produce one{"status":"error",...}object on stderr. Interactive and script errors are reported once.Console/AnsiConsoleoutput outsideShellOutput. Line-editor drawing keeps scoped suppressions.Commits
Known limitations