[McpServerTool,Description("Launch a watchable interactive console in a separate window. The specified interactive command-line program (e.g. cmd, pwsh, bash) is hosted by McpBase.Request.exe so a human can interact with it in its own window, while its stdout/stderr are streamed back to the agent over a named pipe. Returns a watch ID (8-char hex) to pass to ReadWatchableConsole. The human types input and sees output in the host window; the agent observes the same output stream by polling ReadWatchableConsole. No PTY is used, so line-editing/TUI programs may be limited. The watch stays alive until the observed program exits. Use this when the agent needs a human to drive an interactive shell while the agent observes the output.")]
[Description("Executable to launch, optionally followed by arguments. A bare filename works if it is on PATH. Only interactive CLI shells (cmd, pwsh, bash, ...) are supported; do not pass GUI or non-interactive programs.")]stringfileName,
[Description("Optional banner text shown at the top of the host window. Supports Spectre.Console markup (e.g. [yellow]warning[/]); double [ and ] to print them literally.")]string?message="")
{
// 服务端侧创建命名管道(方向 In:接收 Request 转发的子程序输出)。
varpipeName=$"mcpbase.watch.{Guid.NewGuid():N}";
@@ -93,7 +93,7 @@ public class RequestTools(ProcessMap pm)
[McpServerTool,Description("Read output captured from a watchable console created by CreateWatchableConsole. Returns the text accumulated since the last read (when consume=true, the default). Poll periodically while the process runs: an empty string means the process is still running but has produced no new output. When the observed program has exited, the returned string ends with an exit notice and every subsequent call keeps reporting that it has exited (no further output will arrive). Recommended flow: call CreateWatchableConsole, then poll ReadWatchableConsole until the exit notice appears.")]
[Description("Watch ID returned by CreateWatchableConsole.")]stringid,
[Description("If true (default), the returned output is cleared from the buffer after reading. Set false to re-read the full history without consuming it; note that with consume=false the exit notice is still appended when the process has exited.")]boolconsume=true)