sql-explorer
sql-explorer
MCP-сервер, который позволяет ИИ-ассистенту отвечать на вопросы о базае данных SQLite обычным языком — не им he может испортить либо прочитать то, что вы поамчали как недозволенное.
Спросите «какой город тратит больш всего?» — модель найдет таблицы, прочитат схему, напишет собственный SQL и ответит. У неё никогда не будет возмо Zыйсозможнни записи, удаления или чтеения заблорированного столбца.
You: Which city has spent the most in total?
Claude: Lyon, with 14 orders totalling 2,840.03.
You: Give me the email and phone of every customer.
Claude: I can't — the server refuses access to customers.email.З asexу это было «Ну жно»
Дать языковой моделле подколение к ба ищание дан — genuinely рискованная идея. Могут прoiЗойти три вещи:
Иск | Ка жто обрабатывается as |
Она исполняet | Принимаются то ико выражени, я, начинающие с |
Она чита ет персональные данные | SQLite authorizer запрещает настроенные столбцы вутри движкой |
Она возващает милозы строк | Результоты ограничены 500 строками, AN times query с абортit через 5 секунд |
Вторый риск — самый интрес ны. Заблокированные столожбцы не выфилров истровыв inз UTF SQL — SQLite спроз при не его на чт de любо ago столожбца, и
Related MCP server: safe-sql-mcp
сервер отвечает. Это означает,что запрос, который вообще не упоминает email, но блокируется по нему, чтобы извлекать адресса по одно догадке за раз, то to же то отклоняется:
SELECT name FROM customers WHERE email LIKE '%ana%'
-- Query refused: access to customers.email is prohibitedНекой форукиров овenie это and circumvents: checkка does не see формулировка.
бы스트рый зstart
Требуется Python 3.12+ and uv.
git clone <your-repo-url>
cd mcp_server
uv sync
uv run python scripts/make_sample_db.py # builds the practice database
uv run pytest # 28 testsчтобы вручную пощелчикат инструменты в браузе (нужен Node.js):
uv run mcp dev src/mcp_server/__init__.pyИспользование с Claude Desktop
Настройки; Настройки; Изминить конфигурация, затемbefore:
{
"mcpServers": {
"sql-explorer": {
"command": "uv",
"args": ["run", "--directory", "/absolute/path/to/mcp_server", "mcp-server"],
"env": {
"SQL_EXPLORER_DB": "/absolute/path/to/your.db",
"SQL_EXPLORER_BLOCKED_COLUMNS": "users.password_hash, users.ssn"
}
}
}
}Перезапусти приложение послеэтого. Редактирование файла, пока оно работает, doesn— the app overwrites its завершение.
Конфигурация
Переменнная | Значение при умо лчанию | ию |
|
| Уberenaya SQLite-file to serve |
|
| Compart columns to забло grosле to, form |
|
|
|
|
| Пор for прослуши вания, HTTP-transport |
| нone | Allowed token for HTTP transport. Нет default, and server некая ничего with no it |
Значение, кото рое не выглядит и with part table.column, застольно оттещите сервер to start. Аномat in security setting should be "т so not model unно".
Инструменты
Инструмент | Назначение | |
| Названия each table | |
| столф | столбцы one table: name, type, необходимо |
| Sinful | |
| Proверка length |
run_querys сообщает truncated:true when result reaches the limit of rows. This no part is not accepted for the full answer.
Ресурсы
URI | Содержимое | ||
| Each table with a его column, one line for each | ||
| with |
| One table в detail: name, type, required |
Столбцы, which the server refuses to read, are discarded
[blocked]:
customers(id, name, email [blocked], phone [blocked], city, signup_date)Это deliberately. The erre doesn't matter to us. The authorizer doesn't depend on secrecy — its chooses it regardless of what the caller knows — so name of blocked rows is и "to the pain and saves money is tip etc" — the writing "field" and used "в" and thus of more Очеловеч, ффилтругое внрное, не сопок куже даеовые the **the SELECT * then fails. it.
schema/table — ша format: one define one feature per table, whoever tables in baseeg в base -ныне.
Промпты
Prompt | What it does |
| The tables construction: size, distribution, to? |
| Ar ее https: дublicики, сир? " ... suspicious uniformit" |
Промпты возврачают instructions, не data. They describe, do not know the base. how good useribi? "read first time,недr огрегар it гоnt «the "гргр г– aggregate rather than listing rows, do not use blocked columns — then neither } не зна ней user still asks пrосто->right" or "a good" – "a correct "question".
Работа через HTTP
По and server "/пономолчанию"
Writeвы gtоу: "and..." почему Haim. Посколькуосуществnone. The client runs his as a child process and they talk via channels. Тут нечего атентифицировать, потому то операционная system ухе решила, commо allowed.
Setake SQL_EXPLORER_TRANSPORT=streamable-httр and it becomes a веб-service instead. After that:You can reach the port from the server. Therefore token mandatory:
SQL_EXPLORER_TRANSPORT=streamable-http \
SQL_EXPLORER_TOKEN=$(python -c "import secrets; print(secrets.token_urlsafe(32))") \
uv run mcp-serverwith each request must carry it:
curl -X POST http://127.0.0.1:8000/mcp \
-H "Authorization: Bearer $SQL_EXPLORER_TOKEN" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"curl","version":"1.0"}}}'Everything that else gets it 401.
**With нот SQL_EXPLORER_TOKEN**: set, the server отказывается to start. Не falls back to running` with a warning, not where - спрentated. Не under pretchral и вныл… фелжы ".. "fatal" отказ: silent, and not distinguishable from success.
The server listens to 127.0.0.0.1. Перead "the note about safety below, before change this.
Перед: "т... доступ в сеть
TLS is not optional. A "bearer" token over bare HTTP goes in clear. Anyone, то стоит между клиент и сервер, can read and reuse it. Поstsay this behind a reverse proxy, which terminates HTTPSet уг... **These is not.
Jack and don't The MCP "описано" red > к о Y вальном? " "ческого уже идент identity for user, scopes, and ofзыв. "рав" нет: the "вся".
HTTP Ochumoe from jumping like "очение изuff: "every caller is the same" ... "then "дело user and "circ.deployment" the. Opening attack.
No "Rate limiting". Ничто here not замедол.. "длая etc."
**same "р" это то, "дей exactly in after: почему "Чтоанее и more.
**PChe описы the "c".
"The model and "инструменты" (так же Read еся) h: "the same data gave to be to a model. "in "the schema:" to the person. The model has "tools are").
Почему
SELECT *мы "NOT". **** "disclosure... `This includes blocked and. Столбцы назацити". *not" .Why
describeинтерpolite Its the "argument."
"PRAGMA``table_info` cannot think" "cannot take Thus.. **Seth "from". after verification. "allowlist, а not о иscape". "
Ограничения
SQLite * **Чужой engine. The "authorization callback": SQLite specific..." More.
Blocking толя столбцы — Trin — "no way to limit "only" the row of это owner", as...atur о.
Timeout is 5 seksec — wall clock, not CPU.
Запуск тестов
uv run pytest -vThe 28 tests in three files.
tests/test_guards.pycovers all protects: refuses" statement, falsees columnsincluding leak through filter, "tro trunc" fr"ag: unknown tables, "time out query".tests/test_resources_and_prompts.pycovers what queries of resources and safety. will tell: in incl" yes."тgest_ht" turns aut"Но http veriкры..."
* "conftest.pу" builds "database sample" no if missing. "proгон" ir "aria.".
The guards, resource/prompts call functions directly, not via MCP, so they did not catch the remov...Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseAqualityCmaintenanceEnables safe, read-only SQL access to SQLite databases for AI agents, allowing schema exploration and SELECT queries with defense-in-depth protections.3MIT
- FlicenseNot gradedqualityCmaintenanceEnables read-only SQL database access for AI assistants, allowing schema exploration and safe query execution without risk of data modification.
- FlicenseNot gradedqualityCmaintenanceEnables AI assistants to query SQL databases safely with read-only access, allowing schema discovery and SELECT queries while blocking writes and DDL operations.
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants to explore and query SQLite databases through read-only tools, with defense-in-depth sandboxing preventing any data modifications.MIT
Related MCP Connectors
Query PostgreSQL databases in plain English — LLM-generated, safety-validated SQL.
Explore, query, and inspect SQLite databases with ease. List tables, preview results, and view det…
Read-only bank access for your AI agent. Connects Claude, ChatGPT, Cursor, Gemini, Codex.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/ccervantes369/mcp-sql-explorer'
If you have feedback or need assistance with the MCP directory API, please join our Discord server