add_url_tool
Index YouTube videos, playlists, or GitHub repositories by URL to enable searchable content retrieval with citations.
Instructions
Add YouTube videos/playlists or GitHub repos to the index via URL.
For local files or directories, use add_document_tool instead.Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| paths | Yes | URLs to index: YouTube video/playlist or GitHub repo. | |
| tags | No | Optional list of tags, one per URL. | |
| branch | No | For GitHub: override branch (default: main). | |
| include_patterns | No | For GitHub: glob patterns for files to include. | |
| exclude_patterns | No | For GitHub: glob patterns to exclude. |
Implementation Reference
- src/pinrag/mcp/server.py:191-237 (handler)The main handler function for the `add_url_tool`. It validates the input URLs, checks for optional tags, branch and pattern parameters, and then calls `add_files` in a separate thread.
async def add_url_tool( paths: Annotated[ list[str], Field(description="URLs to index: YouTube video/playlist or GitHub repo."), ], tags: Annotated[ list[str] | None, Field(description="Optional list of tags, one per URL.") ] = None, branch: Annotated[ str | None, Field(description="For GitHub: override branch (default: main).") ] = None, include_patterns: Annotated[ list[str] | None, Field(description="For GitHub: glob patterns for files to include."), ] = None, exclude_patterns: Annotated[ list[str] | None, Field(description="For GitHub: glob patterns to exclude.") ] = None, ctx: Context | None = None, ) -> dict: """Add YouTube videos/playlists or GitHub repos to the index via URL. For local files or directories, use add_document_tool instead. """ input_paths = list(paths or []) if not input_paths: raise ValueError("paths cannot be empty") for i, p in enumerate(input_paths): if not _is_url(p): raise ValueError( f"path[{i}] is not a URL. Use add_document_tool for local files or directories." ) if tags is not None and len(tags) != len(input_paths): raise ValueError("tags must have same length as paths when provided") def _run() -> dict: return add_files( paths=input_paths, persist_dir=config.get_persist_dir(), collection=config.get_collection_name(), tags=tags, branch=branch, include_patterns=include_patterns, exclude_patterns=exclude_patterns, ) return await anyio.to_thread.run_sync(_run) - src/pinrag/mcp/server.py:189-190 (registration)Registration of the `add_url_tool` using the `mcp.tool()` decorator and wrapping it with `_log_tool_errors`.
@mcp.tool() @_log_tool_errors