md-sql
Allows querying and modifying Markdown documentation as a relational database using SQL SELECT, INSERT, UPDATE, and DELETE operations, with automatic writing changes back to the original .md files.
Click on "Install 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., "@md-sqlShow me all second-level headings in the docs"
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.
md-sql
MCP-сервер для работы с Markdown-документацией как с реляционной базой данных. Парсит .md файлы в SQLite-таблицу md, предоставляя два MCP-инструмента: md_select (SELECT-запросы) и md_change (INSERT / UPDATE / DELETE с автоматической записью изменений обратно в исходные файлы).
Быстрый старт
pip install -e .
DOC_ROOTS='["/path/to/docs"]' python -m mcp_md_sql.serverRelated MCP server: Frontmatter MCP
Подключение к MCP-клиенту
Zed
{
"mcp_servers": {
"sql-mcp": {
"command": "python",
"args": ["-m", "mcp_md_sql.server"]
}
}
}Claude Desktop
{
"mcpServers": {
"sql-mcp": {
"command": "python",
"args": ["-m", "mcp_md_sql.server"]
}
}
}
DOC_ROOTSможно не указывать — сервер получит корни от IDE через MCP-протокол. Переменная окружения используется как fallback.
DOC_ROUTES
JSON-массив путей:
DOC_ROOTS='["/project/docs", "/project/specs"]'Алиас корня генерируется из имени папки. Для путей выше это docs и specs.
Поддерживается и legacy-формат alias=/path (разделитель ;):
DOC_ROOTS="docs=./docs;specs=./specifications"MCP-инструменты
Корни документации разрешаются lazy при первом вызове (на всю жизнь инстанса):
IDE roots — MCP
session.list_roots()(один раз, кэшируется)Fallback —
DOC_ROOTSиз envError — если ни один источник не дал корней
Параметр root_path опционален — используется только для override корня на конкретный вызов.
Инстанс MCP локальный для проекта → одна in-memory SQLite БД на весь lifecycle.
md_select
Выполняет произвольный SELECT-запрос к таблице md.
SELECT * FROM md WHERE type = 'heading' AND depth = 0md_change
Модифицирует документацию через INSERT / UPDATE / DELETE. Хирургически патчит исходный .md файл и возвращает diff.
Ограничения:
DDL и транзакции запрещены
UPDATE и DELETE без WHERE запрещены
Прямое изменение
idзапрещеноMulti-statement в SELECT запрещены
Таймаут SQL-запроса: 15 секунд
md_debug
Диагностический инструмент (временный). Без параметров. Возвращает JSON с:
состояние
_conn/watcherenv (
DOC_ROOTS, CWD)статистика БД (если загружена)
клиентские capabilities (есть ли
roots)результат
list_roots()probe
Используется для отладки разрешения корней.
Таблица md
Колонка | Тип | Описание |
id | INTEGER | Автоинкрементный первичный ключ |
root | TEXT | Полный абсолютный путь к корню документации |
file | TEXT | Относительный путь к .md файлу |
line_start | INTEGER | Начальная строка элемента в файле (1-based) |
line_end | INTEGER | Конечная строка элемента |
pos_in_file | INTEGER | Порядковая позиция в документе (1..N) |
parent_pos | INTEGER | pos_in_file родителя (NULL для корневых) |
depth | INTEGER | Уровень вложенности |
type | TEXT | Тип элемента (heading, paragraph, list_item, code_block, blockquote, table, strong, emphasis, link, image, inline_code, strikethrough, hr, frontmatter, html, html_inline) |
content | TEXT | Содержимое элемента |
attrs_json | TEXT | JSON-строка с атрибутами |
Структура проекта
src/mcp_md_sql/
├── config.py # DOC_ROOTS → RootConfig
├── parser.py # Парсинг .md через mistune → flat list
├── database.py # SQLite in-memory: схема, загрузка, reload
├── reconstructor.py # Обратная сборка Markdown из строк таблицы
├── tools.py # md_select / md_change
├── watcher.py # Live-синхронизация через watchdog
└── server.py # Точка входа, MCP-сервер
tests/
├── conftest.py # Глобальные фикстуры (cleanup кэша корней)
├── test_parser.py # 30 тестов парсера (+ frontmatter, nested lists)
├── test_reconstructor.py # 23 теста реконструктора (+ frontmatter)
├── test_integration.py # 15 интеграционных тестов (+ integrity check)
├── test_select_queries.py # 47 тестов (SELECT + валидация + config + timeout + FS errors)
├── test_watcher.py # 4 теста файлового вотчера
├── test_server.py # 26 тестов (_format_select_result + _handle_call_tool + _ServerState)
├── test_scenarios.py # 33 сценария реальной работы (через _handle_call_tool)
└── fixtures/
├── test_basic.md # Базовый фикстур
└── complex/ # 5 сложных .md документов для 20 сценариев
├── api_docs.md
├── configuration_guide.md
├── technical_spec.md
├── tutorial_quickstart.md
└── deployment_guide.mdЗапуск тестов
pip install -e ".[dev]"
python -m pytest tests/Тесты запускаются параллельно (через
pytest-xdist -n auto). Полный прогон занимает ~7 секунд.
Зависимости
mistune >= 3.0— парсинг Markdown в ASTwatchdog >= 6.0— отслеживание изменений файловmcp >= 1.0— протокол Model Context ProtocolPython >= 3.11
This server cannot be installed
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 Connectors
Create, edit, review, and explicitly publish Live or Snapshot Markdown Documents in mdedit.ai.
Markdown workspace for AI agents: read, write, organize, and share markdown documents.
Extract PDFs to Markdown, RAG chunks and cited tables; publish tracked Doc Links with read stats.
Portable AI memory shared across models and harnesses - plain markdown you own.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI models to seamlessly access and query local markdown technical documentation files, providing automatic documentation context without explicit prompting.195ISC
- AlicenseAqualityCmaintenanceEnables querying and updating Markdown frontmatter metadata using DuckDB SQL, with optional semantic search capabilities for finding similar documents based on content.91MIT
- AlicenseNot gradedqualityDmaintenanceEnables users to document data and connect it to AI agents by defining tools and instructions in markdown files. It supports building RAG and text-to-SQL applications that can be deployed as MCP servers, APIs, or CLIs.5MIT
- FlicenseNot gradedqualityDmaintenanceConverts documents (PDF, DOCX, XLSX, PPTX, HTML, TXT, MD) to Markdown and stores them locally with search and retrieval capabilities.
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/neirokoder/mcp_md_sql'
If you have feedback or need assistance with the MCP directory API, please join our Discord server