mcp-database-server
A read-only SQLite MCP server for inspecting the shop database and running single SQL queries.
List tables with
list_tables, intended to be called first.Describe one table’s columns and types with
describe_table(table).Run one SQL statement with
run_query(sql), returning at most 50 rows or the database error as text.Write operations fail because the SQLite connection is opened in read-only mode.
Provides read-only access to a SQLite database, with tools to list tables, describe table columns and types, and run a single SQL query returning at most 50 rows or the database error.
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-server which customers placed their last order before October 1, 2026?"
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 server for your database (Python, read-only)
A minimal Model Context Protocol server that lets Claude (or any MCP host) query a SQLite
database through three tools, list_tables, describe_table and run_query, over a connection that cannot write.
It's the code from the video Build an MCP Server for Your Database in Python (Read-Only): https://youtu.be/ox2xk1gXLeM
Claude Desktop --(MCP over stdio)--> db_server.py --(sqlite3, mode=ro)--> shop.dbRequirements
Python 3.10 or newer
Claude Desktop, or any other MCP host
Related MCP server: MCP SQLite Server (Read-Only)
Run it
uv sync
uv run python make_db.py # creates shop.db: 5 made-up customers, 8 orders
uv run python check_client.py # lists the tools, then calls each oneOr try it in the MCP Inspector:
uv run mcp dev db_server.pyConnect it to Claude Desktop
Find your full paths:
which uv(on Windowswhere uv), andpwdin this folder.Open Claude Desktop's config file (Settings, Developer, Edit Config) and add the
shop-dbentry fromclaude_desktop_config.example.json, with the full path to this folder (and the full path touvif Claude can't find it).Restart Claude Desktop.
shop-dbappears in the list of connectors. Ask: "Which customers placed their last order before October 1, 2026?"
The three tools
Tool | Does | Returns |
| lists the tables (its description says "Call this first") | table names, comma separated |
| columns and their types |
|
| runs one SQL statement | at most 50 rows, or the database's error as text |
Why read-only matters
run_query runs whatever statement the model writes. The one line that makes it safe is the connection:
sqlite3.connect(f"{DB.as_uri()}?mode=ro", uri=True)With mode=ro, SQLite itself refuses every write: DELETE FROM orders comes back as
"The query failed: attempt to write a readonly database". Telling the model "never delete" is only a request; filtering the
word DELETE misses DROP and UPDATE. The lock is in the database connection, not in the prompt.
bug_demo_server.py is the same server with a normal, writable connection, for showing the risk:
uv run python check_bug.py deletes all 8 orders (and answers "No rows."). Run make_db.py again to restore them.
Never point the bug demo at real data.
What it doesn't do
Read-only is the first step, not the whole job:
There is no login, and the model sees every table in the file. Point it at a copy, or at a database that holds only what the model may see.
On Postgres or MySQL, connect as a database user that can only read, so the database enforces the rule.
A large query can still be slow;
run_queryreturns at most 50 rows but doesn't limit the work.
License
MIT
Available Tools
3 toolsdescribe_tableA
Show the columns of one table, with their types.
Args: table: Table name, exactly as list_tables returned it
Inputs: table (required). Returns: result
list_tablesA
List the tables in the shop database. Call this first.
Inputs: no named parameters. Returns: result
run_queryA
Run one SQL statement on the shop database (SQLite) and return the rows.
The database is opened read-only: statements that write will fail.
Args: sql: One SQL statement
Inputs: sql (required). Returns: result
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 targets a distinct step in the workflow: discovery (list_tables), schema inspection (describe_table), and data retrieval (run_query). There is no meaningful overlap, and describe_table's argument explicitly references list_tables' output.
All three tools use a consistent snake_case verb_noun pattern (list_tables, describe_table, run_query). The naming is predictable and self-explanatory.
Three tools is minimal but well-matched to a read-only SQL exploration surface; each earns its place. It sits at the low end, though run_query alone could handle much of the work, making the set feel slightly thin.
The read-only discovery-plus-query lifecycle is fully covered, and run_query is a general escape hatch for anything else. Write operations are intentionally excluded (documented as read-only), so this is a deliberate scope limit rather than a gap, though no schema-dump or pagination aid exists.
Maintenance
Related MCP Connectors
Explore, query, and inspect SQLite databases with ease. List tables, preview results, and view det…
PostgreSQL, MySQL, and SQL Server in one session. 26 read-only MCP tools for AI agents.
Query 40 databases from Claude, ChatGPT, or Cursor — on any device. Read-only, encrypted, audited.
Query, explore, and manage your databases through natural conversation.
Related MCP Servers
- FlicenseNot gradedqualityCmaintenanceExposes any SQLite database as read-only MCP tools for AI assistants, enabling listing tables, describing schemas, and running SELECT queries with filtering, ordering, and pagination.-
- FlicenseAqualityCmaintenanceEnables AI agents to safely inspect and query a SQLite database through read-only MCP tools for listing tables, describing schemas, and running paginated SELECT queries.3-
- AlicenseNot gradedqualityCmaintenanceEnables Claude to safely explore and query a SQLite database through natural language, including listing tables, inspecting schemas, and running read-only SELECT queries.711 npmMIT
- AlicenseNot gradedqualityBmaintenanceEnables Claude and other MCP clients to map a SQLite database's schema and run read-only SQL queries against it, with writes blocked at the SQLite level through multiple enforcement layers. Results come back as context-friendly Markdown tables with row caps and a query timeout.2MIT