Skip to content

Commit 49e91bc

Browse files
author
LittleCoinCoin
committed
fix(cli): allow --http-url as standalone option for Gemini
Add --http-url to mutually exclusive group with --command and --url, allowing Gemini users to create servers using only --http-url for HTTP transport without requiring --url or --command. Key changes: - Add --http-url to server_type_group mutually exclusive group - Update validation to accept http_url as valid transport option - Update transport switching logic to handle httpUrl field - Update error messages to mention --http-url option This completes Issue 3 implementation by allowing Gemini's HTTP transport to be configured directly via CLI without requiring --url first. Related: Issue 3 - Gemini dual-transport support
1 parent f715df1 commit 49e91bc

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

hatch/cli_hatch.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -646,11 +646,11 @@ def handle_mcp_configure(host: str, server_name: str, command: str, args: list,
646646

647647
# Validate argument dependencies
648648
if command and headers:
649-
print("Error: --headers can only be used with --url (remote servers), not with --command (local servers)")
649+
print("Error: --headers can only be used with --url or --http-url (remote servers), not with --command (local servers)")
650650
return 1
651651

652-
if url and args:
653-
print("Error: --args can only be used with --command (local servers), not with --url (remote servers)")
652+
if (url or http_url) and args:
653+
print("Error: --args can only be used with --command (local servers), not with --url or --http-url (remote servers)")
654654
return 1
655655

656656
# NOTE: We do NOT validate host-specific arguments here.
@@ -662,11 +662,11 @@ def handle_mcp_configure(host: str, server_name: str, command: str, args: list,
662662
existing_config = manager.get_server_config(host, server_name)
663663
is_update = existing_config is not None
664664

665-
# Conditional validation: Create requires command OR url, update does not
665+
# Conditional validation: Create requires command OR url OR http_url, update does not
666666
if not is_update:
667-
# Create operation: require command or url
668-
if not command and not url:
669-
print(f"Error: When creating a new server, you must provide either --command (for local servers) or --url (for remote servers)")
667+
# Create operation: require command, url, or http_url
668+
if not command and not url and not http_url:
669+
print(f"Error: When creating a new server, you must provide either --command (for local servers), --url (for SSE remote servers), or --http-url (for HTTP remote servers, Gemini only)")
670670
return 1
671671

672672
# Parse environment variables, headers, and inputs
@@ -728,16 +728,17 @@ def handle_mcp_configure(host: str, server_name: str, command: str, args: list,
728728
# Merge with existing configuration
729729
existing_data = existing_config.model_dump(exclude_unset=True, exclude={'name'})
730730

731-
# Handle command/URL switching behavior
732-
# If switching from command to URL: clear command-based fields
733-
if url is not None and existing_config.command is not None:
731+
# Handle command/URL/httpUrl switching behavior
732+
# If switching from command to URL or httpUrl: clear command-based fields
733+
if (url is not None or http_url is not None) and existing_config.command is not None:
734734
existing_data.pop('command', None)
735735
existing_data.pop('args', None)
736736
existing_data.pop('type', None) # Clear type field when switching transports (Issue 1)
737737

738-
# If switching from URL to command: clear URL-based fields
739-
if command is not None and existing_config.url is not None:
738+
# If switching from URL/httpUrl to command: clear URL-based fields
739+
if command is not None and (existing_config.url is not None or getattr(existing_config, 'httpUrl', None) is not None):
740740
existing_data.pop('url', None)
741+
existing_data.pop('httpUrl', None)
741742
existing_data.pop('headers', None)
742743
existing_data.pop('type', None) # Clear type field when switching transports (Issue 1)
743744

@@ -1262,7 +1263,8 @@ def main():
12621263
# Create mutually exclusive group for server type
12631264
server_type_group = mcp_configure_parser.add_mutually_exclusive_group(required=True)
12641265
server_type_group.add_argument("--command", dest="server_command", help="Command to execute the MCP server (for local servers)")
1265-
server_type_group.add_argument("--url", help="Server URL for remote MCP servers")
1266+
server_type_group.add_argument("--url", help="Server URL for remote MCP servers (SSE transport)")
1267+
server_type_group.add_argument("--http-url", help="HTTP streaming endpoint URL (Gemini only)")
12661268

12671269
mcp_configure_parser.add_argument("--args", nargs="*", help="Arguments for the MCP server command (only with --command)")
12681270
mcp_configure_parser.add_argument("--env-var", action="append", help="Environment variables (format: KEY=VALUE)")
@@ -1272,7 +1274,6 @@ def main():
12721274
mcp_configure_parser.add_argument("--timeout", type=int, help="Request timeout in milliseconds (Gemini)")
12731275
mcp_configure_parser.add_argument("--trust", action="store_true", help="Bypass tool call confirmations (Gemini)")
12741276
mcp_configure_parser.add_argument("--cwd", help="Working directory for stdio transport (Gemini)")
1275-
mcp_configure_parser.add_argument("--http-url", help="HTTP streaming endpoint URL (Gemini)")
12761277
mcp_configure_parser.add_argument("--include-tools", nargs="*", help="Tool allowlist - only these tools will be available (Gemini)")
12771278
mcp_configure_parser.add_argument("--exclude-tools", nargs="*", help="Tool blocklist - these tools will be excluded (Gemini)")
12781279

0 commit comments

Comments
 (0)