run_lsd
Execute LSD SQL queries securely using user credentials to transform web data into a structured, queryable format. Simplifies real-world data interactions for Claude AI.
Instructions
Runs LSD SQL using user credentials in .env
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| lsd_sql_code | Yes |
Input Schema (JSON Schema)
{
"properties": {
"lsd_sql_code": {
"title": "Lsd Sql Code",
"type": "string"
}
},
"required": [
"lsd_sql_code"
],
"title": "run_lsdArguments",
"type": "object"
}
Implementation Reference
- app.py:42-50 (handler)The core handler function for the 'run_lsd' tool. It is registered using the @mcp.tool() decorator, which also implies schema from type hints (str input to List[List[str]] output). Connects to LSD database and executes the SQL code.@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 recursively establish a PostgreSQL connection to the LSD server using .env credentials.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()