Skip to content

Commit 36dd241

Browse files
authored
fix: set default log level to ERROR (#73)
1 parent a800c01 commit 36dd241

File tree

4 files changed

+23
-9
lines changed

4 files changed

+23
-9
lines changed

mcp_proxy_for_aws/cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ def parse_args():
7373
parser.add_argument(
7474
'--log-level',
7575
choices=['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'],
76-
default='INFO',
77-
help='Set the logging level (default: INFO)',
76+
default='ERROR',
77+
help='Set the logging level (default: ERROR)',
7878
)
7979

8080
parser.add_argument(

mcp_proxy_for_aws/sigv4_helper.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,27 +84,41 @@ async def _handle_error_response(response: httpx.Response) -> None:
8484
No raises. let the mcp http client handle the errors.
8585
"""
8686
if response.is_error:
87+
# warning only because the SDK logs error
88+
log_level = logging.WARNING
89+
if (
90+
# The server MAY respond 405 to GET (SSE) and DELETE (session).
91+
response.status_code == 405 and response.request.method in ('GET', 'DELETE')
92+
) or (
93+
# The server MAY terminate the session at any time, after which it MUST
94+
# respond to requests containing that session ID with HTTP 404 Not Found.
95+
response.status_code == 404 and response.request.method == 'POST'
96+
):
97+
log_level = logging.DEBUG
98+
8799
try:
88100
# read the content and settle the response content. required to get body (.json(), .text)
89101
await response.aread()
90102
except Exception as e:
91-
logger.error('Failed to read response: %s', e)
92-
# do nothing and let the client handle the error
103+
logger.debug('Failed to read response: %s', e)
104+
# do nothing and let the client and SDK handle the error
93105
return
94106

95107
# Try to extract error details with fallbacks
96108
try:
97109
# Try to parse JSON error details
98110
error_details = response.json()
99-
logger.error('HTTP %d Error Details: %s', response.status_code, error_details)
111+
logger.log(log_level, 'HTTP %d Error Details: %s', response.status_code, error_details)
100112
except Exception:
101113
# If JSON parsing fails, use response text or status code
102114
try:
103115
response_text = response.text
104-
logger.error('HTTP %d Error: %s', response.status_code, response_text)
116+
logger.log(log_level, 'HTTP %d Error: %s', response.status_code, response_text)
105117
except Exception:
106118
# Fallback to just status code and URL
107-
logger.error('HTTP %d Error for url %s', response.status_code, response.url)
119+
logger.log(
120+
log_level, 'HTTP %d Error for url %s', response.status_code, response.url
121+
)
108122

109123

110124
def create_aws_session(profile: Optional[str] = None) -> boto3.Session:

tests/unit/test_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def test_parse_args_minimal(self):
3232
assert args.profile is None
3333
assert args.region is None
3434
assert args.read_only is False
35-
assert args.log_level == 'INFO'
35+
assert args.log_level == 'ERROR'
3636
assert args.retries == 0
3737
assert args.timeout == 180.0
3838
assert args.connect_timeout == 60.0

tests/unit/test_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def test_parse_args_default(self):
194194
assert args.region is None
195195
assert args.profile is None
196196
assert args.read_only is False
197-
assert args.log_level == 'INFO'
197+
assert args.log_level == 'ERROR'
198198
assert args.retries == 0
199199

200200
@patch(

0 commit comments

Comments
 (0)