redshift_connection_status
Check the connection status of Amazon Redshift databases to verify connectivity and troubleshoot issues.
Instructions
Check the Redshift connection status.
Returns:
Connection status information
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- redshift_mcp_server.py:133-154 (handler)The handler function for the 'redshift_connection_status' tool. It is registered via @mcp.tool() decorator and checks the Redshift connection status, returning JSON with status details or error.@mcp.tool() def redshift_connection_status() -> str: """ Check the Redshift connection status. Returns: Connection status information """ try: with get_connection() as conn: return json.dumps({ "status": "connected", "host": REDSHIFT_HOST, "port": REDSHIFT_PORT, "database": REDSHIFT_DATABASE }, indent=2) except Exception as e: return json.dumps({ "status": "disconnected", "error": str(e) }, indent=2)
- redshift_mcp_server.py:32-56 (helper)Supporting helper function used by the tool to establish the database connection.def get_connection(): """Create a connection to Redshift or local Postgres.""" try: # If host is localhost and port is 5432, assume local Postgres for testing if REDSHIFT_HOST == "localhost" and REDSHIFT_PORT == 5432: import psycopg2 return psycopg2.connect( host=REDSHIFT_HOST, port=REDSHIFT_PORT, database=REDSHIFT_DATABASE, user=REDSHIFT_USER, password=REDSHIFT_PASSWORD ) else: return redshift_connector.connect( host=REDSHIFT_HOST, port=REDSHIFT_PORT, database=REDSHIFT_DATABASE, user=REDSHIFT_USER, password=REDSHIFT_PASSWORD ) except Exception as e: logger.error(f"Connection error: {e}") raise