
PinRAG
io.github.ndjordjevic由 GitHub 账号 ndjordjevic 发布v0.9.27更新于 Oct 24, 2026
MCP RAG: index PDFs, repos, YouTube, Discord, text; optional YouTube vision; query with citations.
概览
PinRAG 是一个本地 MCP 服务器,把 PDF、代码仓库、YouTube 视频、Discord 导出、笔记和文档索引到同一个 RAG 库,让助手带引用作答。
- 可以做什么
- 把本地 PDF、文本文件、目录、Discord 导出、YouTube 视频或播放列表、GitHub 仓库和文档站点索引进共享向量库,可加标签,GitHub 还可指定分支和 glob 过滤。用自然语言提问并获得带引用的回答,引用指向 PDF 页码、YouTube 时间戳、文档名、仓库分块序号或来源网址,可按文档、标签、类型或页码范围过滤。列出已索引文档及其分块数,设置或替换标签,删除文档。以只读资源查看已索引文档列表和服务器生效配置。
- 适用场景
- 适合学习资料分散在 PDF、代码仓库、视频、聊天导出和文档站点中,希望 Cursor、VS Code 或其他 MCP 客户端里的助手基于全部资料回答问题并给出出处的情况。
- 运行要求
- 以 stdio 本地进程运行,通过 uvx 从 PyPI 的 pinrag 包启动,因此需安装 uv 并在 PATH 中。默认 OpenRouter 聊天模型需要 OPENROUTER_API_KEY,改用其他提供方需相应密钥。建议用绝对路径设置 PINRAG_PERSIST_DIR 存放 Chroma 库。首次运行会下载本地嵌入模型权重(约 270 MB)。可选 YouTube 视觉在 OpenAI 或 Anthropic 模式下需 ffmpeg 和 vision 附加包,OpenRouter 模式只需 OpenRouter 密钥。私有 GitHub 仓库或降低限流可设 GITHUB_TOKEN。
安装
在 SourceWeft 中
- 打开 控制台中的 PinRAG,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
PinRAG
[PyPI] [License: MIT] [io.github.ndjordjevic/pinrag on MCP Marketplace] [pinrag MCP server]
Overview
PinRAG is for when you want to learn about something and your materials are scattered—PDFs and ebooks, GitHub repos, YouTube videos, Discord discussions, and plain notes. You index those materials into one shared RAG index, then ask questions from Cursor, VS Code (GitHub Copilot), or any MCP-capable assistant and get answers with citations pointing back to pages, timestamps, files, or threads.
Under the hood it is Retrieval-Augmented Generation built with LangChain and exposed as an MCP (Model Context Protocol) server: add documents from the editor, query with natural language, list or remove what you indexed. Supported inputs include PDFs, local text files and directories, Discord exports, YouTube (transcript from URL, playlist, or ID), and GitHub repo URLs. For YouTube you can optionally add vision so on-screen code, diagrams, and UI text are merged with the transcript in the same chunks—see YouTube vision enrichment.
Features
- Multi-format indexing — PDF (.pdf), local files or directories, plain text (.txt), Discord export (.txt), YouTube (video or playlist URL, or video ID), GitHub repo (URL), web documentation sites (URL)
- Optional YouTube vision — Off by default. When enabled, runs a vision model (OpenAI, Anthropic, or OpenRouter native video) and merges structured on-screen context with the transcript so RAG chunks carry searchable code names, labels, and diagrams—not speech alone. OpenRouter mode avoids local ffmpeg/video download; openai/anthropic use scene keyframes and require
pinrag[vision]+ ffmpeg (see YouTube vision enrichment) - RAG with citations — Answers cite source context: PDF page, YouTube timestamp, document name for plain text and Discord, chunk index for GitHub repos, source URL for web documentation
- Document tags — Tag documents at index time (e.g.
AMIGA,PI_PICO) for filtered search - Metadata filtering —
query_toolsupportsdocument_id,tag,document_type, PDFpage_min/page_max, andresponse_style(thorough or concise) - MCP tools —
add_document_tool,query_tool,list_documents_tool,remove_document_tool,set_document_tag_tool,list_collections_tool; optionalcollectionon tools overridesPINRAG_COLLECTION_NAMEfor that call - MCP resources —
pinrag://documents(indexed documents) andpinrag://server-config(env vars and config); click in Cursor’s MCP panel to view - MCP prompt —
use_pinrag(parameter: request) for querying, indexing, listing, or removing documents - Configurable LLM — OpenRouter (default, free
openrouter/freerouter), OpenAI, Anthropic, or Cerebras Inference (OpenAI-compatible API); set viaPINRAG_LLM_PROVIDERandPINRAG_LLM_MODELin MCPenvor your shell - Local embeddings — Nomic (
PINRAG_EMBEDDING_MODEL, defaultnomic-embed-text-v1.5); no API key; first run downloads model weights (~270 MB, cached) - Retrieval & chunking options — Structure-aware chunking (on by default); optional FlashRank re-ranking, multi-query expansion, and parent-child chunks for PDFs (see Configuration)
- Observability — MCP tool notifications (
ctx.log) plus optional LangSmith tracing - Built with — LangChain, Chroma; optional OpenRouter, OpenAI, Anthropic, FlashRank
Installation
Add PinRAG as an MCP server in your editor. Install uv and ensure uvx is on your PATH—that runs PinRAG from PyPI without a prior pip install.
Cursor: add this under mcpServers in ~/.cursor/mcp.json:
VS Code (GitHub Copilot): run MCP: Open User Configuration from the Command Palette (or add .vscode/mcp.json in a workspace), then merge this shape—top-level key is servers:
Quick Start
HTTP server mode
For clients that speak MCP over HTTP (e.g. pinrag-cli with --server), run:
This starts a streamable-HTTP MCP endpoint at http://<host>:<port>/mcp. The default pinrag stdio command for editors is unchanged; pinrag server is additive. Connect pinrag-cli with --server http://127.0.0.1:8765/mcp.
Configure MCP server
Put API keys and any PinRAG settings in the MCP entry’s env block. The server does not load .env files when the editor launches it.
Use in chat
Ask in chat: "Add /path/to/amiga-book.pdf with tag AMIGA", "Index https://youtu.be/xyz and ask what it says", "Index https://github.com/owner/repo and ask about the codebase", or "Index https://docs.langchain.com/ and summarize its memory APIs". The AI will invoke the tools for you. Citations show page numbers for PDFs, timestamps (e.g. t. 1:23) for YouTube, document names for plain text and Discord exports, chunk index labels for GitHub, and source URLs for web documentation.
GitHub indexing
Index a repo with add_document_tool and a URL in paths, e.g. https://github.com/owner/repo, https://github.com/owner/repo/tree/branch, or github.com/owner/repo (scheme optional).
GitHub-only options: branch, include_patterns / exclude_patterns — defaults already favor common text and source files and skip bulky artifacts; use patterns when you need files outside that set. Files over PINRAG_GITHUB_MAX_FILE_BYTES (default 512 KiB) are skipped.
Auth: Set GITHUB_TOKEN in MCP env (or the shell) for private repos or fewer rate-limit hits on big indexes; small public runs often work without it. Use a classic or fine-grained PAT with repo read access; there is no OAuth in PinRAG.
Web documentation indexing
Point add_document_tool at any documentation site URL, e.g. https://docs.langchain.com/, https://docs.crewai.com/, or https://picocomputer.github.io/. PinRAG discovers pages via (in order) llms.txt / llms-full.txt (Mintlify-style), sitemap.xml (including robots.txt Sitemap: hints and nested sitemap indexes), then a scoped BFS crawl from the seed URL.
Scope: exact host match (no subdomains) plus path prefix derived from the seed — e.g. https://docs.example.com/guide/ only indexes pages under /guide/. Use the site root URL to capture the full docs tree.
Extraction: text/markdown responses (from llms.txt fast paths) pass through; HTML runs through trafilatura with a BeautifulSoup + markdownify fallback that scopes to <main> / <article> / [role=main].
Limits & politeness: controlled by PINRAG_WEB_MAX_PAGES (default 200), PINRAG_WEB_MAX_DEPTH (5), PINRAG_WEB_MAX_PAGE_BYTES (1 MiB), PINRAG_WEB_CONCURRENCY (4), PINRAG_WEB_RATE_LIMIT_PER_HOST (2.0/sec), and PINRAG_WEB_RESPECT_ROBOTS (true). Some sites (e.g. Cloudflare-protected pages) may return 403 to pure-Python clients; that's a known limitation.
Citations: web chunks carry a source_url metadata field; answers cite per-page URLs, and the document_id is <host><path_prefix> so remove_document_tool / set_document_tag_tool operate on the whole site at once.
YouTube indexing and IP blocking
Transcript-heavy indexing—especially from cloud or high-volume IPs—may return errors like "YouTube is blocking requests from your IP". Point youtube-transcript-api at a proxy via MCP env (or your shell):
PINRAG_YT_PROXY_* affects transcript fetches only; yt-dlp steps (titles, playlists) do not use it. Residential or rotating proxies usually fare better than raw datacenter IPs.
When some paths fail (e.g. a few videos in a playlist), add_document_tool includes fail_summary with counts keyed by blocked, disabled, missing_transcript, and other.
YouTube vision enrichment (optional)
Default indexing is transcript-only. Set PINRAG_YT_VISION_ENABLED=true to add vision captions for on-screen content, time-aligned with the transcript and chunked with metadata such as has_visual, frame_count, and visual_source.
PINRAG_YT_VISION_PROVIDER:
openai(default) oranthropic:yt-dlpdownload → scene-based frames → one multimodal call per frame. Needspinrag[vision], ffmpeg/ffprobe onPATH, andOPENAI_API_KEYorANTHROPIC_API_KEY(install the extra in the same env aspinrag, e.g.uv sync --extra visionorpip install 'pinrag[vision]').openrouter: one OpenRouter request per video viavideo_url(defaultgoogle/gemini-2.5-flash).OPENROUTER_API_KEYonly—no download, ffmpeg, orpinrag[vision]; choose a video-capable model if you overridePINRAG_YT_VISION_MODEL.
Ops: Re-index after changing vision settings. For openai/anthropic, tune cost and timeouts with PINRAG_YT_VISION_MAX_FRAMES and optional PINRAG_YT_VISION_IMAGE_DETAIL=high (clearer small text, more tokens). MCP stdio: yt-dlp progress goes to stderr so stdout stays JSON-clean. Downloading video can breach YouTube ToS or local rules—your call. Docker: build with BUILD_WITH_VISION=1 for ffmpeg + pinrag[vision] (see Dockerfile).
Tips
pinragnot found: MCP inherits your login PATH. Afterpipxoruv tool install, restart the editor and confirmwhich pinrag.PINRAG_PERSIST_DIR: Use a stable absolute path in MCPenv(e.g.~/.pinrag/chroma_db) so the vector store does not depend on the server process cwd.- FlashRank: Install
pinrag[rerank]in the same tool env (pipx install 'pinrag[rerank]'/uv tool install 'pinrag[rerank]'); tunables are in Configuration. - YouTube vision: Follow YouTube vision enrichment for env and deps; re-index after changing vision settings.
pinrag://server-config: MCP Resources → this URI forPINRAG_VERSION, effective LLM/embeddings/chunking, and API key set / not set status.
Configuration
The pinrag://server-config MCP resource prints PINRAG_VERSION (package version, not an env var you set) and effective values for the variables below, plus which API keys are set. Use the table as the full env reference.
Environment variables:
Re-indexing when changing embedding model: Changing
PINRAG_EMBEDDING_MODELrequires re-indexing; vector dimensions must match the model used at index time (including indexes created under an older default embedding).Re-indexing when enabling parent-child: Setting
PINRAG_USE_PARENT_CHILD=truerequires re-indexing; the new structure (child chunks in Chroma, parent chunks in docstore) is created only during indexing for supported document types (not plain.txt).Re-indexing when toggling YouTube vision: Turning
PINRAG_YT_VISION_ENABLEDon or off, changingPINRAG_YT_VISION_PROVIDER, or changing vision model /PINRAG_YT_VISION_IMAGE_DETAIL/ frame limits, requires re-indexing affected YouTube documents for chunks to reflect the new behavior.
Monitoring & Observability
For query performance metrics (latency, timing, token usage) and debugging, use LangSmith. Set LANGSMITH_TRACING=true and LANGSMITH_API_KEY in MCP env or your shell; optionally set LANGSMITH_PROJECT (see table above). If your LangSmith workspace is in the EU region (you use eu.smith.langchain.com in the browser), you must also set LANGSMITH_ENDPOINT=https://eu.api.smith.langchain.com; without it, traces may not show up in the EU deployment. US-region accounts use the default API host and do not need LANGSMITH_ENDPOINT. See notes/langsmith-setup.md for more detail.
For MCP-side introspection, set PINRAG_VERBOSE_LOGGING=true to surface detailed phase events in notifications/message (e.g., YouTube transcript load, whether vision runs, and chunk upsert milestones).
Multiple providers and collections
Vector dimension is fixed per Chroma collection and must match the PINRAG_EMBEDDING_MODEL used when chunks were written. The default id nomic-embed-text-v1.5 is a 768-d Nomic model; another PINRAG_EMBEDDING_MODEL value may imply a different size—check that model’s documentation.
- Default:
PINRAG_COLLECTION_NAMEdefaults topinrag. Do not changePINRAG_EMBEDDING_MODELfor an existing collection without re-indexing into a new collection (or wiping the old one); otherwise adds/queries can fail with embedding dimension errors. - Per-model collections: Use a stable pair of
PINRAG_EMBEDDING_MODEL+PINRAG_COLLECTION_NAME(+PINRAG_PERSIST_DIRif you isolate stores) for each index. To query a collection, set the same env values you used when indexing it. You can index the same sources again under another pair (changeenv, restart MCP if needed, runadd_document_tool). - MCP tools: Each tool uses
config.get_persist_dir()andconfig.get_collection_name()by default; optionalcollectionon a tool call overrides the collection name for that request.list_collections_toollists collection names in the configured persist directory (optionalpersist_diroverride).
MCP reference
Tools, prompt, and read-only resources from the pinrag MCP server (FastMCP("PinRAG")). Tool results are JSON objects that always include _server_version; with PINRAG_VERBOSE_LOGGING=true they may include _verbose_log.
add_document_tool returns indexed, failed, counts, persist_directory, collection_name, and fail_summary when any path failed. query_tool returns answer and sources (each entry: document_id, page—PDF page, often 0 for non-PDF—plus optional start in seconds for YouTube).
query_tool
Natural-language question; optional filters narrow retrieval ("" / omit when unused):
Filters can be combined. The sources list uses page for PDFs and start (seconds) for YouTube; answers may show t. M:SS labels derived from start. GitHub citations use chunk-index-style p. N labels in the answer text. Web docs sources carry a per-page source_url.
Example: "What is OpenOCD? In the Pico doc, pages 16–17 only" → query_tool(query="What is OpenOCD?", document_id="RP-008276-DS-1-getting-started-with-pico.pdf", page_min=16, page_max=17).
add_document_tool
Index locals (PDF, plain or Discord .txt, directories), YouTube (video URL, playlist URL, or bare id), GitHub URLs (scheme optional), or web documentation sites (any http(s) URL). paths batches work items; one failed path does not roll back others. Persists to PINRAG_PERSIST_DIR / PINRAG_COLLECTION_NAME only (no MCP parameters for those).
list_documents_tool
Returns documents, total_chunks, persist_directory, collection_name, and document_details (tags, titles, counts, aggregated bytes when present, upload_timestamp, etc.). If tag is set, total_chunks counts only chunks with that tag (not the whole collection).
remove_document_tool
Deletes every chunk for document_id. Accepts the exact ref from list_documents_tool, the list title, or a unique PDF filename stem.
set_document_tag_tool
Sets or replaces the tag on every indexed chunk for one document. Useful to add or correct a tag after indexing, without re-indexing. Same document-targeting rules as remove_document_tool.
MCP prompt: use_pinrag
Built-in routing blurb: request is interpolated as the first line; the rest lists when to use each tool and their parameters (matches use_pinrag in server.py). Listed wherever the client exposes MCP prompts (e.g. Cursor).
MCP resources
Running tests
From the repo root, install dev extras (e.g. uv sync --extra dev).
-
Fast (no
integration):
uv run pytest tests/ -q -m "not integration"
Skips anything markedintegrationinpyproject.toml(network, API keys, optional assets, MCP stdio). Any test that uses thesample_pdf_pathfixture gets that marker automatically intests/conftest.py, so the sample PDF underdata/pdfs/is only needed for the full run. -
Full suite:
uv run pytest tests/ -qSecrets: For MCP stdio tests, the subprocess env starts from your shell, then any missing
OPENAI_API_KEY/ANTHROPIC_API_KEYare filled fromtests/.mcp_stdio_integration.env(copy fromtests/mcp_stdio_integration.env.example; only those keys are read from the file—already-set env wins). Override the file withPINRAG_MCP_ITEST_ENV_FILE. After merge,test_mcp_stdio_repo.pyrequiresOPENAI_API_KEY, andPINRAG_LLM_PROVIDERmust pass its credential check (e.g. exportOPENROUTER_API_KEYwhen using OpenRouter).test_mcp_stdio_pypi.pyalso requires a working OpenAI key.PDF / stdio: Default PDF is
data/pdfs/sample-text.pdf(not in git). Override withPINRAG_MCP_ITEST_PDF/PINRAG_MCP_ITEST_QUERY. Stdio tests needuvonPATH, or setPINRAG_TEST_UVto the binary path.PyPI MCP test: Marked
pypi_mcp; skip with-m "not pypi_mcp"orPINRAG_MCP_ITEST_SKIP_PYPI=1. Pin the install withPINRAG_MCP_ITEST_PYPI_SPEC(defaultpinrag= latest on PyPI).Verbose:
--log-cli-level=INFO.
The data/ directory is gitignored—create data/pdfs/ (and similar) locally; nothing under data/ is committed.
License
MIT License. Full text in LICENSE.
来源:README.md,提交 3f3336e
工具
0版本历史
1- v0.9.27最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分