# docs-rag **Repository Path**: vince4win/docs-rag ## Basic Information - **Project Name**: docs-rag - **Description**: Documentation Knowledge Base — multi-source RAG engine for coding agents. Syncs and indexes docs from Mastra, Flue, VitePlus, Scrapling, FastAPI into per-source SQLite databases. - **Primary Language**: Unknown - **License**: BSD-3-Clause - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-06-09 - **Last Updated**: 2026-06-09 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Doc Knowledge Base A RAG-powered documentation indexing and search system built for coding agents. Scrape, index, and full-text search library/framework docs — then query them from your agent via MCP, CLI, REST API, or the Codex plugin. **3,020 indexed chunks** across 4 sources (Mastra 2,347, Flue 438, VitePlus 195, Scrapling 40). Built on [Scrapling](https://github.com/D4Vinci/Scrapling) by [D4Vinci](https://github.com/D4Vinci) for HTML parsing and content extraction. Scrapling is licensed under BSD 3-Clause — see [LICENSE](LICENSE) and [THIRD-PARTY-NOTICES.md](docs/THIRD-PARTY-NOTICES.md). --- ## Installation (new machine) ```powershell # Prerequisites: Python 3.10+ and uv (https://docs.astral.sh/uv/) # Clone the repo git clone https://gitee.com/vince4win/docs-rag.git cd docs-rag # Install dependencies uv sync # Verify uv run python -m scripts.cli stats uv run python -m scripts.cli sources ``` If you clone to a different path, update the project path in the Codex plugin config (see [Codex Plugin](#codex-plugin) section). > **Note:** If `uv sync` fails with `Multiple top-level packages discovered`, add this to `pyproject.toml`: > ```toml > [tool.setuptools.packages.find] > include = ["scripts*"] > exclude = ["db*", "output*", "plugins*", "sources*"] > ``` > Then run `uv sync` again. --- ## Quick Start ```bash # Start the REST API (optional) uv run uvicorn scripts.api:app --host 127.0.0.1 --port 8001 # Sync documentation sources uv run python -m scripts.cli sync scrapling --max-pages 25 --max-depth 2 # Query uv run python -m scripts.cli query "Selector.css adaptive" --source scrapling --limit 3 ``` --- ## CLI The CLI works directly against the database — no server needed. ```bash uv run python -m scripts.cli --help ``` ### query — Full-text search ```bash uv run python -m scripts.cli query "how to create an agent" --source flue --limit 3 uv run python -m scripts.cli query "Selector.css" --source scrapling --limit 5 --max-chars 1000 --max-code-blocks 2 ``` | Flag | Default | Description | |------|---------|-------------| | `--source`, `-s` | all | Filter by source name | | `--limit`, `-l` | 5 | Max results (max: 20) | | `--max-chars` | 2000 | Truncate content_md per chunk | | `--max-code-blocks` | 3 | Code blocks per result | ### api — API signature lookup ```bash uv run python -m scripts.cli api scrapling Selector.css uv run python -m scripts.cli api flue createAgent uv run python -m scripts.cli api flue "session.task(...)" ``` ### agent — Agent-friendly Markdown retrieval ```bash uv run python -m scripts.cli agent "what is flue framework" --source flue --api-base http://127.0.0.1:8001 ``` ### sources — List configured sources ```bash uv run python -m scripts.cli sources ``` ### stats — Storage statistics ```bash uv run python -m scripts.cli stats ``` ### sync — Sync one source ```bash uv run python -m scripts.cli sync scrapling --max-pages 25 --max-depth 2 --links-per-page 10 uv run python -m scripts.cli sync flue --full --max-pages 50 --max-depth 3 ``` | Flag | Default | Description | |------|---------|-------------| | `--full` | false | Clear and re-sync from scratch | | `--max-pages` | 25 | Cap on pages fetched | | `--max-depth` | 2 | Max link traversal depth | | `--links-per-page` | 10 | Max links followed per page | ### sync-all — Sync all enabled sources ```bash uv run python -m scripts.cli sync-all --max-pages 25 --max-depth 2 ``` --- ## REST API ```bash uv run uvicorn scripts.api:app --host 127.0.0.1 --port 8001 ``` Background syncs run via APScheduler at intervals defined in each source config. | Method | Path | Description | |--------|------|-------------| | `GET` | `/health` | Health check | | `GET` | `/sources` | List all configured sources | | `POST` | `/query` | Full-text search | | `GET` | `/api/{source}/{name}` | API signature lookup | | `POST` | `/sync/{source}` | Trigger sync for one source | | `POST` | `/sync/all` | Sync all enabled sources | | `GET` | `/stats` | Storage statistics | ```bash # Health check curl http://127.0.0.1:8001/health # Search curl -X POST http://127.0.0.1:8001/query \ -H "Content-Type: application/json" \ -d '{"query": "createAgent", "source": "flue", "limit": 3}' # API lookup curl http://127.0.0.1:8001/api/flue/createAgent # Sync curl -X POST "http://127.0.0.1:8001/sync/scrapling?max_pages=10&max_depth=1" # Stats curl http://127.0.0.1:8001/stats ``` --- ## MCP Server Connects to any MCP-compatible coding agent over stdio. The repo includes config files for all major agents. ### Tools | Tool | Input | Description | |------|-------|-------------| | `docs_query` | `query`, `source?`, `limit?` | Full-text search | | `docs_api` | `source`, `name` | API signature lookup | | `docs_sources` | -- | List configured sources | | `docs_sync` | `source_name`, `full?`, `max_pages?`, `max_depth?`, `links_per_page?` | Sync a source | | `docs_sync_all` | `full?`, `max_pages_per_source?`, `max_depth?`, `links_per_page?` | Sync all sources | | `docs_stats` | -- | Storage statistics | ### Resources | URI | Description | |-----|-------------| | `doc-kb://sources` | All sources and their config | | `doc-kb://stats` | Total chunk counts per source | | `doc-kb://source/{name}/stats` | Stats for one source | ### Quick start (any agent) ```bash cd /path/to/docs-rag uv run python -m scripts.mcp_server ``` ### Agent configuration files #### Claude Code **Config file:** `.claude/servers.json` ```json { "doc-kb": { "command": "uv", "args": ["run", "--directory", "/path/to/docs-rag", "python", "-m", "scripts.mcp_server"] } } ``` **Install:** ```bash cp .claude/servers.json ~/.claude/servers.json ``` #### Cursor **Config file:** `.cursor/mcp.json` — copy JSON into Cursor MCP settings. #### OpenCode **Config file:** `.opencode/providers/mcp.json` ```bash mkdir -p ~/.config/opencode/providers cp .opencode/providers/mcp.json ~/.config/opencode/providers/mcp.json ``` #### Any MCP agent Use `.mcp.json` as a reference. Replace `/path/to/docs-rag` with the absolute path to this repo. ```json { "mcpServers": { "doc-kb": { "command": "uv", "args": ["run", "--directory", "/path/to/docs-rag", "python", "-m", "scripts.mcp_server"], "env": {} } } } ``` --- ## Codex Plugin This repo includes a Codex plugin at `plugins/doc-knowledge-base/`. The plugin registers an MCP server (`doc-kb`) that provides 6 search tools in every Codex thread. ### Install on a new machine ```powershell # Prerequisites: Python 3.10+, uv, and uv sync already run (see Installation above) # 1. Register the local plugin marketplace in Codex npx codex plugin marketplace add "C:\path\to\docs-rag" # 2. Install the plugin npx codex plugin add doc-knowledge-base@local # 3. Verify npx codex plugin list # 4. Start a new Codex thread — the doc-kb MCP server will be available ``` Replace `C:\path\to\docs-rag` with your actual clone path. The marketplace name (`local`) is defined in `.agents/plugins/marketplace.json` and can be changed there before running the add commands. ### Uninstall ```powershell npx codex plugin remove doc-knowledge-base@local ``` ### What the plugin provides - **MCP server** `doc-kb` — 6 tools + 3 resources in every Codex thread - **Skill** — CLI usage guide for Codex agents (see `skills/SKILL.md`) - **Default prompts** — quick-start queries in the plugin card ### Plugin structure ``` plugins/doc-knowledge-base/ ├── .codex-plugin/plugin.json # Manifest ├── .mcp.json # MCP server config ├── assets/ │ ├── icon.svg # Logo (256x256) │ └── composer-icon.svg # Composer icon (48x48) ├── skills/ │ └── SKILL.md # Usage guide for agents └── scripts/ └── run_mcp_server.py # MCP server launcher ``` The `.mcp.json` references this repo's absolute path as the `--directory` argument for `uv run`. If you move the repo, update that path. --- ## License **BSD 3-Clause** — see [LICENSE](LICENSE) for full text. Built on [Scrapling](https://github.com/D4Vinci/Scrapling) by [D4Vinci](https://github.com/D4Vinci), also BSD 3-Clause. See [THIRD-PARTY-NOTICES.md](docs/THIRD-PARTY-NOTICES.md) for all third-party licenses.