Skip to content

Refactor run() to accept generic async streams - #8

Open
nikomatsakis wants to merge 1 commit into
zeenix:mainfrom
nikomatsakis:main
Open

nikomatsakis wants to merge 1 commit into
zeenix:mainfrom
nikomatsakis:main

Conversation

@nikomatsakis

Copy link
Copy Markdown
  • Add run_with_streams<R, W>() method accepting generic AsyncRead/AsyncWrite streams
  • Keep existing run() method for backward compatibility, delegating to run_with_streams()
  • Enables library usage with custom streams (duplex, Unix sockets, etc.) beyond stdio

- Add run_with_streams<R, W>() method accepting generic AsyncRead/AsyncWrite streams
- Keep existing run() method for backward compatibility, delegating to run_with_streams()
- Enables library usage with custom streams (duplex, Unix sockets, etc.) beyond stdio

Co-authored-by: Claude <claude@anthropic.com>
@zeenix

zeenix commented Aug 15, 2026

Copy link
Copy Markdown
Owner

Hi Niko, I'm sorry I never saw this but for some reason GitHub hasn't been sending me notifications about PRs on the repo. 🤦‍♂️

I'll look soon.

@zeenix zeenix left a comment

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: Apologies this sat unreviewed: notifications for this repository were accidentally disabled, so it wasn’t seen until now.

The generic stream abstraction itself is sound, but the branch conflicts directly with the shutdown work just merged in #23. Please rebase and add the custom-stream regression test below; resolving the conflict by retaining this branch’s old loop would reintroduce the shutdown bug. CONTRIBUTING.md also asks for a package prefix in the commit subject (for example, ♻️ mcp: Accept generic async streams). If this lands, #18 must preserve this public entry point during its server rewrite.

Comment thread src/mcp/server.rs
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.

@zeenix zeenix mentioned this pull request Aug 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants