Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions aws_mcp_proxy/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
from aws_mcp_proxy.utils import (
create_transport_with_sigv4,
determine_service_name,
normalize_endpoint_url,
)
from fastmcp.server.server import FastMCP
from typing import Any
Expand All @@ -57,11 +56,8 @@ async def setup_mcp_mode(mcp: FastMCP, args) -> None:
)
logger.info('Running in MCP mode')

# Normalize endpoint URL
endpoint_url = normalize_endpoint_url(args.endpoint)

# Create transport with SigV4 authentication
transport = create_transport_with_sigv4(endpoint_url, service, profile)
transport = create_transport_with_sigv4(args.endpoint, service, profile)

# Create proxy with the transport
proxy = FastMCP.as_proxy(transport)
Expand Down
16 changes: 0 additions & 16 deletions aws_mcp_proxy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,6 @@ def client_factory(
)


def normalize_endpoint_url(endpoint: str, path: str = '/mcp') -> str:
"""Normalize endpoint URL by ensuring it has the correct path.

Args:
endpoint: The base endpoint URL
path: The path to append (defaults to '/mcp')

Returns:
Normalized endpoint URL
"""
endpoint_url = endpoint.rstrip('/')
if not endpoint_url.endswith(path):
endpoint_url += path
return endpoint_url


def determine_service_name(endpoint: str, service: Optional[str] = None) -> str:
"""Validate and determine the service name.

Expand Down
35 changes: 0 additions & 35 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from aws_mcp_proxy.utils import (
create_transport_with_sigv4,
determine_service_name,
normalize_endpoint_url,
)
from fastmcp.client.transports import StreamableHttpTransport
from unittest.mock import MagicMock, patch
Expand Down Expand Up @@ -85,40 +84,6 @@ def test_create_transport_with_sigv4_no_profile(self, mock_create_sigv4_client):
assert result is not None


class TestNormalizeEndpointUrl:
"""Test cases for normalize_endpoint_url function (lines 151-153)."""

def test_normalize_endpoint_url_default_path(self):
"""Test normalizing endpoint URL with default /mcp path."""
endpoint = 'https://eks-mcp.us-west-2.api.aws'
result = normalize_endpoint_url(endpoint)
assert result == 'https://eks-mcp.us-west-2.api.aws/mcp'

def test_normalize_endpoint_url_custom_path(self):
"""Test normalizing endpoint URL with custom path."""
endpoint = 'https://eks-mcp.us-west-2.api.aws'
result = normalize_endpoint_url(endpoint, '/api/v1')
assert result == 'https://eks-mcp.us-west-2.api.aws/api/v1'

def test_normalize_endpoint_url_trailing_slash(self):
"""Test normalizing endpoint URL that already has trailing slash."""
endpoint = 'https://eks-mcp.us-west-2.api.aws/'
result = normalize_endpoint_url(endpoint)
assert result == 'https://eks-mcp.us-west-2.api.aws/mcp'

def test_normalize_endpoint_url_already_has_path(self):
"""Test normalizing endpoint URL that already has the path."""
endpoint = 'https://eks-mcp.us-west-2.api.aws/mcp'
result = normalize_endpoint_url(endpoint)
assert result == 'https://eks-mcp.us-west-2.api.aws/mcp'

def test_normalize_endpoint_url_different_existing_path(self):
"""Test normalizing endpoint URL that has a different existing path."""
endpoint = 'https://eks-mcp.us-west-2.api.aws/api'
result = normalize_endpoint_url(endpoint)
assert result == 'https://eks-mcp.us-west-2.api.aws/api/mcp'


class TestValidateRequiredArgs:
"""Test cases for validate_service_name function."""

Expand Down