Add configuration for maximum receive buffer size to NetworkTransport#146
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR makes the receive buffer size in NetworkTransport configurable and increases the default from the hardcoded 64KB limit.
- Introduced
BufferConfigurationfor settingmaxReceiveBufferSize - Updated
NetworkTransportinitializers to accept abufferConfig - Modified the
receivecall to use the configured buffer size
Comments suppressed due to low confidence (2)
Sources/MCP/Base/Transports/NetworkTransport.swift:219
- The doc comment mentions "uses system default" when
maxReceiveBufferSizeis nil, but the code falls back toInt.max. Please clarify whether nil should delegate to the system default or truly be unlimited, and update the comment to match the implementation.
/// Set to nil for unlimited (uses system default).
Sources/MCP/Base/Transports/NetworkTransport.swift:217
- [nitpick] New
BufferConfigurationbehavior (default limits and unlimited mode) should be covered by unit tests to ensure that buffers respect the configured sizes and fallback logic.
public struct BufferConfiguration: Hashable, Sendable {
mstepanov
pushed a commit
to mstepanov/mcp-swift-sdk
that referenced
this pull request
Sep 18, 2025
…modelcontextprotocol#146) (cherry picked from commit 494b5b5)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently,
NetworkTransporthas a hardcoded limit of 64KB for how many bytes can be received at once. This PR bumps the default to 10MB and makes this configurable.