Adopting `with`- style accessors as part of the Transport APIs
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 30/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- swift
- Domain
- api, backend-api-design
Research direction
Start by reading the existing Transport API entry points for connect(), send(), and receive(), then compare them with the proposed withClient closure flow. Done means a bootstrap can manage the connection for the closure, expose sending and incoming messages there, and close and clean up when the closure returns.
Written by the indexing model from the issue text.
Description
Is your feature request related to a problem? Please describe.
The current Transport APIs require the user to call connect() to establish a connection. From this point, the user has to manually track whether or not the connection is still alive, by handling any errors thrown by send or receive.
If a user wants to correctly handle error cases, this leads to more complexity in their implementations.
Describe the solution you'd like
In the Swift on Server ecosystem, we've adopted a with- style pattern, which compliments prior art in Swift's standard library. In there, we have a "bootstrap" for each transport that can be configured with the intended behavior of a transport connection.
let bootstrap = MCPTransportBootstrap()
A bootstrap connects in a with- style function call like so:
bootstrap.withClient { send, messages in
try await send(SomeToolCall())
for try await message in messages {
// Handle incoming traffic
}
}
Returning out of the withClient scope closes and cleans up the connection.
This pattern can be wrapped in more domain specific use cases like a request/response style flow in the higher level APIs.
- Dominant language
- Swift
- Stars
- 1.6k
- Forks
- 278
- Avg merge
- 11h 15m
- Merged PRs (30d)
- 46
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from modelcontextprotocol/swift-sdk
-
-32042 without elicitations drops JSON-RPC error dataPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
modelcontextprotocol/swift-sdk#381 ·
Maintainers usually reply within 1 day
-
StdioTransport traps ("Negative value is not representable") when stdio is a socket, e.g. spawned by Node clientsPossibly taken @branben claimed this 9 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
modelcontextprotocol/swift-sdk#327 · 1 comment ·
Maintainers usually reply within 1 day
-
Value decoding changes data-URL-looking JSON strings into Value.dataPossibly taken @bitbemol claimed this 89 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
modelcontextprotocol/swift-sdk#277 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 1/5 Under an hour Newbie friendliness 78/100
modelcontextprotocol/swift-sdk#274 ·
Maintainers usually reply within 1 day
-
`HTTPClientTransport` fails to build on Windows: `#if !os(Linux)` guards no longer match the `EventSource` platform conditionMay be free again A pull request for this issue was closed without being merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
modelcontextprotocol/swift-sdk#261 ·
Maintainers usually reply within 1 day
All issues in modelcontextprotocol/swift-sdk
Similar issues
-
needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
manaflow-ai/cmux#59692 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 2 days
-
App 仍在下载和解析用不上的会话列表Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
vibe-cafe/vibe-usage-app#125 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 76/100
touyou/CheckItOut#39 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
touyou/IntentTodo#232 ·
Maintainers usually reply within 1 day