Skip to main content
Glama

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
NameRequiredDescriptionDefault
pathsYesURLs to index: YouTube video/playlist or GitHub repo.
tagsNoOptional list of tags, one per URL.
branchNoFor GitHub: override branch (default: main).
include_patternsNoFor GitHub: glob patterns for files to include.
exclude_patternsNoFor GitHub: glob patterns to exclude.

Implementation Reference

  • 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)
  • Registration of the `add_url_tool` using the `mcp.tool()` decorator and wrapping it with `_log_tool_errors`.
    @mcp.tool()
    @_log_tool_errors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ndjordjevic/pinrag'

If you have feedback or need assistance with the MCP directory API, please join our Discord server