diff --git a/src/fetch/pyproject.toml b/src/fetch/pyproject.toml index 84735f278a..4cbf1e0b2c 100644 --- a/src/fetch/pyproject.toml +++ b/src/fetch/pyproject.toml @@ -18,7 +18,7 @@ classifiers = [ dependencies = [ "httpx>=0.27", "markdownify>=0.13.1", - "mcp>=1.1.3", + "mcp>=1.1.3,<2", "protego>=0.3.1", "pydantic>=2.0.0", "readabilipy>=0.2.0", diff --git a/src/fetch/tests/test_server.py b/src/fetch/tests/test_server.py index 96c1cb38c7..be82914d14 100644 --- a/src/fetch/tests/test_server.py +++ b/src/fetch/tests/test_server.py @@ -1,8 +1,11 @@ """Tests for the fetch MCP server.""" +import tomllib import pytest +from pathlib import Path from unittest.mock import AsyncMock, patch, MagicMock from mcp.shared.exceptions import McpError +from packaging.requirements import Requirement from mcp_server_fetch.server import ( extract_content_from_html, @@ -324,3 +327,23 @@ async def test_fetch_with_proxy(self): # Verify AsyncClient was called with proxy mock_client_class.assert_called_once_with(proxy="http://proxy.example.com:8080") + + +class TestDeclaredDependencies: + """Tests for the dependencies declared in pyproject.toml.""" + + def test_mcp_requirement_excludes_2x(self): + """Test that the mcp requirement excludes the 2.x line. + + mcp 2.0.0 renamed McpError to MCPError and changed its constructor, so + server.py fails to import against it. Without an upper bound, unpinned + launchers such as uvx resolve 2.x and the server dies on startup. + """ + pyproject = Path(__file__).parent.parent / "pyproject.toml" + with pyproject.open("rb") as f: + dependencies = tomllib.load(f)["project"]["dependencies"] + + requirements = [Requirement(dep) for dep in dependencies] + mcp_requirement = next(req for req in requirements if req.name == "mcp") + + assert not mcp_requirement.specifier.contains("2.0.0") diff --git a/src/fetch/uv.lock b/src/fetch/uv.lock index ea9b0567e2..4f6f729518 100644 --- a/src/fetch/uv.lock +++ b/src/fetch/uv.lock @@ -582,7 +582,7 @@ dev = [ requires-dist = [ { name = "httpx", specifier = ">=0.27" }, { name = "markdownify", specifier = ">=0.13.1" }, - { name = "mcp", specifier = ">=1.1.3" }, + { name = "mcp", specifier = ">=1.1.3,<2" }, { name = "protego", specifier = ">=0.3.1" }, { name = "pydantic", specifier = ">=2.0.0" }, { name = "readabilipy", specifier = ">=0.2.0" },