Skip to content

test: add pytest coverage for SSE transport functions #557

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

passionateSandy2004
Copy link

@passionateSandy2004 passionateSandy2004 commented Apr 22, 2025

Added a new pytest function, test_remove_request_params, in tests/shared/test_sse.py to cover the previously untested remove_request_params utility in the SSE client module.

Motivation and Context

The remove_request_params function in src/mcp/client/sse.py was not directly tested, leaving potential edge cases unverified. By adding a focused unit test, we ensure that:

  • URLs with query parameters and fragments are correctly stripped down to their base form.
  • URLs without parameters remain unchanged.

This aligns the SSE client tests with the project’s coverage standards and closes gaps in our automated test suite.

How Has This Been Tested?

  • Ran pytest tests/shared/test_sse.py locally, confirming:
    • URLs like http://example.com/path?foo=bar#baz are normalized to http://example.com/path.
    • Clean URLs (e.g. https://mcp.dev/stream) pass through untouched.
  • Executed full test suite (pytest) to verify no regressions.

Breaking Changes

None. This update only adds tests and does not alter library behavior or public APIs.

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

Checklist

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

Additional context

This change brings the SSE client’s test coverage to 100% for its public utilities and contributes to overall library reliability.

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