Skip to main content
Glama

search_youtube

Read-only

Search YouTube by topic to find videos, channels, or playlists. Returns up to 50 results with metadata. Use for broad discovery when you do not know a specific channel.

Instructions

Search YouTube globally for videos, channels, or playlists on any topic. Returns up to 50 results with metadata. Use this for topic-based discovery when the user has not specified a channel — for searching within a known channel use search_channel_videos instead.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
qYesSearch query (same syntax as YouTube's search bar, e.g. 'rust async tutorial', 'lex fridman dario amodei').
typeNoSearch type: 'video', 'channel', or 'playlist'. Default: 'video'.
limitNoMax results (1-50, default 20).

Implementation Reference

  • Input schema for search_youtube tool: accepts 'q' (required string query), optional 'type' (video/channel/playlist), and optional 'limit' (1-50).
    inputSchema: {
      type: "object",
      properties: {
        q: {
          type: "string",
          description:
            "Search query (same syntax as YouTube's search bar, e.g. 'rust async tutorial', 'lex fridman dario amodei').",
          minLength: 1,
        },
        type: {
          type: "string",
          description:
            "Search type: 'video', 'channel', or 'playlist'. Default: 'video'.",
          enum: ["video", "channel", "playlist"],
        },
        limit: {
          type: "number",
          description: "Max results (1-50, default 20).",
          minimum: 1,
          maximum: 50,
        },
      },
      required: ["q"],
    },
  • src/index.js:74-103 (registration)
    Tool registration entry in the TOOLS array at line 73. The search_youtube tool is declared with name, description, annotations (YT_READ: non-idempotent, not destructive, read-only), and its inputSchema.
    {
      name: "search_youtube",
      description:
        "Search YouTube globally for videos, channels, or playlists on any topic. Returns up to 50 results with metadata. Use this for topic-based discovery when the user has not specified a channel — for searching within a known channel use search_channel_videos instead.",
      annotations: { title: "Search YouTube", ...ANN.YT_READ },
      inputSchema: {
        type: "object",
        properties: {
          q: {
            type: "string",
            description:
              "Search query (same syntax as YouTube's search bar, e.g. 'rust async tutorial', 'lex fridman dario amodei').",
            minLength: 1,
          },
          type: {
            type: "string",
            description:
              "Search type: 'video', 'channel', or 'playlist'. Default: 'video'.",
            enum: ["video", "channel", "playlist"],
          },
          limit: {
            type: "number",
            description: "Max results (1-50, default 20).",
            minimum: 1,
            maximum: 50,
          },
        },
        required: ["q"],
      },
    },
  • Generic handler that proxies all tool calls (including search_youtube) to the upstream MCP server at api.subdownload.com/mcp via callUpstream(). No local handler logic — the actual search_youtube execution is on the upstream side.
    server.setRequestHandler(CallToolRequestSchema, async (request) => {
      try {
        return await callUpstream(
          request.params.name,
          request.params.arguments || {}
        );
      } catch (err) {
        return {
          content: [{ type: "text", text: err.message || String(err) }],
          isError: true,
        };
      }
    });
  • Helper function callUpstream() that forwards tool call requests (including search_youtube) to the upstream SubDownload MCP API via HTTP POST with Bearer token authentication.
    async function callUpstream(name, args) {
      if (!API_KEY) {
        throw new Error(
          "SUBDOWNLOAD_API_KEY env var is not set. Get one at https://subdownload.com/account, then run with -e SUBDOWNLOAD_API_KEY=<your-key>."
        );
      }
      const res = await fetch(UPSTREAM_URL, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Accept: "application/json, text/event-stream",
          Authorization: `Bearer ${API_KEY}`,
        },
        body: JSON.stringify({
          jsonrpc: "2.0",
          id: Date.now(),
          method: "tools/call",
          params: { name, arguments: args },
        }),
      });
      const text = await res.text();
      let body;
      try {
        body = JSON.parse(text);
      } catch {
        throw new Error(
          `Upstream returned non-JSON response (HTTP ${res.status}): ${text.slice(0, 200)}`
        );
      }
      if (body.error) {
        throw new Error(body.error.message || JSON.stringify(body.error));
      }
      return body.result;
    }
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint and destructiveHint. Description adds that results are up to 50 with metadata, and search is global. No contradictions. Additional behavioral details like rate limits or auth are not needed given context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences: first sentence states purpose and output, second gives usage guidance. No wasted words, front-loaded with key information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with three well-documented parameters and no output schema, the description covers purpose, scope, result count, and sibling differentiation. 'Metadata' is slightly vague but acceptable for agent invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% with good descriptions for all three parameters. The description does not add new parameter information beyond what the schema provides, so baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool searches YouTube globally for videos, channels, or playlists. It specifies the verb 'search' and the resource 'YouTube', and distinguishes from sibling 'search_channel_videos' by noting global scope.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly advises when to use this tool ('topic-based discovery when the user has not specified a channel') and when not to use it ('for searching within a known channel use search_channel_videos instead'). This is high-quality guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/SubDownload/subdownload-mcp'

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