@@ -1003,7 +1003,7 @@ async def _connect_http_server(self, server_name: str, config: MCPServerConfig,
10031003
10041004 # Create HTTP client with authentication
10051005 headers = await self ._get_auth_headers (config , user_id )
1006- if headers is False :
1006+ if headers is None :
10071007 return False
10081008
10091009 # Store the connection (user-specific or system-level)
@@ -1018,19 +1018,19 @@ async def _connect_http_server(self, server_name: str, config: MCPServerConfig,
10181018 logger .info (f"Connected to HTTP server: { server_name } " + (f" for user { user_id } " if user_id else "" ))
10191019 return True
10201020
1021- async def _get_auth_headers (self , config : MCPServerConfig , user_id : Optional [str ] = None ) -> Dict [str , str ]:
1021+ async def _get_auth_headers (self , config : MCPServerConfig , user_id : Optional [str ] = None ) -> Optional [ Dict [str , str ] ]:
10221022 """Get authentication headers for a server"""
10231023 headers = {}
10241024 if config .auth :
10251025 if config .auth .type == AuthType .BEARER :
10261026 if not config .auth .token :
10271027 logger .error (f"No token specified for bearer auth on { config .name } " )
1028- return {}
1028+ return None
10291029 headers ["Authorization" ] = f"Bearer { config .auth .token } "
10301030 elif config .auth .type == AuthType .API_KEY :
10311031 if not config .auth .api_key or not config .auth .header_name :
10321032 logger .error (f"API key or header name not specified for { config .name } " )
1033- return {}
1033+ return None
10341034 headers [config .auth .header_name ] = config .auth .api_key
10351035 elif config .auth .type in [AuthType .OAUTH2_CLIENT_CREDENTIALS , AuthType .OAUTH2_AUTHORIZATION_CODE ]:
10361036 # Priority 1: Check Streamlit session state (for web UI)
@@ -1067,19 +1067,19 @@ async def _get_auth_headers(self, config: MCPServerConfig, user_id: Optional[str
10671067 # Check if user ID is required
10681068 if config .auth .requires_user_auth :
10691069 logger .error (f"User ID is required for user-based OAuth on { config .name } " )
1070- return {}
1070+ return None
10711071 else :
10721072 logger .error (f"No access token in Streamlit session state for { config .name } " )
1073- return {}
1073+ return None
10741074 else :
10751075 logger .error (f"No OAuth data found in Streamlit session state for { config .name } " )
1076- return {}
1076+ return None
10771077 else :
10781078 logger .error (f"Streamlit session state not available" )
1079- return {}
1079+ return None
10801080 except Exception as e :
10811081 logger .error (f"Failed to get Streamlit OAuth headers for { config .name } : { e } " )
1082- return {}
1082+ return None
10831083 else :
10841084 # Priority 2: Check environment variables (for CLI/automation)
10851085 # Only used when NOT running in Streamlit
@@ -1111,7 +1111,7 @@ async def _get_auth_headers(self, config: MCPServerConfig, user_id: Optional[str
11111111 f" Alternatively, authenticate via Streamlit web interface.\n "
11121112 f" Server will be skipped."
11131113 )
1114- return {}
1114+ return None
11151115
11161116 return headers
11171117
@@ -1137,7 +1137,7 @@ async def _get_auth_headers(self, config: MCPServerConfig, user_id: Optional[str
11371137 f" Alternatively, authenticate via Streamlit web interface.\n "
11381138 f" Server will be skipped."
11391139 )
1140- return {}
1140+ return None
11411141
11421142 return headers
11431143
0 commit comments