test(mcp): pin the dependencies the http transport needs declared
`tests/pointer/test_vendored_protocol.py` asserts the root pyproject names `pywayland` and `xkbcommon`, with a comment saying why neither may be optional. The MCP distribution had no equivalent, which left the previous commit's argument resting on a comment. So: `starlette` and `uvicorn` by name, and `anyio` beside them as the precedent they follow. The point of the test is that leaving them out would *work* -- the SDK propagates all three today -- which is exactly what makes a tripwire worth having rather than redundant. Skipped outside a checkout, the same way its sibling is: the build sandbox copies only `tests/`. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KchcvnbfhhZhUHy83YL3Ya
This commit is contained in:
1 parent
8d6a6c7ae8
commit
abf2c96ec1
1 file changed
+33
@@ -23,6 +23,7 @@ would 421 them, which is the behaviour ``test_rebinding_protection_*`` asserts.
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import pathlib
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -468,3 +469,35 @@ def test_offered_for_returns_everything_without_a_grant():
|
||||
|
||||
chooser = http_transport.offered_for(Server("probe"), tools.TOOLS)
|
||||
assert chooser() == tools.TOOLS
|
||||
|
||||
|
||||
# ── the dependencies this transport needs declared ─────────────────────────
|
||||
|
||||
|
||||
#: `src/hhstream_mcp/pyproject.toml`, when the suite is run from a checkout.
|
||||
#: Absent in the build sandbox, which copies only `tests/`.
|
||||
MCP_PYPROJECT = (
|
||||
pathlib.Path(__file__).resolve().parents[2] / "src" / "hhstream_mcp" / "pyproject.toml"
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.skipif(not MCP_PYPROJECT.is_file(), reason="not running from a checkout")
|
||||
def test_the_distribution_declares_what_this_module_imports():
|
||||
"""`starlette` and `uvicorn` by name, not by way of the SDK.
|
||||
|
||||
The same assertion `tests/pointer/test_vendored_protocol.py` makes about
|
||||
`pywayland` and `xkbcommon`, and for the same kind of reason. The MCP SDK
|
||||
propagates both of these today, so leaving them out of the metadata would
|
||||
*work* — which is exactly what makes it worth pinning. `http.py` imports
|
||||
`uvicorn` by name and the SDK's `TransportSecuritySettings` sits on
|
||||
Starlette's `Request`, so an SDK release that moved its HTTP transport
|
||||
behind an optional extra would break `serve --http` with an ImportError
|
||||
naming somebody else's package.
|
||||
"""
|
||||
|
||||
pyproject = MCP_PYPROJECT.read_text()
|
||||
assert "starlette" in pyproject
|
||||
assert "uvicorn" in pyproject
|
||||
# And `anyio`, which was already declared on this argument before the HTTP
|
||||
# transport existed — the precedent this follows.
|
||||
assert "anyio" in pyproject
|
||||
Reference in new issue
Block a user