Skip to content

Commit 171dc5c

Browse files
committed
remove testclient
1 parent bccd718 commit 171dc5c

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

tests/server/fastmcp/test_server.py

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,16 +1073,21 @@ def prompt_fn(name: str) -> str:
10731073
with pytest.raises(McpError, match="Missing required arguments"):
10741074
await client.get_prompt("prompt_fn")
10751075

1076-
@pytest.mark.anyio
1077-
@pytest.mark.filterwarnings("ignore::DeprecationWarning:httpx")
1078-
async def test_streamable_http_no_redirect(self):
1079-
"""Test that /mcp endpoint does not cause 307 redirect (PR #1115)."""
1080-
from starlette.testclient import TestClient
1081-
1082-
mcp = FastMCP("test-redirect")
1083-
app = mcp.streamable_http_app()
1084-
1085-
with TestClient(app, raise_server_exceptions=False) as client:
1086-
# Test POST to /mcp - should NOT redirect
1087-
response = client.post("/mcp", json={"test": "data"}, follow_redirects=False)
1088-
assert response.status_code != 307
1076+
1077+
def test_streamable_http_no_redirect() -> None:
1078+
"""Test that streamable HTTP routes are correctly configured."""
1079+
mcp = FastMCP()
1080+
app = mcp.streamable_http_app()
1081+
1082+
# Find routes by type - streamable_http_app creates Route objects, not Mount objects
1083+
streamable_routes = [
1084+
r
1085+
for r in app.routes
1086+
if isinstance(r, Route) and hasattr(r, "path") and r.path == mcp.settings.streamable_http_path
1087+
]
1088+
1089+
# Verify routes exist
1090+
assert len(streamable_routes) == 1, "Should have one streamable route"
1091+
1092+
# Verify path values
1093+
assert streamable_routes[0].path == "/mcp", "Streamable route path should be /mcp"

0 commit comments

Comments
 (0)