MCP Jina Supabase RAG
一个精简、专注的MCP服务器,用于抓取文档网站并将其索引到RAG(检索增强生成)的Supabase。
特性
- 智能URL发现:首先尝试sitemap.xml,回退到Crawl4AI递归发现
- 混合内容提取:使用Jina AI进行快速内容提取,Crawl4AI作为后备
- 多项目支持:为多个文档站点建立索引,以分隔Supabase项目
- 高效分块:具有可配置大小和重叠的智能文本分块
- 矢量嵌入:存储在Supabase pgvector中的OpenAI嵌入
建筑
┌─────────────────────────────────────────────────────────────┐
│ MCP Server Tools │
├─────────────────────────────────────────────────────────────┤
│ 1. crawl_and_index(url_pattern, project_name) │
│ 2. list_projects() │
│ 3. search_documents(query, project_name, limit) │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Discovery Layer │
├─────────────────────────────────────────────────────────────┤
│ • Try sitemap.xml (fast) │
│ • Try common doc patterns │
│ • Crawl4AI recursive discovery (fallback) │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Extraction Layer │
├─────────────────────────────────────────────────────────────┤
│ • Jina AI Reader API (primary, fast) │
│ • Crawl4AI (fallback for complex pages) │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Chunking & Embedding Layer │
├─────────────────────────────────────────────────────────────┤
│ • Smart text chunking │
│ • OpenAI embeddings (text-embedding-3-small) │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Supabase Storage │
├─────────────────────────────────────────────────────────────┤
│ • pgvector for similarity search │
│ • Project isolation via source column │
└─────────────────────────────────────────────────────────────┘安装
先决条件
- Python 3.12+
- Supabase账户
- OpenAI API密钥
- Jina AI API密钥 (可选,推荐)
设置
- 克隆存储库:
git clone https://github.com/yourusername/mcp-jina-supabase-rag.git
cd mcp-jina-supabase-rag- 安装依赖项:
# Using uv (recommended)
uv venv
source .venv/bin/activate # or .venv\Scripts\activate on Windows
uv pip install -e .
# Or using pip
pip install -e .- 设置Supabase数据库:
# Run the SQL in supabase_schema.sql in your Supabase SQL Editor- 配置环境:
cp .env.example .env
# Edit .env with your credentials用法
运行MCP服务器
# SSE transport (recommended for remote connections)
python src/main.py
# The server will start on http://localhost:8052/sse配置MCP客户端
克劳德代码
claude mcp add --transport sse jina-supabase http://localhost:8052/sse光标/克劳德桌面
{
"mcpServers": {
"jina-supabase": {
"transport": "sse",
"url": "http://localhost:8052/sse"
}
}
}斜杠命令
创建 /home/marty/.claude/commands/jina.md:
---
allowed-tools: mcp__jina-supabase
argument-hint:
description: Crawl documentation and index to Supabase RAG
---
# Index Documentation to Supabase
Use the jina-supabase MCP server to crawl and index documentation.
Arguments:
- $1: URL pattern (e.g., https://docs.example.com/*)
- $2: Project name for isolation
Example:
/jina https://docs.anthropic.com/claude/* anthropic-docs工具
crawl_and_index
抓取文档网站并索引到Supabase。
参数:
url_pattern(string):要爬网的URL或模式project_name(string):隔离的项目标识符discovery_method(字符串,可选):auto,sitemap,或crawlextraction_method(字符串,可选):auto,jina,或crawl4ai
例子:
await crawl_and_index(
url_pattern="https://docs.supabase.com/docs/*",
project_name="supabase-docs",
discovery_method="auto",
extraction_method="jina"
)list_projects
列出所有索引项目。
退货: 带有文档计数的项目名称列表
search_documents
使用向量相似度搜索索引文档。
参数:
query(string):搜索查询project_name(字符串,可选):按项目筛选limit(int,可选):最大结果(默认值:5)
例子:
results = await search_documents(
query="How do I set up authentication?",
project_name="supabase-docs",
limit=10
)配置
看 .env.example 对于所有配置选项。
发现方法
auto:先尝试站点地图,然后回退到爬网sitemap:仅使用sitemap.xml(快速,如果没有站点地图则失败)crawl:仅使用Crawl4AI递归发现(缓慢、全面)
提取方法
auto:使用Jina进行批量提取(>10个URL),否则使用Crawl4AIjina:使用Jina AI阅读器API(快速,需要API密钥)crawl4ai:使用Crawl4AI浏览器自动化(速度慢,不需要API密钥)
发展
# Install dev dependencies
uv pip install -e ".[dev]"
# Run tests
pytest
# Format code
black src/
# Lint
ruff check src/与mcp-crawl4ai-rag的区别
| 功能 | mcp-crawl4ai-rag | mcp-jina suabase rag |
|---|---|---|
| 聚焦 | 带知识图的全功能RAG | 精益文档索引器 |
| 发现 | 仅递归 | 先使用Sitemap,爬行回退 |
| 提取 | 仅限Crawl4AI | Jina初选,Crawl4AI回退 |
| 依赖项 | 重型(Neo4j等) | 轻型(仅内核) |
| 用例 | 具有幻觉检测功能的高级RAG | 快速文档索引 |
许可证
麻省理工学院
贡献
欢迎投稿!请先打开一个问题来讨论更改。
