Clean up code for creating the resource url (#1916)

This commit is contained in:
Jeremiah Lowin 2025-09-25 10:42:57 -04:00 committed by GitHub
commit fccd081758
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 3 deletions

View file

@ -1,7 +1,6 @@
from __future__ import annotations
from typing import Any
from urllib.parse import urljoin
from mcp.server.auth.middleware.auth_context import AuthContextMiddleware
from mcp.server.auth.middleware.bearer_auth import (
@ -146,7 +145,9 @@ class AuthProvider(TokenVerifierProtocol):
return None
if 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_url

View file

@ -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):