File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -208,11 +208,11 @@ filterwarnings = [
208208 " ignore:getargs.*The 'u' format is deprecated:DeprecationWarning" ,
209209 # `mcp` prefers `httpx2`; importing `mcp.shared._httpx` warns when falling back to
210210 # `httpx`. The lockfile pins `httpx`, so CI always exercises the fallback. We match on
211- # the message string only — naming the category would force pytest to import
212- # `mcp.shared._warnings`, which cascades through `mcp/__init__.py` and triggers the
213- # very warning we're trying to filter (the same trap pydantic-ai documents). The
214- # dedicated test in `tests/shared/test_httpx_shim.py` covers emission. Remove this entry
215- # once `httpx2` is the dependency and the fallback is dropped.
211+ # the message string only — naming the category would force pytest's filter parser to
212+ # `__import__` the module hosting `MCPDeprecationWarning`, which cascades through
213+ # `mcp/__init__.py` and triggers the very warning we're trying to filter (the same trap
214+ # pydantic-ai documents). The dedicated test in `tests/shared/test_httpx_shim.py` covers
215+ # emission. Remove this entry once `httpx2` is the dependency and the fallback is dropped.
216216 " ignore:Using `httpx` with `mcp` is deprecated" ,
217217]
218218
Original file line number Diff line number Diff line change 99dependency to `httpx2`.
1010
1111The warning is emitted at module-import time and fires at most once per process via Python's
12- module cache. `MCPDeprecationWarning` lives in `mcp.shared._warnings` so pytest's
13- `filterwarnings` parser can resolve the category symbol without importing this shim.
12+ module cache.
1413"""
1514
1615from __future__ import annotations
1716
1817import warnings
1918from typing import TYPE_CHECKING
2019
21- from mcp .shared ._warnings import MCPDeprecationWarning
20+ from mcp .shared .exceptions import MCPDeprecationWarning
2221
23- __all__ = ["MCPDeprecationWarning" , " httpx" ]
22+ __all__ = ["httpx" ]
2423
2524
2625if TYPE_CHECKING :
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -41,6 +41,14 @@ def __str__(self) -> str:
4141 return self .message
4242
4343
44+ class MCPDeprecationWarning (UserWarning ):
45+ """Deprecation warning emitted by the `mcp` package.
46+
47+ Subclasses `UserWarning` (not `DeprecationWarning`) so it is visible by default —
48+ `DeprecationWarning` is silenced at the Python level for non-`__main__` callers.
49+ """
50+
51+
4452class StatelessModeNotSupported (RuntimeError ):
4553 """Raised when attempting to use a method that is not supported in stateless mode.
4654
Original file line number Diff line number Diff line change 1313
1414import pytest
1515
16- from mcp .shared ._warnings import MCPDeprecationWarning
16+ from mcp .shared .exceptions import MCPDeprecationWarning
1717
1818
1919def _force_reimport_shim () -> None :
You can’t perform that action at this time.
0 commit comments