Skip to content

Commit ac44aad

Browse files
committed
add cloud open
1 parent 71daae2 commit ac44aad

File tree

4 files changed

+63
-3
lines changed

4 files changed

+63
-3
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"""Cloud open command exports."""
2+
3+
from .main import open_portal
4+
5+
__all__ = ["open_portal"]
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
"""Open MCP Agent Cloud portal in browser."""
2+
3+
import webbrowser
4+
from typing import Optional
5+
6+
import typer
7+
8+
from mcp_agent.cli.core.constants import DEFAULT_BASE_URL
9+
from mcp_agent.cli.utils.ux import print_info, print_warning
10+
11+
12+
def open_portal(
13+
server: Optional[str] = typer.Option(
14+
None,
15+
"--server",
16+
help="Server ID or URL to open deployment details page",
17+
),
18+
) -> None:
19+
"""Open the MCP Agent Cloud portal in browser.
20+
21+
Opens the portal home page by default, or the deployment details page
22+
if a server ID or URL is provided.
23+
24+
Args:
25+
server: Optional server ID or URL to open deployment details for
26+
"""
27+
# Use the base URL directly for portal access
28+
base_url = DEFAULT_BASE_URL.rstrip("/")
29+
30+
if server:
31+
if server.startswith("http"):
32+
# If it's a URL, try to extract server ID
33+
url = f"{base_url}/deployments/{server.split('/')[-1]}"
34+
print_info(f"Opening deployment details for server: {server}")
35+
else:
36+
# If it's an ID, construct the deployment page URL
37+
url = f"{base_url}/deployments/{server}"
38+
print_info(f"Opening deployment details for server ID: {server}")
39+
else:
40+
url = f"{base_url}/dashboard"
41+
print_info("Opening MCP Agent Cloud portal")
42+
43+
try:
44+
webbrowser.open(url)
45+
print_info(f"Portal opened at: {url}")
46+
except Exception as e:
47+
print_warning(f"Could not open browser automatically: {str(e)}")
48+
print_info(f"Please open this URL manually: {url}")

src/mcp_agent/cli/cloud/main.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
list_app_workflows,
2121
)
2222
from mcp_agent.cli.cloud.commands.apps import list_apps
23+
from mcp_agent.cli.cloud.commands.open import open_portal
2324
from mcp_agent.cli.cloud.commands.workflow import get_workflow_status
2425
from mcp_agent.cli.exceptions import CLIError
2526
from mcp_agent.cli.utils.ux import print_error
@@ -160,7 +161,12 @@ def invoke(self, ctx):
160161
app_cmd_cloud_auth.command(name="logout", help="Clear credentials.")(logout)
161162
# Add auth sub-typer to cloud
162163
app_cmd_cloud.add_typer(app_cmd_cloud_auth, name="auth", help="Authentication commands")
163-
# Register cloud commands (only containing auth for now)
164+
165+
# Add open command to cloud
166+
app_cmd_cloud.command(name="open", help="Open the MCP Agent Cloud portal in browser")(
167+
open_portal
168+
)
169+
164170
app.add_typer(app_cmd_cloud, name="cloud", help="Cloud operations and management")
165171
# Top-level auth commands that map to cloud auth commands
166172
app.command(

src/mcp_agent/cli/core/constants.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323
ENV_API_KEY = "MCP_API_KEY"
2424
ENV_VERBOSE = "MCP_VERBOSE"
2525

26-
# API defaults
27-
DEFAULT_API_BASE_URL = "https://mcp-agent.com/api"
26+
# Base URL defaults
27+
DEFAULT_BASE_URL = "https://mcp-agent.com" # Base URL for web portal and API
28+
DEFAULT_API_BASE_URL = f"{DEFAULT_BASE_URL}/api" # API endpoint derived from base URL
2829

2930
# Secret types (string constants)
3031
SECRET_TYPE_DEVELOPER = "dev"

0 commit comments

Comments
 (0)