Skip to content

Commit 695b1ab

Browse files
committed
Keep the wire packages statically discoverable to bundlers
The per-version wire packages are now imported by module name at runtime, so PyInstaller-style dependency scanners could no longer see them. A compiled-in but never-executed TYPE_CHECKING import of both packages next to the registry keeps them discoverable (and typed) without importing them at module load.
1 parent 9ef39b6 commit 695b1ab

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

‎src/mcp-types/mcp_types/methods.py‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,24 @@
1919
from functools import cache
2020
from importlib import import_module
2121
from types import MappingProxyType, ModuleType, UnionType
22-
from typing import Any, Final, Literal, TypeGuard, TypeVar, cast, get_args
22+
from typing import TYPE_CHECKING, Any, Final, Literal, TypeGuard, TypeVar, cast, get_args
2323

2424
from pydantic import BaseModel, TypeAdapter
2525

2626
import mcp_types as types
2727
from mcp_types.version import KNOWN_PROTOCOL_VERSIONS
2828

29+
if TYPE_CHECKING:
30+
# The wire packages are imported by module name at runtime (below), which a
31+
# static bundler (PyInstaller and friends) cannot see; these compiled-in but
32+
# never-executed imports keep the dependency discoverable for such tools
33+
# (else add the packages to the bundler's hidden imports; see
34+
# docs/advanced/import-cost.md).
35+
import mcp_types._v2025_11_25 as _v2025_11_25
36+
import mcp_types._v2026_07_28 as _v2026_07_28
37+
38+
_WIRE_PACKAGE_MODULES: Final = (_v2025_11_25, _v2026_07_28)
39+
2940
__all__ = [
3041
"CACHEABLE_METHODS",
3142
"CLIENT_NOTIFICATIONS",

0 commit comments

Comments
 (0)