11
11
from starlette .exceptions import HTTPException
12
12
from starlette .requests import Request
13
13
from starlette .responses import JSONResponse , RedirectResponse , Response , HTMLResponse
14
- from dataclasses import dataclass
15
-
16
14
17
15
from mcp .server .auth .middleware .auth_context import get_access_token
18
16
from mcp .server .auth .provider import (
@@ -76,8 +74,6 @@ def __init__(self, settings: ServerSettings):
76
74
# Store GitHub tokens with MCP tokens using the format:
77
75
# {"mcp_token": "github_token"}
78
76
self .token_mapping : dict [str , str ] = {}
79
- # Track which clients have been granted consent
80
- self .client_consent : dict [str , bool ] = {}
81
77
82
78
async def get_client (self , client_id : str ) -> OAuthClientInformationFull | None :
83
79
"""Get OAuth client information."""
@@ -87,14 +83,6 @@ async def register_client(self, client_info: OAuthClientInformationFull):
87
83
"""Register a new OAuth client."""
88
84
self .clients [client_info .client_id ] = client_info
89
85
90
- async def has_client_consent (self , client : OAuthClientInformationFull ) -> bool :
91
- """Check if a client has already provided consent."""
92
- return self .client_consent .get (client .client_id , False )
93
-
94
- async def grant_client_consent (self , client : OAuthClientInformationFull ) -> None :
95
- """Grant consent for a client."""
96
- self .client_consent [client .client_id ] = True
97
-
98
86
async def authorize (
99
87
self , client : OAuthClientInformationFull , params : AuthorizationParams
100
88
) -> str :
@@ -277,8 +265,6 @@ async def revoke_token(
277
265
278
266
class ConsentHandler :
279
267
280
-
281
-
282
268
def __init__ (self , provider : SimpleGitHubOAuthProvider , settings : ServerSettings , path : str ):
283
269
self .provider : SimpleGitHubOAuthProvider = provider
284
270
self .settings : ServerSettings = settings
@@ -299,6 +285,7 @@ async def handle(self, request: Request) -> Response:
299
285
async def _show_consent_form (self , request : Request ) -> HTMLResponse :
300
286
client_id = request .query_params .get ("client_id" , "" )
301
287
redirect_uri = request .query_params .get ("redirect_uri" , "" )
288
+ # TODO: address csrf
302
289
state = request .query_params .get ("state" , "" )
303
290
scopes = request .query_params .get ("scopes" , "" )
304
291
code_challenge = request .query_params .get ("code_challenge" , "" )
0 commit comments