π The fast, Pythonic way to build MCP servers and clients.
Clean up code for creating the resource url (#1916)
Jeremiah Lowinfccd08175868
diff --git a/src/fastmcp/server/auth/auth.py b/src/fastmcp/server/auth/auth.pyindex 6c2eafc30..e67928651 100644--- a/src/fastmcp/server/auth/auth.py+++ b/src/fastmcp/server/auth/auth.py@@ -1,7 +1,6 @@from __future__ import annotationsfrom typing import Any-from urllib.parse import urljoinfrom mcp.server.auth.middleware.auth_context import AuthContextMiddlewarefrom mcp.server.auth.middleware.bearer_auth import (@@ -146,7 +145,9 @@ class AuthProvider(TokenVerifierProtocol):return Noneif path:- return AnyHttpUrl(f"{str(self.base_url).rstrip('/')}/{path.lstrip('/')}")+ prefix = str(self.base_url).rstrip("/")+ suffix = path.lstrip("/")+ return AnyHttpUrl(f"{prefix}/{suffix}")return self.base_urldiff --git a/tests/server/auth/test_remote_auth_provider.py b/tests/server/auth/test_remote_auth_provider.pyindex a5d435641..eedb871b3 100644--- a/tests/server/auth/test_remote_auth_provider.py+++ b/tests/server/auth/test_remote_auth_provider.py@@ -239,7 +239,6 @@ class TestRemoteAuthProviderIntegration:("https://api.example.com", "https://api.example.com/mcp"),("https://api.example.com/", "https://api.example.com/mcp"),("https://api.example.com/v1/", "https://api.example.com/v1/mcp"),-],)async def test_base_url_configurations(self, base_url: str, expected_resource: str):