Problem
All Lambda MCP server functions use generic exception handling that returns plain error strings without context:
except Exception as e:
return {"error": str(e)}
This makes debugging difficult in production — no stack traces, no request context, and no error classification in CloudWatch Logs.
Affected files:
src/lambda/mcp_servers/cost_explorer/lambda_function.py
src/lambda/mcp_servers/athena/lambda_function.py
src/lambda/mcp_servers/cur_analyst/lambda_function.py
Expected Behavior
Each Lambda handler should log structured errors with:
- Handler/tool name that failed
- Input parameters (sanitized)
- Full stack trace via
exc_info=True
- Use Python's
logging module configured at module level
Example
import logging
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
def some_handler(event):
tool_name = event.get("tool_name", "unknown")
try:
# ... handler logic
except Exception as e:
logger.error("Error in handler %s", tool_name, exc_info=True)
return {"error": str(e)}
Scope
- Add
logging import and logger setup to each affected Lambda
- Wrap existing
except blocks with structured logging
- Do not change the return format — keep
{"error": str(e)} for backward compatibility
Problem
All Lambda MCP server functions use generic exception handling that returns plain error strings without context:
This makes debugging difficult in production — no stack traces, no request context, and no error classification in CloudWatch Logs.
Affected files:
src/lambda/mcp_servers/cost_explorer/lambda_function.pysrc/lambda/mcp_servers/athena/lambda_function.pysrc/lambda/mcp_servers/cur_analyst/lambda_function.pyExpected Behavior
Each Lambda handler should log structured errors with:
exc_info=Trueloggingmodule configured at module levelExample
Scope
loggingimport and logger setup to each affected Lambdaexceptblocks with structured logging{"error": str(e)}for backward compatibility