Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
refactor(api): improve type safety in MCPToolManageService.execute_auth_actions (#34824)
dev-miro26f4d5e2f43d34
diff --git a/api/services/tools/mcp_tools_manage_service.py b/api/services/tools/mcp_tools_manage_service.pyindex 690b06ea7d1..89762d6772a 100644--- a/api/services/tools/mcp_tools_manage_service.py+++ b/api/services/tools/mcp_tools_manage_service.py@@ -17,6 +17,7 @@ from core.helper import encrypterfrom core.helper.provider_cache import NoOpProviderCredentialCachefrom core.mcp.auth.auth_flow import authfrom core.mcp.auth_client import MCPClientWithAuthRetry+from core.mcp.entities import AuthActionType, AuthResultfrom core.mcp.error import MCPAuthError, MCPErrorfrom core.mcp.types import Tool as MCPToolfrom core.tools.entities.api_entities import ToolProviderApiEntity@@ -496,7 +497,13 @@ class MCPToolManageService:) as mcp_client:return mcp_client.list_tools()- def execute_auth_actions(self, auth_result: Any) -> dict[str, str]:+ _ACTION_TO_OAUTH: dict[AuthActionType, OAuthDataType] = {+ AuthActionType.SAVE_CLIENT_INFO: OAuthDataType.CLIENT_INFO,+ AuthActionType.SAVE_TOKENS: OAuthDataType.TOKENS,+ AuthActionType.SAVE_CODE_VERIFIER: OAuthDataType.CODE_VERIFIER,+ }++ def execute_auth_actions(self, auth_result: AuthResult) -> dict[str, str]:"""Execute the actions returned by the auth function.@@ -508,19 +515,13 @@ class MCPToolManageService:Returns:The response from the auth result"""- from core.mcp.entities import AuthAction, AuthActionType-- action: AuthActionfor action in auth_result.actions:if action.provider_id is None or action.tenant_id is None:continue- if action.action_type == AuthActionType.SAVE_CLIENT_INFO:- self.save_oauth_data(action.provider_id, action.tenant_id, action.data, OAuthDataType.CLIENT_INFO)- elif action.action_type == AuthActionType.SAVE_TOKENS:- self.save_oauth_data(action.provider_id, action.tenant_id, action.data, OAuthDataType.TOKENS)- elif action.action_type == AuthActionType.SAVE_CODE_VERIFIER:- self.save_oauth_data(action.provider_id, action.tenant_id, action.data, OAuthDataType.CODE_VERIFIER)+ oauth_type = self._ACTION_TO_OAUTH.get(action.action_type)+ if oauth_type is not None:+ self.save_oauth_data(action.provider_id, action.tenant_id, action.data, oauth_type)return auth_result.response