TinyRAG
Enables LLM agents to access a private knowledge base through MCP by automatically chunking and indexing .txt documents, with zero configuration and no Docker or vector database required.
README
TinyRAG
Your agent already has an LLM. TinyRAG gives it a private knowledge base through MCP.
No Docker. No vector database. No mandatory API key. Add your .txt documents to data/raw/; TinyRAG automatically chunks and indexes them, then exposes the relevant source text to your agent through MCP.
Zero RAG configuration: the defaults work out of the box, with optional semantic retrieval when you need it.
You do not need to install or configure anything yourself. Give this repository to an agent with terminal access, and it can set up TinyRAG for you.
Give this repository to your agent and tell it:
Install TinyRAG, add my text documents, run its evaluation, and configure it as a local stdio MCP server. Do not commit secrets or private documents.
Repository: https://github.com/spacecat398/TinyRAG-MCP
你的 Agent 已经拥有 LLM,TinyRAG 通过 MCP 为它提供一个私有知识库。
无需 Docker,无需向量数据库,也不强制要求 API Key。把 .txt 文档放入 data/raw/,TinyRAG 会自动切块并建立索引,再通过 MCP 把相关原文提供给你的 Agent。
RAG 零配置:默认设置开箱即用,需要时再开启语义检索。
你不需要亲自安装或配置任何东西。把这个仓库交给拥有终端权限的 Agent,它会替你完成 TinyRAG 的安装和接入。
把这个仓库地址发给你的 Agent,并告诉它:
安装 TinyRAG,添加我的文本文档,运行项目评估,并将它配置为本地 stdio MCP 服务器。不要提交密钥或私人文档。
仓库地址:https://github.com/spacecat398/TinyRAG-MCP
Agent Instructions
This section is written for AI agents that install, configure, or operate TinyRAG.
Objective
Install TinyRAG as a local MCP server and expose the user's UTF-8 .txt documents as searchable knowledge. Prefer the smallest working configuration. Do not add Docker, a vector database, or an LLM dependency unless the user explicitly requests one.
Requirements
- Python 3.12 or newer
uvpreferred;pipis supported- Git
- A host that can launch local stdio MCP servers
Install
git clone https://github.com/spacecat398/TinyRAG-MCP.git
cd TinyRAG-MCP
uv sync
uv run python -m unittest discover -s tests -v
uv run python scripts/eval.py
Expected test result: all unit tests pass. Expected evaluation result: 3 passed, 0 failed.
If uv is unavailable:
python -m venv .venv
python -m pip install -r requirements.txt
python -m unittest discover -s tests -v
python scripts/eval.py
Activate .venv first when required by the operating system.
Add Knowledge
- Put UTF-8
.txtfiles indata/raw/. - Run a query or restart the MCP server.
- TinyRAG automatically rebuilds
data/processed/when source file names, modification times, or chunk settings change.
Do not commit private documents unless the user explicitly approves it. The included sample documents may be removed.
Configure MCP
Use the following local stdio server definition. Replace cwd with the absolute repository path on the current machine.
{
"mcpServers": {
"tinyrag": {
"command": "uv",
"args": ["run", "python", "rag_app/mcp_server.py"],
"cwd": "/absolute/path/to/TinyRAG-MCP"
}
}
}
Windows paths may use forward slashes, for example C:/Users/name/TinyRAG-MCP.
Configuration file names and locations vary by MCP host. Adapt the object to the host's schema without changing the command, arguments, or working directory. TinyRAG uses stdio; do not configure it as an HTTP server.
Available Tools
| Tool | Purpose |
|---|---|
query_knowledge_base(question) |
Retrieve relevant context and return a lightweight grounded answer or excerpt |
search_relevant_chunks(question, top_k=3) |
Return source chunks for the calling agent to reason over |
list_documents() |
List indexed source documents |
For agentic workflows, prefer search_relevant_chunks when the calling agent should produce the final answer itself.
Retrieval Modes
TinyRAG works without an API key:
- Default: local keyword retrieval
- Optional: semantic retrieval through an OpenAI-compatible Embedding API
- Fallback: keyword retrieval when the Embedding API is unavailable
To enable semantic retrieval, create .env from .env.example:
TINYRAG_ENABLE_REMOTE_EMBEDDINGS=true
OPENAI_API_KEY=
OPENAI_BASE_URL=https://api.openai.com/v1
EMBEDDING_MODEL=text-embedding-3-small
Never commit .env. Remote embeddings stay disabled unless TINYRAG_ENABLE_REMOTE_EMBEDDINGS=true is set explicitly. When enabled, document chunks and queries are sent to the configured API endpoint. Inform the user before enabling a remote endpoint for private data.
Direct Query
uv run python scripts/query.py "What does the knowledge base say about RAG?"
Interactive mode:
uv run python scripts/query.py
Operational Constraints
- Supported source format:
.txtonly - Transport: local MCP stdio only
- Generation: lightweight rule/excerpt generation, not a general-purpose LLM
- Storage: JSON cache under
data/processed/ - Default chunk size: 500 characters
- Default overlap: 80 characters
- Default retrieval count: 3 chunks
The calling agent is expected to handle general reasoning and answer generation. TinyRAG focuses on loading, caching, and retrieving local context.
Safety Rules
- Never expose or commit
.env. - Never commit
.venv/ordata/processed/. - Treat files in
data/raw/as potentially private. - Do not silently enable a remote Embedding API.
- Do not delete user documents when rebuilding the cache.
- Keep paths relative to the repository except for the MCP host's required absolute
cwd.
Important Files
rag_app/mcp_server.py MCP stdio entry point
rag_app/pipeline.py retrieval pipeline
rag_app/retriever.py keyword and embedding retrieval
rag_app/cache.py automatic local cache
data/raw/ user source documents
data/processed/ generated cache, ignored by Git
scripts/eval.py smoke evaluation
scripts/query.py command-line query tool
.env.example optional embedding configuration
CHANGELOG.md release notes and upgrade changes
Completion Check
Before reporting installation complete, verify all of the following:
uv run python -m unittest discover -s tests -vanduv run python scripts/eval.pypass.data/raw/contains the intended documents.- The MCP configuration uses an absolute and existing
cwd. - The MCP host can see
query_knowledge_base,search_relevant_chunks, andlist_documents. - No secret or private generated file is staged in Git.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。