refactor: Update MCP composer auth to just api and oauth (#9487)

* Update auth to just api and oauth

* schema push

* pr comment fix
This commit is contained in:
Mike Fortman 2025-08-21 20:57:04 -05:00 • committed by GitHub
commit fd9f8c5711
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 6 additions and 209 deletions

View file

@ -39,7 +39,6 @@ from langflow.base.mcp.constants import MAX_MCP_SERVER_NAME_LENGTH
from langflow.base.mcp.util import sanitize_mcp_name
from langflow.services.database.models import Flow, Folder
from langflow.services.deps import get_settings_service, session_scope
from langflow.services.settings.feature_flags import FEATURE_FLAGS
logger = logging.getLogger(__name__)
@ -368,7 +367,6 @@ async def install_mcp_config(
# Determine command and args based on operating system
os_type = platform.system()
command = "uvx"
mcp_tool = "mcp-composer" if FEATURE_FLAGS.mcp_composer else "mcp-proxy"
# Check if running on WSL (will appear as Linux but with Microsoft in release info)
is_wsl = os_type == "Linux" and "microsoft" in platform.uname().release.lower()
@ -398,33 +396,8 @@ async def install_mcp_config(
sse_url = sse_url.replace(f"http://{host}:{port}", f"http://{wsl_ip}:{port}")
except OSError as e:
logger.warning("Failed to get WSL IP address: %s. Using default URL.", str(e))
# Configure args based on the MCP tool
oauth_env = None
if FEATURE_FLAGS.mcp_composer:
args = [mcp_tool, "--sse-url", sse_url]
# Check for auth settings and add auth parameters
if project.auth_settings:
from langflow.api.v1.schemas import AuthSettings
auth_settings = AuthSettings(**project.auth_settings)
args.extend(["--auth_type", auth_settings.auth_type])
oauth_env = {
"OAUTH_HOST": auth_settings.oauth_host,
"OAUTH_PORT": auth_settings.oauth_port,
"OAUTH_SERVER_URL": auth_settings.oauth_server_url,
"OAUTH_CALLBACK_PATH": auth_settings.oauth_callback_path,
"OAUTH_CLIENT_ID": auth_settings.oauth_client_id,
"OAUTH_CLIENT_SECRET": auth_settings.oauth_client_secret,
"OAUTH_AUTH_URL": auth_settings.oauth_auth_url,
"OAUTH_TOKEN_URL": auth_settings.oauth_token_url,
"OAUTH_MCP_SCOPE": auth_settings.oauth_mcp_scope,
"OAUTH_PROVIDER_SCOPE": auth_settings.oauth_provider_scope,
}
else:
args = [mcp_tool, sse_url]
args = ["mcp-proxy", sse_url]
if os_type == "Windows":
command = "cmd"
@ -439,10 +412,6 @@ async def install_mcp_config(
"args": args,
}
# Add environment variables if mcp-composer feature flag is enabled and auth settings exist
if FEATURE_FLAGS.mcp_composer and oauth_env is not None:
server_config["env"] = oauth_env # type: ignore[assignment]
mcp_config = {
"mcpServers": {f"lf-{sanitize_mcp_name(name)[: (MAX_MCP_SERVER_NAME_LENGTH - 4)]}": server_config}
}

View file

@ -444,12 +444,8 @@ class CancelFlowResponse(BaseModel):
class AuthSettings(BaseModel):
"""Model representing authentication settings for MCP."""
auth_type: Literal["none", "apikey", "basic", "bearer", "iam", "oauth"] = "none"
auth_type: Literal["none", "apikey", "oauth"] = "none"
api_key: SecretStr | None = None
username: str | None = None
password: SecretStr | None = None
bearer_token: SecretStr | None = None
iam_endpoint: str | None = None
oauth_host: str | None = None
oauth_port: str | None = None
oauth_server_url: str | None = None