Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions src/mcp/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use log::{debug, error, info};
use serde_json::json;
use std::{path::PathBuf, sync::Arc};
use tokio::{
io::{AsyncBufReadExt, AsyncWriteExt, BufReader, BufWriter},
io::{AsyncBufReadExt, AsyncRead, AsyncWrite, AsyncWriteExt, BufReader, BufWriter},
sync::Mutex,
};

Expand Down Expand Up @@ -79,12 +79,20 @@ impl RustAnalyzerMCPServer {
}

pub async fn run(&mut self) -> Result<()> {
info!("Starting rust-analyzer MCP server");

let stdin = tokio::io::stdin();
let stdout = tokio::io::stdout();
let mut reader = BufReader::new(stdin);
let mut writer = BufWriter::new(stdout);
self.run_with_streams(stdin, stdout).await
}

pub async fn run_with_streams<R, W>(&mut self, reader: R, writer: W) -> Result<()>

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Chatgpt GPT-5.6 on behalf of Zeeshan: [blocking] Please rebase this onto current main and reapply the generic reader/writer abstraction around the newly merged shutdown loop. The body here still contains the pre-#23 Arc<Mutex<bool>> polling implementation; resolving the conflict in its favor would discard the current signal racing, error propagation, and bounded cleanup behavior. Please also add a tokio::io::duplex regression test that exercises run_with_streams.

where
R: AsyncRead + Unpin,
W: AsyncWrite + Unpin,
{
info!("Starting rust-analyzer MCP server");

let mut reader = BufReader::new(reader);
let mut writer = BufWriter::new(writer);

// Handle shutdown signals.
let running = Arc::new(Mutex::new(true));
Expand Down