{
"tool_response": [
{
"type": "text",
"text": "{\n \"success\": true,\n \"doc\": {\n \"id\": 46,\n \"parent_id\": 36,\n \"slug\": \"mcp-db-cheatsheet\",\n \"path\": \"\/mcp\/mcp-db\/mcp-db-cheatsheet\",\n \"title\": \"Cheat-Sheet\",\n \"description\": \"Schnellreferenz für den Umstieg von direkten mysql-Befehlen auf MCP-DB Tools.\",\n \"content\": \"<nav class=\\\"breadcrumb\\\">\\n <a href=\\\"\/docs\\\">Dokumentation<\/a> » <a href=\\\"\/docs\/mcp\/mcp-db\\\">MCP-DB<\/a> » Cheat-Sheet\\n<\/nav>\\n\\n<h1>MCP-DB Cheat-Sheet<\/h1>\\n<p>Schnellreferenz für den Umstieg von direkten mysql-Befehlen auf MCP-DB Tools.<\/p>\\n\\n<div class=\\\"alert alert-danger\\\">\\n<h2>WICHTIG: mysql\/mariadb-Befehle sind blockiert!<\/h2>\\n<p>Direkte Datenbankzugriffe mit mysql oder mariadb werden durch einen PreToolUse Hook <strong>automatisch blockiert<\/strong>.<\/p>\\n<pre><code># Diese Befehle werden BLOCKIERT:\\nmysql -u root -pPassword -e \\\"SELECT 1\\\"\\nmariadb -u user -pSecret\\nmysqldump ki_protokoll > backup.sql\\n\\n# Stattdessen MCP-DB verwenden:\\nmcp__mcp-db__db_select(\\\"SELECT * FROM mcp_log LIMIT 5\\\")\\nmcp__mcp-db__db_schema()\\nmcp__mcp-db__db_stats()<\/code><\/pre>\\n<\/div>\\n\\n<h2>Grundprinzip<\/h2>\\n<table>\\n <tr>\\n <th>Alt (BLOCKIERT)<\/th>\\n <th>Neu (MCP-DB)<\/th>\\n <\/tr>\\n <tr>\\n <td><code>mysql -u user -p db -e \\\"...\\\"<\/code><\/td>\\n <td><code>db_select(\\\"...\\\", database=\\\"db\\\")<\/code><\/td>\\n <\/tr>\\n<\/table>\\n\\n<h2>MCP-DB Tools Übersicht<\/h2>\\n\\n<table>\\n <tr>\\n <th>Tool<\/th>\\n <th>Verwendung<\/th>\\n <th>Parameter<\/th>\\n <\/tr>\\n <tr>\\n <td><strong>db_select<\/strong><\/td>\\n <td>SELECT Queries ausführen<\/td>\\n <td>query, database (Optional), max_rows (Optional), params (Optional)<\/td>\\n <\/tr>\\n <tr>\\n <td><strong>db_schema<\/strong><\/td>\\n <td>Tabellen einer DB anzeigen<\/td>\\n <td>database (Optional, Default: ki_protokoll)<\/td>\\n <\/tr>\\n <tr>\\n <td><strong>db_stats<\/strong><\/td>\\n <td>Letzte Queries aus mcp_log<\/td>\\n <td>limit (Optional, Default: 50, Max: 100)<\/td>\\n <\/tr>\\n<\/table>\\n\\n<h2>Basis-Queries<\/h2>\\n\\n<h3>Einfache SELECT Query<\/h3>\\n<table>\\n <tr>\\n <th>Alt (BLOCKIERT)<\/th>\\n <th>Neu (MCP-DB)<\/th>\\n <\/tr>\\n <tr>\\n <td><pre><code>mysql -u user -p db \\\\\\n -e \\\"SELECT * FROM table LIMIT 5\\\"<\/code><\/pre><\/td>\\n <td><pre><code>db_select(\\\"SELECT * FROM table LIMIT 5\\\",\\n database=\\\"db\\\")<\/code><\/pre><\/td>\\n <\/tr>\\n<\/table>\\n\\n<h3>Query mit WHERE Clause<\/h3>\\n<table>\\n <tr>\\n <th>Alt (BLOCKIERT)<\/th>\\n <th>Neu (MCP-DB)<\/th>\\n <\/tr>\\n <tr>\\n <td><pre><code>mysql -u user -p ki_protokoll \\\\\\n -e \\\"SELECT * FROM mcp_log\\n WHERE status = 'success'\\n LIMIT 10\\\"<\/code><\/pre><\/td>\\n <td><pre><code>db_select(\\n \\\"SELECT * FROM mcp_log\\n WHERE status = 'success'\\n LIMIT 10\\\",\\n database=\\\"ki_protokoll\\\"\\n)<\/code><\/pre><\/td>\\n <\/tr>\\n<\/table>\\n\\n<h3>Aggregation (COUNT, AVG, etc.)<\/h3>\\n<table>\\n <tr>\\n <th>Alt (BLOCKIERT)<\/th>\\n <th>Neu (MCP-DB)<\/th>\\n <\/tr>\\n <tr>\\n <td><pre><code>mysql -u user -p ki_protokoll \\\\\\n -e \\\"SELECT COUNT(*) as total,\\n AVG(duration_ms) as avg_ms\\n FROM protokoll\\\"<\/code><\/pre><\/td>\\n <td><pre><code>db_select(\\n \\\"SELECT COUNT(*) as total,\\n AVG(duration_ms) as avg_ms\\n FROM protokoll\\\",\\n database=\\\"ki_protokoll\\\"\\n)<\/code><\/pre><\/td>\\n <\/tr>\\n<\/table>\\n\\n<h3>JOIN Query<\/h3>\\n<table>\\n <tr>\\n <th>Alt (BLOCKIERT)<\/th>\\n <th>Neu (MCP-DB)<\/th>\\n <\/tr>\\n <tr>\\n <td><pre><code>mysql -u user -p ki_system \\\\\\n -e \\\"SELECT d.title, c.chunk_text\\n FROM documents d\\n JOIN chunks c ON d.id = c.document_id\\n LIMIT 5\\\"<\/code><\/pre><\/td>\\n <td><pre><code>db_select(\\n \\\"SELECT d.title, c.chunk_text\\n FROM documents d\\n JOIN chunks c ON d.id = c.document_id\\n LIMIT 5\\\",\\n database=\\\"ki_system\\\"\\n)<\/code><\/pre><\/td>\\n <\/tr>\\n<\/table>\\n\\n<h2>Schema-Inspektion<\/h2>\\n\\n<h3>Tabellen anzeigen<\/h3>\\n<table>\\n <tr>\\n <th>Alt (BLOCKIERT)<\/th>\\n <th>Neu (MCP-DB)<\/th>\\n <\/tr>\\n <tr>\\n <td><pre><code>mysql -u user -p ki_system \\\\\\n -e \\\"SHOW TABLES\\\"<\/code><\/pre><\/td>\\n <td><pre><code>db_schema(database=\\\"ki_system\\\")<\/code><\/pre><\/td>\\n <\/tr>\\n<\/table>\\n\\n<h3>Tabellenstruktur anzeigen<\/h3>\\n<table>\\n <tr>\\n <th>Alt (BLOCKIERT)<\/th>\\n <th>Neu (MCP-DB)<\/th>\\n <\/tr>\\n <tr>\\n <td><pre><code>mysql -u user -p ki_system \\\\\\n -e \\\"DESCRIBE documents\\\"<\/code><\/pre><\/td>\\n <td><pre><code>db_schema(database=\\\"ki_system\\\")\\n# Gibt alle Tabellen mit Spalten zurück<\/code><\/pre><\/td>\\n <\/tr>\\n<\/table>\\n\\n<h2>Statistiken<\/h2>\\n\\n<h3>MCP-Log Statistiken<\/h3>\\n<table>\\n <tr>\\n <th>Alt (BLOCKIERT)<\/th>\\n <th>Neu (MCP-DB)<\/th>\\n <\/tr>\\n <tr>\\n <td><pre><code>mysql -u user -p ki_protokoll \\\\\\n -e \\\"SELECT * FROM mcp_log\\n ORDER BY timestamp DESC\\n LIMIT 10\\\"<\/code><\/pre><\/td>\\n <td><pre><code>db_stats(limit=10)<\/code><\/pre><\/td>\\n <\/tr>\\n<\/table>\\n\\n<h2>Häufige Anwendungsfälle<\/h2>\\n\\n<h3>File Backup History<\/h3>\\n<pre><code>db_select(\\n \\\"SELECT id, file_path, version, changed_at\\n FROM file_backup_history\\n ORDER BY id DESC LIMIT 10\\\",\\n database=\\\"ki_protokoll\\\"\\n)<\/code><\/pre>\\n\\n<h3>KI-Protokoll Analyse<\/h3>\\n<pre><code>db_select(\\n \\\"SELECT DATE(timestamp) as tag, COUNT(*) as anzahl\\n FROM protokoll\\n GROUP BY DATE(timestamp)\\n ORDER BY tag DESC\\\",\\n database=\\\"ki_protokoll\\\"\\n)<\/code><\/pre>\\n\\n<h3>MCP-Log Fehler<\/h3>\\n<pre><code>db_select(\\n \\\"SELECT * FROM mcp_log\\n WHERE status = 'error'\\n ORDER BY timestamp DESC\\n LIMIT 5\\\",\\n database=\\\"ki_protokoll\\\"\\n)<\/code><\/pre>\\n\\n<h3>Content Orders Status<\/h3>\\n<pre><code>db_select(\\n \\\"SELECT id, title, status\\n FROM content_orders\\n WHERE status = 'in_progress'\\\",\\n database=\\\"ki_system\\\"\\n)<\/code><\/pre>\\n\\n<h2>Datenbank-übergreifende Queries<\/h2>\\n\\n<h3>Standard-Datenbank (ki_protokoll)<\/h3>\\n<pre><code># database Parameter ist optional, Default: ki_protokoll\\ndb_select(\\\"SELECT * FROM mcp_log LIMIT 5\\\")\\n\\n# Explizit angeben (empfohlen)\\ndb_select(\\\"SELECT * FROM mcp_log LIMIT 5\\\", database=\\\"ki_protokoll\\\")<\/code><\/pre>\\n\\n<h3>Andere Datenbank (ki_system)<\/h3>\\n<pre><code># Muss explizit angegeben werden\\ndb_select(\\\"SELECT * FROM documents LIMIT 5\\\", database=\\\"ki_system\\\")<\/code><\/pre>\\n\\n<h2>Best Practices<\/h2>\\n\\n<h3>1. Immer LIMIT verwenden<\/h3>\\n<table>\\n <tr>\\n <th>Schlecht<\/th>\\n <th>Gut<\/th>\\n <\/tr>\\n <tr>\\n <td><pre><code>db_select(\\\"SELECT * FROM protokoll\\\")<\/code><\/pre><\/td>\\n <td><pre><code>db_select(\\\"SELECT * FROM protokoll LIMIT 100\\\")<\/code><\/pre><\/td>\\n <\/tr>\\n<\/table>\\n\\n<h3>2. Datenbank explizit angeben<\/h3>\\n<table>\\n <tr>\\n <th>Okay<\/th>\\n <th>Besser<\/th>\\n <\/tr>\\n <tr>\\n <td><pre><code>db_select(\\\"SELECT * FROM mcp_log LIMIT 5\\\")<\/code><\/pre><\/td>\\n <td><pre><code>db_select(\\n \\\"SELECT * FROM mcp_log LIMIT 5\\\",\\n database=\\\"ki_protokoll\\\"\\n)<\/code><\/pre><\/td>\\n <\/tr>\\n<\/table>\\n\\n<h3>3. Schema vor komplexen Queries prüfen<\/h3>\\n<pre><code># 1. Schema laden\\ndb_schema(database=\\\"ki_system\\\")\\n\\n# 2. Spalten identifizieren\\n# 3. Query schreiben\\ndb_select(\\\"SELECT id, title, created_at FROM documents LIMIT 5\\\", database=\\\"ki_system\\\")<\/code><\/pre>\\n\\n<h2>Sicherheitshinweise<\/h2>\\n\\n<ul>\\n <li><strong>mysql\/mariadb BLOCKIERT:<\/strong> Direkte Befehle werden durch Hook abgelehnt<\/li>\\n <li><strong>Nur SELECT:<\/strong> MCP-DB erlaubt ausschließlich lesende Zugriffe<\/li>\\n <li><strong>Keine INSERT\/UPDATE\/DELETE:<\/strong> Für Schreibzugriffe verwende Backend-Code<\/li>\\n <li><strong>Logging:<\/strong> Alle Queries werden in mcp_log protokolliert<\/li>\\n <li><strong>Keine Passwörter:<\/strong> MCP-DB authentifiziert automatisch aus .env<\/li>\\n<\/ul>\\n\\n<h2>Fehlerbehandlung<\/h2>\\n\\n<h3>Hook blockiert Befehl<\/h3>\\n<pre><code># Fehlermeldung:\\n# \\\"BLOCKIERT: Direkter Datenbankzugriff ist verboten!\\\"\\n\\n# Lösung: MCP-DB Tools verwenden\\ndb_select(\\\"SELECT * FROM mcp_log LIMIT 5\\\")<\/code><\/pre>\\n\\n<h3>Query Fehler<\/h3>\\n<pre><code># Fehler: Tabelle existiert nicht\\ndb_select(\\\"SELECT * FROM nonexistent_table\\\")\\n# Lösung: Schema prüfen\\ndb_schema()\\n\\n# Fehler: Spalte existiert nicht\\ndb_select(\\\"SELECT nonexistent_column FROM mcp_log\\\")\\n# Lösung: Schema für Tabelle prüfen\\ndb_schema()<\/code><\/pre>\\n\\n<h2>Verwandte Kapitel<\/h2>\\n<ul>\\n <li><a href=\\\"\/docs\/mcp\/mcp-db\\\">MCP-DB Übersicht<\/a> - Hauptseite<\/li>\\n <li><a href=\\\"\/docs\/mcp\/mcp-db\/mcp-db-tools\\\">Tools<\/a> - Detaillierte Tool-Beschreibung<\/li>\\n <li><a href=\\\"\/docs\/mcp\/mcp-db\/mcp-db-security\\\">Sicherheit<\/a> - Blocking-Hook Details<\/li>\\n <li><a href=\\\"\/docs\/mcp\/mcp-db\/mcp-db-config\\\">Konfiguration<\/a> - Hook-Konfiguration<\/li>\\n<\/ul>\",\n \"status\": \"published\",\n \"sort_order\": 10,\n \"depth\": 2,\n \"created_at\": \"2025-12-20T11:13:58\",\n \"updated_at\": \"2025-12-20T18:23:53\"\n }\n}"
}
]
}