| name | windows-process-manager |
| description | Manage Windows-specific process isolation, stdio pipe decoding, and ANSI code page handling. Use when debugging Windows-specific MCP server issues, fixing stdio encoding, or handling Windows path discovery. |
Windows Process Manager
Manage Windows-specific process isolation and stdio handling for LibrAgent.
Key Challenges
1. ANSI Code Page Handling
Windows uses ANSI code pages by default. Stdio output from MCP servers may contain non-UTF-8 characters.
use std::os::windows::prelude::*;
use winapi::um::consoleapi::GetConsoleOutputCP;
2. Stdio Pipe Reading
Windows pipes require special handling for async reading:
use tokio::io::{AsyncReadExt, BufReader};
use tokio::process::Command;
let mut child = Command::new("cmd")
.args(&["/C", "server.exe"])
.stdout(Stdio::piped())
.spawn()?;
let mut stdout = BufReader::new(child.stdout.take().unwrap());
let mut buffer = Vec::new();
stdout.read_to_end(&mut buffer).await?;
3. Path Discovery
Windows paths require normalization:
use std::path::{Path, PathBuf};
fn normalize_windows_path(path: &str) -> PathBuf {
let path = Path::new(path);
if path.is_absolute() {
path.to_path_buf()
} else {
std::env::current_dir().unwrap().join(path)
}
}
4. Process Spawning
use std::process::Stdio;
let mut cmd = Command::new(program);
cmd.args(args)
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.creation_flags(CREATE_NO_WINDOW);
Audit Checklist
Platform Detection
#[cfg(target_os = "windows")]
{
}
#[cfg(not(target_os = "windows"))]
{
}