PDF Inline Image RAG MCP
Builds searchable SQLite databases from PDFs, preserving inline image locations for AI agents to discover and caption visual content. Supports full-text search over text, image placeholders, and saved captions.
README
PDF Inline Image RAG MCP
An MCP server and CLI for building local, searchable SQLite databases from PDFs where important content appears inside inline images, figures, diagrams, or scanned image blocks.
The key rule is simple:
- Extract PDF text normally.
- Extract only actual PDF image blocks, not whole-page screenshots.
- Insert image placeholders into the page text stream at their page-flow location.
- Store every extracted image with its exact PDF bounding box.
Example text_with_images marker:
[[IMAGE page=72 index=1 bbox=80.6,76.0,535.7,645.7 size=1896x2373 file=mtp-2_assets/images/page_0072_image_01.png]]
This gives an AI agent enough context to search normal text, notice where an image appeared, fetch the image asset, caption/OCR it, and save the caption back into the searchable index.
Install
pip install git+https://github.com/Joncallim/pdf-inline-image-rag-mcp.git
For local development:
git clone https://github.com/Joncallim/pdf-inline-image-rag-mcp.git
cd pdf-inline-image-rag-mcp
python -m venv .venv
. .venv/bin/activate
pip install -e ".[dev]"
MCP Usage
Add this server to your MCP client:
{
"mcpServers": {
"pdf-inline-image-rag": {
"command": "pdf-inline-image-rag-mcp"
}
}
}
Available tools:
build_pdf_ragsearch_pdf_ragget_pdf_pageget_pdf_imagelist_uncaptioned_pdf_imagessave_pdf_image_captioninspect_pdf_rag
Typical flow:
- Call
build_pdf_ragwith a PDF path and output directory. - Call
search_pdf_ragfor normal text queries. - When a result includes
[[IMAGE ...]], callget_pdf_pageorget_pdf_image. - Caption or OCR the image with your preferred model.
- Call
save_pdf_image_captionso the caption is added to page text and FTS.
CLI Usage
Build a database:
pdf-inline-image-rag build \
--input /path/to/file.pdf \
--output-dir outputs/pdf_rag \
--replace
Build only selected pages:
pdf-inline-image-rag build \
--input /path/to/file.pdf \
--output-dir outputs/pdf_rag \
--pages 1-10,42
Search:
pdf-inline-image-rag search \
--db outputs/pdf_rag/file_rag.sqlite \
"sector method"
Inspect:
pdf-inline-image-rag inspect \
--db outputs/pdf_rag/file_rag.sqlite
Output Layout
outputs/pdf_rag/
file_rag.sqlite
file_rag_export.md
file_assets/
images/page_0001_image_01.png
visual_json/page_0001.visual.json
Whole-page PNG rendering is disabled by default. Use --render-pages only for debugging.
SQLite Tables
pages:
text: normal embedded PDF texttext_with_images: text plus inline image placeholdersmarkdown: page-level retrieval documentimage_countneeds_ocr
images:
file_pathbbox_x0,bbox_y0,bbox_x1,bbox_y1width,heightblock_numberplaceholdercaptioncaption_model
pages_fts:
- FTS5 index over text, image placeholders, markdown, and saved captions.
Notes
This project does not invent image captions. It extracts image blocks and makes them discoverable. Use an OCR or vision model to caption the extracted images, then persist the caption with save_pdf_image_caption.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。
mcp-server-qdrant
这个仓库展示了如何为向量搜索引擎 Qdrant 创建一个 MCP (Managed Control Plane) 服务器的示例。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。