@@ -127,8 +127,6 @@ async def authorize(
127127 }
128128
129129 consent_url = f"{ self .settings .server_url } consent?{ urlencode (consent_params )} "
130- print (f"[DEBUGG] { consent_url } { state } " )
131-
132130 return consent_url
133131
134132 async def handle_github_callback (self , code : str , state : str ) -> str :
@@ -277,10 +275,15 @@ async def revoke_token(
277275 del self .tokens [token ]
278276
279277
280- @dataclass
281278class ConsentHandler :
282- provider : OAuthAuthorizationServerProvider [Any , Any , Any ]
283- settings : ServerSettings
279+
280+
281+
282+ def __init__ (self , provider : SimpleGitHubOAuthProvider , settings : ServerSettings , path : str ):
283+ self .provider : SimpleGitHubOAuthProvider = provider
284+ self .settings : ServerSettings = settings
285+ self .client_consent : dict [str , bool ] = {}
286+ self .path = path
284287
285288 async def handle (self , request : Request ) -> Response :
286289 # This handles both showing the consent form (GET) and processing consent (POST)
@@ -308,11 +311,11 @@ async def _show_consent_form(self, request: Request) -> HTMLResponse:
308311 if client and hasattr (client , 'client_name' ):
309312 client_name = client .client_name
310313
311- # TODO: get this passed in
312- target_url = "/consent"
314+ target_url = self .path
313315
314- # Create a simple consent form
316+ # TODO: allow skipping consent if we've already approved this client ID
315317
318+ # Create a simple consent form
316319 html_content = f"""
317320<!DOCTYPE html>
318321<html>
@@ -436,9 +439,7 @@ async def _process_consent(self, request: Request) -> RedirectResponse | HTMLRes
436439 if client_id :
437440 client = await self .provider .get_client (client_id )
438441 if client :
439- # TODO: move this out of provider
440- await self .provider .grant_client_consent (client )
441-
442+ self .client_consent [client .client_id ] = True
442443
443444 auth_url = (
444445 f"{ self .settings .github_auth_url } "
@@ -505,8 +506,6 @@ def create_simple_mcp_server(settings: ServerSettings) -> FastMCP:
505506 enabled = True ,
506507 valid_scopes = [settings .mcp_scope ],
507508 default_scopes = [settings .mcp_scope ],
508- # Turning off consent since we'll handle it via custom endpoint
509- client_consent_required = False
510509 ),
511510 required_scopes = [settings .mcp_scope ],
512511 )
@@ -521,9 +520,10 @@ def create_simple_mcp_server(settings: ServerSettings) -> FastMCP:
521520 auth = auth_settings ,
522521 )
523522
524- consent_handler = ConsentHandler (provider = oauth_provider , settings = settings )
523+ consent_path = "/consent"
524+ consent_handler = ConsentHandler (provider = oauth_provider , settings = settings , path = consent_path )
525525
526- @app .custom_route ("/consent" , methods = ["GET" , "POST" ])
526+ @app .custom_route (consent_path , methods = ["GET" , "POST" ])
527527 async def example_consent_handler (request : Request ) -> Response :
528528 return await consent_handler .handle (request )
529529
0 commit comments