Skip to content

Add requestModifier property to HTTPClientTransport #152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 10, 2025

Conversation

mattt
Copy link
Contributor

@mattt mattt commented Aug 10, 2025

Alternative to #149, as discussed in #149 (comment)

@mattt mattt force-pushed the mattt/request-modifier branch from 4c8af27 to 73650d2 Compare August 10, 2025 13:12
@mattt mattt force-pushed the mattt/request-modifier branch from d4bbe3b to 7d83d86 Compare August 10, 2025 13:21
@mattt mattt requested a review from Copilot August 10, 2025 13:21
Copy link

@Copilot 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 adds a requestModifier property to the HTTPClientTransport class to enable custom modification of HTTP requests before they are sent. This allows for adding authentication headers, custom headers, or other request modifications without subclassing.

  • Added requestModifier parameter to HTTPClientTransport initializers with a default no-op implementation
  • Applied the request modifier in both the send method and SSE connection setup
  • Added comprehensive test coverage for the new functionality

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
Sources/MCP/Base/Transports/HTTPClientTransport.swift Added requestModifier property and parameter to initializers, applied modifier in request methods
Tests/MCPTests/HTTPClientTransportTests.swift Added test for request modifier functionality and improved test setup ordering
Comments suppressed due to low confidence (1)

Tests/MCPTests/HTTPClientTransportTests.swift:535

  • This #endif directive appears to be incorrectly removed. The corresponding #if condition likely still exists above this line, creating unbalanced conditional compilation directives.
            }

@mattt mattt merged commit 0121dcc into main Aug 10, 2025
6 checks passed
@mattt mattt deleted the mattt/request-modifier branch August 10, 2025 13:28
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.

1 participant