Labsco
ndjordjevic logo

PinRAG

1

from ndjordjevic

Cited RAG MCP: PDFs, GitHub, YouTube, Discord exports, local files, one shared index.

🔥🔥🔥🔥✓ VerifiedAccount requiredNeeds API keys

PinRAG logo

PinRAG

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 filteringquery_tool supports document_id, tag, document_type, PDF page_min/page_max, and response_style (thorough or concise)
  • MCP toolsadd_document_tool, query_tool, list_documents_tool, remove_document_tool, set_document_tag_tool, list_collections_tool; optional collection on tools overrides PINRAG_COLLECTION_NAME for that call
  • MCP resourcespinrag://documents (indexed documents) and pinrag://server-config (env vars and config); click in Cursor’s MCP panel to view
  • MCP promptuse_pinrag (parameter: request) for querying, indexing, listing, or removing documents
  • Configurable LLM — OpenRouter (default, free openrouter/free router), OpenAI, Anthropic, or Cerebras Inference (OpenAI-compatible API); set via PINRAG_LLM_PROVIDER and PINRAG_LLM_MODEL in MCP env or your shell
  • Local embeddings — Nomic (PINRAG_EMBEDDING_MODEL, default nomic-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

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):

ParameterDescription
queryQuestion (required)
document_idLimit to this document — exact ref from list_documents_tool, list title, or unique PDF filename stem
page_min, page_maxInclusive PDF page range (must pass both; one page: same value twice)
tagOnly chunks with this tag
document_typepdf, youtube, discord, github, plaintext, or web
response_stylethorough or concise. Empty (the schema default) or any other string → resolved via PINRAG_RESPONSE_STYLE (see server.py: only those two literals override env).

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).

ParameterDescription
pathsRequired list: files, dirs, URLs, or video ids
tagsOptional; one per paths entry, same order
branchGitHub only: branch override
include_patternsGitHub only: glob include list
exclude_patternsGitHub only: glob exclude list

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).

ParameterDescription
tagOptional: only docs that have this tag

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.

ParameterDescription
document_idRequired — exact ref, list title, or unique PDF 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.

ParameterDescription
document_idRequired — exact ref, list title, or unique PDF stem
tagRequired — non-empty tag string
collectionOptional override (default: PINRAG_COLLECTION_NAME)

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).

ParameterDescription
requestOptional user goal (may be empty)

MCP resources

ResourceDescription
pinrag://documentsPlain-text listing for the server’s configured collection (from format_documents_list)
pinrag://server-configPrintable dump of effective env/config (includes PINRAG_VERSION, key operational vars, API key presence)