mcp-database
Provides read-only access to MariaDB databases, allowing listing tables, describing table structures, and running SELECT/SHOW/DESCRIBE/EXPLAIN/WITH queries with safety measures such as automatic LIMIT and query timeout.
Provides read-only access to MySQL databases, allowing listing tables, describing table structures, and running SELECT/SHOW/DESCRIBE/EXPLAIN/WITH queries with safety measures such as automatic LIMIT and query timeout.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-database show me the structure of the orders table"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mcp-database
MCP server read-only untuk MySQL / MariaDB. Memungkinkan Claude melakukan pengecekan data lewat query SQL — tanpa bisa mengubah/menghapus data.
Tools yang disediakan
Tool | Fungsi |
| Menampilkan daftar semua tabel di database |
| Menampilkan struktur kolom sebuah tabel |
| Menjalankan SELECT/SHOW/DESCRIBE/EXPLAIN/WITH (read-only) |
Pengaman (read-only)
Hanya statement baca yang diterima.
INSERT/UPDATE/DELETE/DROP/ALTER/CREATE/...ditolak otomatis.Multi-statement (dipisah
;) ditolak.Komentar SQL (
--,#,/* */) dibersihkan sebelum divalidasi.LIMITotomatis ditambahkan (default 1000 baris) bila query tidak punya.Query punya timeout (default 15 detik).
Sangat disarankan: tetap pakai user MySQL yang hanya punya hak
SELECT, sebagai lapisan keamanan kedua di sisi database.CREATE USER 'readonly_user'@'%' IDENTIFIED BY 'password_kuat'; GRANT SELECT ON nama_database.* TO 'readonly_user'@'%'; FLUSH PRIVILEGES;
Setup
npm install
cp .env.example .env # lalu isi kredensial database
npm run buildIsi .env:
DB_HOST=localhost
DB_PORT=3306
DB_USER=readonly_user
DB_PASSWORD=...
DB_NAME=nama_database
MAX_ROWS=1000
QUERY_TIMEOUT_MS=15000Menghubungkan ke Claude Desktop
Edit file konfigurasi:
Windows:
%APPDATA%\Claude\claude_desktop_config.jsonmacOS:
~/Library/Application Support/Claude/claude_desktop_config.json
Kredensial cukup ditaruh di file .env (server otomatis memuatnya dari folder
proyek). Config-nya jadi sederhana:
{
"mcpServers": {
"database": {
"command": "node",
"args": ["c:\\project\\mcp-database\\dist\\index.js"]
}
}
}⚠️ JANGAN menambahkan blok
envdengan nilai placeholder (localhost,nama_database, dst). Nilai di blokenvakan menimpa.envAnda dan menyebabkan koneksi gagal (ECONNREFUSED). Isi.envsaja.Restart total Claude Desktop (Quit dari tray, lalu buka lagi) setiap kali mengubah config atau melakukan rebuild — bukan sekadar tutup window.
Menghubungkan ke Claude Code (CLI)
claude mcp add database -- node c:\project\mcp-database\dist\index.js(pastikan .env sudah terisi, atau tambahkan --env DB_HOST=... dst.)
Contoh penggunaan di Claude
"Cek ada berapa pengguna yang statusnya aktif di tabel pengguna"
Claude akan memanggil
list_tables→describe_table→run_querydenganSELECT COUNT(*) FROM pengguna WHERE status = 'aktif'.
Pengembangan
npm run dev # tsc --watchAvailable Tools
3 toolsdescribe_tableA
Tampilkan struktur (kolom, tipe data, nullable, key) dari sebuah tabel. Gunakan untuk memahami skema sebelum menulis SELECT.
Inputs: table (required).
list_tablesA
Tampilkan daftar semua tabel di database. Gunakan ini lebih dulu untuk tahu tabel apa saja yang tersedia sebelum membuat query.
Inputs: no named parameters.
run_queryA
Jalankan query SQL read-only (SELECT/SHOW/DESCRIBE/EXPLAIN/WITH) untuk pengecekan data. Perintah tulis (INSERT/UPDATE/DELETE/DROP/dll) akan ditolak. Hasil dibatasi maksimal 1000 baris.
Inputs: sql (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
Each tool has a clear, distinct purpose: listing tables, describing table schema, and running custom queries. There is no overlap or ambiguity.
All tool names follow a consistent verb_noun pattern in snake_case (list_tables, describe_table, run_query), making them predictable.
Three tools is minimal but appropriate for a read-only database server, covering the essential operations. Slightly more could be added, but not necessary.
The set covers the core read-only operations: enumeration, schema inspection, and arbitrary queries. Minor gaps like listing views or indexes exist, but the surface is sufficient for most exploration tasks.
Related MCP Connectors
Read-only MCP server for The Quiet Protocol's engines, benchmarks, proof, and business data.
Read-only MCP server for ClassQuill, a tutoring-business-management platform.
Text-to-SQL MCP server: read-only queries on PostgreSQL, MySQL and SQL Server with your real schema
Read-only MCP server for interior design studios: projects, overviews, weekly activity. No writes.