diff --git a/src/mcp_agent/cli/commands/install.py b/src/mcp_agent/cli/commands/install.py index ac767016f..a768165b6 100644 --- a/src/mcp_agent/cli/commands/install.py +++ b/src/mcp_agent/cli/commands/install.py @@ -28,7 +28,6 @@ from copy import deepcopy from pathlib import Path from typing import Optional -from urllib.parse import urlparse import typer from rich.panel import Panel @@ -182,36 +181,6 @@ def _write_json(path: Path, data: dict) -> None: pass -def _server_hostname(server_url: str, app_name: Optional[str] = None) -> str: - """ - Generate a friendly server name from the URL. - - Extracts the subdomain or hostname to create a short, readable name. - For example, "https://abc123.deployments.mcp-agent.com/sse" -> "abc123" - - Args: - server_url: The server URL - app_name: Optional app name from API (preferred if available) - - Returns: - A friendly server name - """ - if app_name: - return app_name - - parsed = urlparse(server_url) - hostname = parsed.hostname or "" - - parts = hostname.split(".") - if len(parts) > 2 and "deployments" in hostname: - return parts[0] - - if len(parts) >= 2: - return ".".join(parts[:-1]) - - return hostname or "mcp-server" - - def _build_server_config( server_url: str, transport: str = "http", @@ -363,9 +332,6 @@ def install( # For ChatGPT, check if server has unauthenticated access enabled if client_lc == "chatgpt": try: - if not app_info: - app_info = run_async(mcp_client.get_app(server_url=server_url)) - has_unauth_access = app_info.unauthenticatedAccess is True or ( app_info.appServerInfo and app_info.appServerInfo.unauthenticatedAccess is True @@ -417,7 +383,7 @@ def install( ) return - server_name = name or _server_hostname(server_url, app_name) + server_name = name or app_name or "mcp_agent" transport = "sse" if server_url.rstrip("/").endswith("/sse") else "http" @@ -550,3 +516,8 @@ def install( border_style="green", ) ) + + console.print( + "\n💡 You may need to restart your MCP client for the changes to take effect.", + style="dim", + ) diff --git a/tests/cli/commands/test_install.py b/tests/cli/commands/test_install.py index 39a71f80f..faca72949 100644 --- a/tests/cli/commands/test_install.py +++ b/tests/cli/commands/test_install.py @@ -6,7 +6,6 @@ import pytest from mcp_agent.cli.commands.install import ( _build_server_config, - _server_hostname, _merge_mcp_json, install, ) @@ -42,32 +41,6 @@ def mock_app_without_auth(): return app -def test_server_hostname(): - """Test friendly server name generation from URLs.""" - # Test with deployment URL - assert _server_hostname("https://abc123.deployments.mcp-agent.com/sse") == "abc123" - assert _server_hostname("https://xyz456.deployments.example.com/mcp") == "xyz456" - - # Test with app name override - assert ( - _server_hostname("https://abc123.deployments.mcp-agent.com/sse", "my-app") - == "my-app" - ) - - # Test with regular domain - assert _server_hostname("https://api.example.com/sse") == "api.example" - assert ( - _server_hostname("https://subdomain.api.example.com/mcp") - == "subdomain.api.example" - ) - - # Test with simple domain - assert _server_hostname("https://example.com") == "example" - - # Test fallback - assert _server_hostname("invalid-url") == "mcp-server" - - def test_build_server_config(): """Test server configuration building with auth header.""" config = _build_server_config("https://example.com/mcp", "http", api_key="test-key")