@@ -82,19 +82,15 @@ async def register_client(self, client_info: OAuthClientInformationFull):
8282 """Register a new OAuth client."""
8383 self .clients [client_info .client_id ] = client_info
8484
85- async def authorize (
86- self , client : OAuthClientInformationFull , params : AuthorizationParams
87- ) -> str :
85+ async def authorize (self , client : OAuthClientInformationFull , params : AuthorizationParams ) -> str :
8886 """Generate an authorization URL for GitHub OAuth flow."""
8987 state = params .state or secrets .token_hex (16 )
9088
9189 # Store the state mapping
9290 self .state_mapping [state ] = {
9391 "redirect_uri" : str (params .redirect_uri ),
9492 "code_challenge" : params .code_challenge ,
95- "redirect_uri_provided_explicitly" : str (
96- params .redirect_uri_provided_explicitly
97- ),
93+ "redirect_uri_provided_explicitly" : str (params .redirect_uri_provided_explicitly ),
9894 "client_id" : client .client_id ,
9995 }
10096
@@ -117,9 +113,7 @@ async def handle_github_callback(self, code: str, state: str) -> str:
117113
118114 redirect_uri = state_data ["redirect_uri" ]
119115 code_challenge = state_data ["code_challenge" ]
120- redirect_uri_provided_explicitly = (
121- state_data ["redirect_uri_provided_explicitly" ] == "True"
122- )
116+ redirect_uri_provided_explicitly = state_data ["redirect_uri_provided_explicitly" ] == "True"
123117 client_id = state_data ["client_id" ]
124118
125119 # Exchange code for token with GitHub
@@ -200,8 +194,7 @@ async def exchange_authorization_code(
200194 for token , data in self .tokens .items ()
201195 # see https://github.blog/engineering/platform-security/behind-githubs-new-authentication-token-formats/
202196 # which you get depends on your GH app setup.
203- if (token .startswith ("ghu_" ) or token .startswith ("gho_" ))
204- and data .client_id == client .client_id
197+ if (token .startswith ("ghu_" ) or token .startswith ("gho_" )) and data .client_id == client .client_id
205198 ),
206199 None ,
207200 )
@@ -232,9 +225,7 @@ async def load_access_token(self, token: str) -> AccessToken | None:
232225
233226 return access_token
234227
235- async def load_refresh_token (
236- self , client : OAuthClientInformationFull , refresh_token : str
237- ) -> RefreshToken | None :
228+ async def load_refresh_token (self , client : OAuthClientInformationFull , refresh_token : str ) -> RefreshToken | None :
238229 """Load a refresh token - not supported."""
239230 return None
240231
@@ -247,9 +238,7 @@ async def exchange_refresh_token(
247238 """Exchange refresh token"""
248239 raise NotImplementedError ("Not supported" )
249240
250- async def revoke_token (
251- self , token : str , token_type_hint : str | None = None
252- ) -> None :
241+ async def revoke_token (self , token : str , token_type_hint : str | None = None ) -> None :
253242 """Revoke a token."""
254243 if token in self .tokens :
255244 del self .tokens [token ]
@@ -335,9 +324,7 @@ async def get_user_profile() -> dict[str, Any]:
335324 )
336325
337326 if response .status_code != 200 :
338- raise ValueError (
339- f"GitHub API error: { response .status_code } - { response .text } "
340- )
327+ raise ValueError (f"GitHub API error: { response .status_code } - { response .text } " )
341328
342329 return response .json ()
343330
@@ -361,9 +348,7 @@ def main(port: int, host: str, transport: Literal["sse", "streamable-http"]) ->
361348 # No hardcoded credentials - all from environment variables
362349 settings = ServerSettings (host = host , port = port )
363350 except ValueError as e :
364- logger .error (
365- "Failed to load settings. Make sure environment variables are set:"
366- )
351+ logger .error ("Failed to load settings. Make sure environment variables are set:" )
367352 logger .error (" MCP_GITHUB_GITHUB_CLIENT_ID=<your-client-id>" )
368353 logger .error (" MCP_GITHUB_GITHUB_CLIENT_SECRET=<your-client-secret>" )
369354 logger .error (f"Error: { e } " )
0 commit comments