Skip to content

Commit 4f4b991

Browse files
committed
Integrate proxy components into auth module
Signed-off-by: Jesse Sanford <108698+jessesanford@users.noreply.github.com>
1 parent 5272cd7 commit 4f4b991

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

src/mcp/server/auth/__init__.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,47 @@
1+
# pyright: reportGeneralTypeIssues=false
12
"""
23
MCP OAuth server authorization components.
34
"""
5+
6+
# Convenience re-exports so users can simply::
7+
#
8+
# from mcp.server.auth import build_proxy_server
9+
#
10+
# instead of digging into the sub-package path.
11+
12+
from typing import TYPE_CHECKING
13+
14+
from mcp.server.auth.proxy import (
15+
create_proxy_routes,
16+
fetch_upstream_metadata,
17+
)
18+
from mcp.server.fastmcp.utilities.logging import configure_logging
19+
20+
# For *build_proxy_server* we need a lazy import to avoid a circular reference
21+
# during the initial package import sequence (FastMCP -> auth -> proxy ->
22+
# FastMCP ...). PEP 562 allows us to implement module-level `__getattr__` for
23+
# this purpose.
24+
25+
26+
def __getattr__(name: str): # noqa: D401
27+
if name == "build_proxy_server":
28+
from mcp.server.auth.proxy.server import build_proxy_server as _bps # noqa: WPS433
29+
30+
globals()["build_proxy_server"] = _bps
31+
return _bps
32+
raise AttributeError(name)
33+
34+
35+
# ---------------------------------------------------------------------------
36+
# Public API specification
37+
# ---------------------------------------------------------------------------
38+
39+
__all__: list[str] = [
40+
"configure_logging",
41+
"create_proxy_routes",
42+
"fetch_upstream_metadata",
43+
"build_proxy_server",
44+
]
45+
46+
if TYPE_CHECKING: # pragma: no cover – make *build_proxy_server* visible to type checkers
47+
from mcp.server.auth.proxy.server import build_proxy_server # noqa: F401

0 commit comments

Comments
 (0)