Skip to content

Conversation

@mattt
Copy link
Contributor

@mattt mattt commented Jul 8, 2025

Currently, NetworkTransport has 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.

@mattt mattt requested a review from Copilot July 8, 2025 21:45
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR makes the receive buffer size in NetworkTransport configurable and increases the default from the hardcoded 64KB limit.

  • Introduced BufferConfiguration for setting maxReceiveBufferSize
  • Updated NetworkTransport initializers to accept a bufferConfig
  • Modified the receive call 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 maxReceiveBufferSize is nil, but the code falls back to Int.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 BufferConfiguration behavior (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 {

@mattt mattt merged commit 494b5b5 into main Jul 8, 2025
6 checks passed
@mattt mattt deleted the mattt/network-transport-buffer-configuration branch July 8, 2025 21:48
mstepanov pushed a commit to mstepanov/mcp-swift-sdk that referenced this pull request Sep 18, 2025
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