Support substituting `receive()` with a different AsyncSequence

Open
#127 0 comments 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
42/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
swift
Domain
api

Research direction

Start by locating the Transport API and its receive() declaration, then inspect the conforming transport implementations and related tests. Determine all affected call sites and verify that a transport can provide an alternative AsyncSequence with backpressure while existing message handling and error behavior remain covered.

Written by the indexing model from the issue text.

Description

enhancement

Is your feature request related to a problem? Please describe.
The current Transport API mandates that the receive() function is an AsyncThrowingStream. Unfortunately, this type doesn't support backpressure. Meaning that if the messages are handled slower than they arrive, this will start (slowly or quickly) blowing up memory. At large volumes, this can cause an unintentional Denial of Service.

Describe the solution you'd like
If we can have an associatedtype instead of the AsyncThrowingStream, Swift(NIO) based libraries can provide their own implementations that support backpressure. That would eliminate this problem.

associatedtype Messages: AsyncStream<Data, any Error>
Dominant language
Swift
Stars
1.6k
Forks
278
Avg merge
11h 15m
Merged PRs (30d)
46

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from modelcontextprotocol/swift-sdk

All issues in modelcontextprotocol/swift-sdk

Similar issues

More Swift issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.