Skip to content

Conversation

@k61b
Copy link

@k61b k61b commented Jan 9, 2026

Add unit tests for normalizeHeaders and createFetchWithInit in packages/core/src/shared/transport.ts.

Motivation and Context

These utility functions are used by both SSEClientTransport and StreamableHTTPClientTransport but had no dedicated unit tests. Adding coverage helps catch regressions and documents expected behavior.

How Has This Been Tested?

pnpm -C packages/core test
# 441 tests passed

Breaking Changes

None. Test-only change.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

(This is a test-only change)

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

Tests cover:

  • normalizeHeaders: undefined, Headers instance, array of tuples, plain objects
  • createFetchWithInit: base init passthrough, option merging, header merging precedence

Copilot AI review requested due to automatic review settings January 9, 2026 15:38
@k61b k61b requested a review from a team as a code owner January 9, 2026 15:38
@changeset-bot
Copy link

changeset-bot bot commented Jan 9, 2026

⚠️ No Changeset found

Latest commit: 67cf485

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 9, 2026

Open in StackBlitz

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/client@1374
npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/server@1374

commit: 67cf485

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 adds comprehensive unit tests for two utility functions (normalizeHeaders and createFetchWithInit) in the transport module that previously lacked dedicated test coverage. The tests verify various input formats for header normalization and proper merging behavior for fetch initialization options.

Key changes:

  • New test file with 142 lines covering two utility functions
  • Tests for normalizeHeaders validate handling of undefined, Headers instances, arrays of tuples, and plain objects
  • Tests for createFetchWithInit verify base initialization passthrough, option merging, and header merging precedence

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@k61b k61b force-pushed the test/transport-utilities branch from 76779f6 to 3f7ef90 Compare January 9, 2026 15:58
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