Skip to content

Commit 84bfe75

Browse files
Use TypedDict for OAuth error responses
Replace Dict[str, str] with a more precise TypedDict that captures the exact structure of OAuth error responses. Also updates imports to use Python 3.10 style type annotations.
1 parent a1161ab commit 84bfe75

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/mcp/server/auth/errors.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@
44
Corresponds to TypeScript file: src/server/auth/errors.ts
55
"""
66

7-
from typing import Dict, Optional, Any
7+
from typing import Any, TypedDict
8+
9+
10+
class OAuthErrorResponse(TypedDict):
11+
"""OAuth error response format."""
12+
error: str
13+
error_description: str
814

915

1016
class OAuthError(Exception):
@@ -19,7 +25,7 @@ def __init__(self, message: str):
1925
super().__init__(message)
2026
self.message = message
2127

22-
def to_response_object(self) -> Dict[str, str]:
28+
def to_response_object(self) -> OAuthErrorResponse:
2329
"""Convert error to JSON response object."""
2430
return {
2531
"error": self.error_code,

0 commit comments

Comments
 (0)