run_lsd
Execute LSD SQL queries to access and analyze web data through a database-like structure, enabling interaction with real-world information using stored credentials.
Instructions
Runs LSD SQL using user credentials in .env
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| lsd_sql_code | Yes |
Implementation Reference
- app.py:42-50 (handler)The handler function for the 'run_lsd' tool. It is registered via the @mcp.tool() decorator. Connects to the LSD database using credentials from environment variables, executes the provided LSD SQL code, fetches the results, and returns them as a list of lists of strings.@mcp.tool() def run_lsd(lsd_sql_code: str) -> List[List[str]]: """Runs LSD SQL using user credentials in .env""" conn = establish_connection() with conn.cursor() as curs: curs.execute(lsd_sql_code) rows = curs.fetchall() return [list(r) for r in rows]
- app.py:29-40 (helper)Helper function used by run_lsd to establish a connection to the PostgreSQL database at lsd.so using environment variables for authentication. Retries on failure.def establish_connection(): try: return psycopg2.connect( host="lsd.so", database=os.environ.get("LSD_USER"), user=os.environ.get("LSD_USER"), password=os.environ.get("LSD_API_KEY"), port="5432", ) except Exception as e: sleep(1) return establish_connection()