
Databases (read-only, switchable)
io.github.shibbirweb由 GitHub 帳號 shibbirweb 發布v1.1.0更新於 Oct 24, 2026
Read-only SQL, MongoDB, Redis and Elasticsearch access, switchable mid-conversation.
概覽
唯讀 MCP 伺服器,讓助理查詢 MySQL、PostgreSQL、SQLite、SQL Server、ClickHouse、MongoDB、Redis 與 Elasticsearch,並可在對話中切換資料庫。
- 可以做什麼
- 檢視結構:列出資料表、集合、索引與鍵,並描述欄位
- 執行唯讀查詢與搜尋:SQL SELECT、MongoDB 查詢、Redis 讀取、Elasticsearch 搜尋
- 透過提問在多個具名資料庫設定之間切換,或連線未事先設定的資料庫,無需重新啟動
- 可選擇將每次工具呼叫與查詢記錄到資料夾、檔案或 stderr,並用本機瀏覽器檢視器即時查看
- 適用情境
- 適合想用自然語言向助理詢問自身資料(計數、最新資料列、結構查詢),且要求助理無法修改任何內容的情境。對需要在單一用戶端跨多種資料庫做臨時查詢的分析人員與開發者很有用。
- 執行需求
- 透過 npx(需 Node.js 22.13 或更新版本)或 Docker 映像以 stdio 在本機執行。需要 DB_URL 中的連線網址,或 DB_PROFILES 中的具名連線,以及 DB_PASSWORD、MYSQL_PASSWORD 等憑證;需能連線到資料庫主機。選用記錄設定包括 DB_LOG、DB_LOG_FILE、DB_LOG_DIR 與 DB_LOG_PORT。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Databases (read-only, switchable),將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
mcp-db-read-only
[CI] [M8ven Score] [npm] [npm downloads] [Docker Hub] [Docker pulls] [License: MIT]
Let your AI assistant look at your databases without being able to change them.
Point it at MySQL, PostgreSQL, SQLite, SQL Server, ClickHouse, MongoDB, Redis or Elasticsearch, then just ask questions in plain words: "how many users signed up this week?", "what's in the orders table?", "which Redis keys hold sessions?". It can read anything you give it access to, and it cannot write, update or delete anything.
- Every popular database, one server. Switch between them in the middle of a conversation.
- Read-only, twice over. Every query is checked before it is sent, and the database itself is also told to refuse writes.
- No restart to switch. Change database, server or engine by asking.
- Optional logging, with a live page in your browser that shows every query as it happens.
Works with Claude Desktop, Claude Code, and any other MCP client.
Quick start
1. Have Node.js 22.13 or newer (node --version), or Docker.
2. Add the server to your client. For Claude Desktop, edit claude_desktop_config.json (Settings, Developer, Edit Config). For Claude Code, create .mcp.json in your project:
Replace the DB_URL with your own database. The examples below show one for every kind.
3. Restart the client once, and ask away:
"What tables are in my database?" "Show me the 5 newest orders." "How many customers are in each country?"
That's it. You never need to restart again to change database; just ask the assistant to switch.
Examples for each database
Each database has a URL format, then a real example to copy and change. Put the finished URL in DB_URL.
Replace each [PLACEHOLDER] with your own value:
No password? Leave out :[PASSWORD]. No user either? Leave out [USER]:[PASSWORD]@ entirely.
MySQL and MariaDB
Format (usual port 3306):
Example:
"List the tables in shop." · "Describe the orders table." · "What were last month's top 10 products by revenue?"
PostgreSQL
Format (usual port 5432). Add ?sslmode=require to use TLS:
Example:
"Which tables are in the reporting schema?" · "Show the foreign keys on invoices." · "Count signups per day this week."
SQLite
Format (three slashes, then the full path to the file):
Example:
The file is opened read-only.
"What tables does this file have?" · "Show 10 rows from notes."
SQL Server (and Azure SQL)
Format (usual port 1433). Add ?trustServerCertificate=true for a local server with a self-signed certificate:
Example:
"List the tables in Sales." · "Show the top 5 customers by order total." (SQL Server uses
TOP 5, notLIMIT; the assistant knows.)
ClickHouse
Format (usual port 8123, or 8443 with clickhouse+https):
Example:
"How many events per hour did we have yesterday?" · "What is the sorting key of the events table?"
MongoDB
Format (usual port 27017). Use mongodb+srv for MongoDB Atlas, with no port:
Example:
"What collections are in myapp?" · "What fields do documents in users have?" · "Find the 5 most recent orders over 100." · "Count users by country."
Redis (and Valkey, KeyDB)
Format (usual port 6379). [DB_NUMBER] is the database number, 0 if left out; rediss means TLS:
Example:
"Which keys start with session:?" · "What's inside user:42?" · "How long until cache:home expires?"
Elasticsearch and OpenSearch
Format (usual port 9200, no database). Add +https for TLS, or ?api_key=[API_KEY] instead of a user and password:
Example:
"What indices do we have?" · "Find error logs from the last hour." · "How many documents are in logs-2026.09?"
Detailed notes for every database, including how to create a read-only account, are in the Databases guide.
Using several databases
Give each one a name with DB_PROFILES, and switch by asking ("switch to legacy", "use the cache"):
You can also connect to a database you didn't list, mid-conversation: "connect to postgres://[email protected]/reports".
Password with special characters (@, /, #)? Give it separately instead of inside the URL: DB_PASSWORD next to DB_URL, or {"url": "...", "password": "..."} inside DB_PROFILES.
Running with Docker
Nothing to install but Docker:
Inside Docker, use host.docker.internal instead of localhost to reach a database on your own computer. For SQLite, mount the folder: add "-v", "/Users/me/data:/data:ro" and use sqlite:///data/app.db.
Watching what the assistant does
Turn on logging to keep a record of every query the assistant runs, and see them live in your browser.
1. Save logs to a folder by adding this to the server's env:
Each query is saved as its own file, one folder per day. Nothing is ever deleted automatically.
2. Open the viewer in a terminal, whenever you want to watch:
Then open http://127.0.0.1:4800/. You'll see every call: what was asked, the exact query sent, how long it took, and the result. It updates live, shows 20 per page (10, 20, 30 or 50 to choose from), and lets you filter and copy anything. Press Ctrl+C to close it.
The viewer has no password. Anyone who can reach that port on your network can read the log while it runs.
Passwords are never written to the logs. More in the Logging guide.
Is it really read-only?
Yes, in two independent ways, so a mistake in one is caught by the other:
- Before anything is sent, every query is checked. Only reads are allowed:
SELECTand friends for SQL, read commands for Redis, searches for Elasticsearch, and no$outor$mergefor MongoDB. - The database is told to refuse writes too, wherever it supports that: read-only sessions on MySQL, read-only transactions on PostgreSQL, a read-only file on SQLite, and so on.
The best protection is still a read-only database account. Then nothing can write through it, whatever happens. The Databases guide shows how to create one for each database.
Keep in mind that the assistant can read whatever the account can see, and what it reads becomes part of your conversation with the AI provider. Only connect accounts that can see data you are happy to share. See PRIVACY.md.
Settings
All optional. Set them in the server's env.
Coming from mcp-mysql-read-only? Its MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE and MYSQL_PROFILES settings still work as they are.
Full details: Configuration guide.
Troubleshooting
"Can't connect" from Docker to a database on my computer. Use host.docker.internal instead of localhost, and keep the --add-host line from the Docker example.
The server won't start with npx. Check node --version is 22.13 or newer.
SQL Server says the certificate isn't trusted. Add ?trustServerCertificate=true to the URL for a local or development server.
"No database selected". Your URL has no database name. Add one (.../myapp), or ask the assistant to list the databases and pick one.
My password has @ or # in it. Use DB_PASSWORD, or the {"url": ..., "password": ...} form in DB_PROFILES.
The viewer says the port is in use. Something else is using it. Close that, or pick another port with --port 4801.
More answers in the Troubleshooting guide.
Learn more
- Wiki: user guides for every feature, plus developer documentation
- CHANGELOG.md: what changed in each version
- PRIVACY.md: what the server sends where (nothing, except to your databases)
- Contributing: pull requests to
masterare welcome../scripts/test-in-docker.shruns the full test suite against every database in throwaway containers; see Testing. If you change this README, change README.dockerhub.md to match.
License
MIT © Md. Shibbir Ahmed
來源:README.md,提交 44fd5bc
工具
0版本歷史
2- v1.1.0最新Sep 25, 2026
- v0.1.0Sep 24, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分