Feature chore bug 005 #19

Merged
iamdoubz merged 106 commits from feature_chore_bug_005 into main 2026-07-07 22:02:41 -05:00
Showing only changes of commit f99845ef1b - Show all commits
+42
View File
@@ -280,3 +280,45 @@ pub(crate) fn update_tray_tooltip(app: &tauri::AppHandle, text: &str) {
let _ = tray.0.set_tooltip(Some(text));
}
}
/// Entry point for `whispassist.exe --mcp-stdio` (FR-MCP-6): serves one MCP
/// session over this process's own stdin/stdout instead of showing a window,
/// against the same `wa.db` the GUI instance uses. There is no Tauri
/// `AppHandle` in this mode, so `mcp://access` events have nowhere to go —
/// the `mcp_access_log` DB row is still written regardless (FR-MCP-5).
pub fn run_mcp_stdio() {
#[cfg(feature = "mcp")]
{
// stderr, not stdout: stdout is the MCP JSON-RPC channel.
let _ = tracing_subscriber::fmt()
.with_env_filter("info")
.with_writer(std::io::stderr)
.try_init();
let rt = match tokio::runtime::Builder::new_multi_thread().enable_all().build() {
Ok(rt) => rt,
Err(e) => {
eprintln!("whispassist --mcp-stdio: failed to start a runtime: {e}");
std::process::exit(1);
}
};
rt.block_on(async {
let store: std::sync::Arc<dyn storage::Store> = match storage::SqliteStore::connect().await {
Ok(s) => std::sync::Arc::new(s),
Err(e) => {
eprintln!("whispassist --mcp-stdio: failed to open wa.db: {e}");
std::process::exit(1);
}
};
let handler = mcp::handler::WaMcpHandler::new(store, None);
if let Err(e) = mcp::stdio_transport::serve_once(handler).await {
eprintln!("whispassist --mcp-stdio: session ended with an error: {e}");
std::process::exit(1);
}
});
}
#[cfg(not(feature = "mcp"))]
{
eprintln!("this build was compiled without MCP support (the `mcp` cargo feature is off)");
std::process::exit(1);
}
}