Skip to content

Commit 38c574f

Browse files
committed
ruff
1 parent 86283c3 commit 38c574f

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

examples/servers/simple-auth/mcp_simple_auth/server.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818

1919
from mcp.server.auth.middleware.auth_context import get_access_token
2020
from mcp.server.auth.settings import AuthSettings
21-
from .token_verifier import IntrospectionTokenVerifier
2221
from mcp.server.fastmcp.server import FastMCP
2322

23+
from .token_verifier import IntrospectionTokenVerifier
24+
2425
logger = logging.getLogger(__name__)
2526

2627

examples/servers/simple-auth/mcp_simple_auth/token_verifier.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
"""Example token verifier implementation using OAuth 2.0 Token Introspection (RFC 7662)."""
22

33
import logging
4+
45
from mcp.server.auth.provider import AccessToken
56

67
logger = logging.getLogger(__name__)
78

89

910
class IntrospectionTokenVerifier:
1011
"""Example token verifier that uses OAuth 2.0 Token Introspection (RFC 7662).
11-
12+
1213
This is a simple example implementation for demonstration purposes.
1314
Production implementations should consider:
1415
- Connection pooling and reuse
@@ -25,14 +26,14 @@ async def verify_token(self, token: str) -> AccessToken | None:
2526
import httpx
2627

2728
# Validate URL to prevent SSRF attacks
28-
if not self.introspection_endpoint.startswith(('https://', 'http://localhost', 'http://127.0.0.1')):
29+
if not self.introspection_endpoint.startswith(("https://", "http://localhost", "http://127.0.0.1")):
2930
logger.warning(f"Rejecting introspection endpoint with unsafe scheme: {self.introspection_endpoint}")
3031
return None
3132

3233
# Configure secure HTTP client
3334
timeout = httpx.Timeout(10.0, connect=5.0)
3435
limits = httpx.Limits(max_connections=10, max_keepalive_connections=5)
35-
36+
3637
async with httpx.AsyncClient(
3738
timeout=timeout,
3839
limits=limits,
@@ -61,4 +62,4 @@ async def verify_token(self, token: str) -> AccessToken | None:
6162
)
6263
except Exception as e:
6364
logger.warning(f"Token introspection failed: {e}")
64-
return None
65+
return None

src/mcp/server/auth/provider.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,9 @@ def construct_redirect_uri(redirect_uri_base: str, **params: str | None) -> str:
282282

283283
class ProviderTokenVerifier:
284284
"""Token verifier that uses an OAuthAuthorizationServerProvider.
285-
285+
286286
This is provided for backwards compatibility with existing auth_server_provider
287-
configurations. For new implementations using AS/RS separation, consider using
287+
configurations. For new implementations using AS/RS separation, consider using
288288
the TokenVerifier protocol with a dedicated implementation like IntrospectionTokenVerifier.
289289
"""
290290

src/mcp/server/fastmcp/server.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@
6767
logger = get_logger(__name__)
6868

6969

70-
71-
7270
class Settings(BaseSettings, Generic[LifespanResultT]):
7371
"""FastMCP server settings.
7472

0 commit comments

Comments
 (0)