{
"event": "PreToolUse",
"tool_name": "Read",
"tool_input": {
"file_path": "\/var\/www\/mcp-servers\/mcp_code\/db.py"
}
}
{
"tool_response": {
"type": "text",
"file": {
"filePath": "\/var\/www\/mcp-servers\/mcp_code\/db.py",
"content": "\"\"\"Einfache DB-Connection für mcp-code.\"\"\"\nimport mysql.connector\nfrom config import Config\n\n\ndef get_connection():\n \"\"\"Erstellt eine DB-Connection.\"\"\"\n return mysql.connector.connect(\n host=Config.DB_HOST,\n user=Config.DB_USER,\n password=Config.DB_PASSWORD,\n database=Config.DB_NAME,\n )\n\n\ndef execute_query(query: str, params: tuple = None, max_rows: int = 100) -> list:\n \"\"\"Führt Query aus und gibt Ergebnisse zurück.\"\"\"\n conn = get_connection()\n cursor = conn.cursor(dictionary=True, buffered=True)\n cursor.execute(query, params or ())\n rows = cursor.fetchmany(max_rows)\n cursor.close()\n conn.close()\n return rows\n\n\ndef execute_single(query: str, params: tuple = None) -> dict | None:\n \"\"\"Führt Query aus und gibt einzelnes Ergebnis zurück.\"\"\"\n rows = execute_query(query, params, max_rows=1)\n return rows[0] if rows else None\n",
"numLines": 31,
"startLine": 1,
"totalLines": 31
}
}
}