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 5 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion tests/shared/test_sse.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from starlette.routing import Mount, Route

from mcp.client.session import ClientSession
from mcp.client.sse import sse_client
from mcp.client.sse import remove_request_params, sse_client
from mcp.server import Server
from mcp.server.sse import SseServerTransport
from mcp.shared.exceptions import McpError
Expand Down Expand Up @@ -250,3 +250,14 @@ async def test_sse_client_timeout(
return

pytest.fail("the client should have timed out and returned an error already")


def test_remove_request_params():
# Removes query parameters
assert remove_request_params('http://example.com/test?foo=bar') == 'http://example.com/test'
# Removes fragment
assert remove_request_params('http://example.com/test#section') == 'http://example.com/test'
# Leaves clean URL unchanged
assert remove_request_params('http://example.com/test') == 'http://example.com/test'
# Works with path only
assert remove_request_params('/test/path?x=1') == '/test/path'
Loading