Skip to main content
Glama

get_content

Retrieve detailed metadata for Khan Academy educational content including videos, articles, and exercises by providing a slug or URL.

Instructions

Get details about a specific Khan Academy content item (video, article, or exercise). Accepts a slug or full URL. Returns title, description, type, and metadata.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
slugYesContent slug or full URL (e.g., 'math/algebra/v/intro-to-algebra', 'https://www.khanacademy.org/science/biology/a/intro-to-biology')

Implementation Reference

  • The async handler function that executes the get_content tool logic. It calls client.getContent(slug), handles not-found cases, and formats the response with title, type, URL, description, duration, YouTube link, authors, and date.
    async ({ slug }) => {
      try {
        const content = await client.getContent(slug);
    
        if (!content) {
          return {
            content: [
              {
                type: "text" as const,
                text: `Content not found for "${slug}". Check the slug/URL and try again. Use \`search\` to find content.`,
              },
            ],
          };
        }
    
        let text = `## ${content.title}\n`;
        text += `**Type:** ${content.kind}\n`;
        text += `**URL:** ${content.kaUrl}\n`;
    
        if (content.description) {
          text += `\n${content.description}\n`;
        }
    
        if (content.duration) {
          text += `\n**Duration:** ${formatDuration(content.duration)}\n`;
        }
    
        if (content.youtubeId) {
          text += `**YouTube:** https://www.youtube.com/watch?v=${content.youtubeId}\n`;
          text += `\n*Use \`get_transcript\` with this slug to get the video transcript.*\n`;
        }
    
        if (content.authorNames?.length) {
          text += `**Authors:** ${content.authorNames.join(", ")}\n`;
        }
    
        if (content.dateAdded) {
          text += `**Date Added:** ${content.dateAdded}\n`;
        }
    
        return {
          content: [{ type: "text" as const, text }],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text" as const,
              text: `Error fetching content: ${error instanceof Error ? error.message : "Unknown error"}`,
            },
          ],
          isError: true,
        };
      }
    }
  • Zod schema defining the 'slug' input parameter for get_content tool. Accepts a string that can be a content slug or full URL.
    slug: z
      .string()
      .describe(
        "Content slug or full URL (e.g., 'math/algebra/v/intro-to-algebra', 'https://www.khanacademy.org/science/biology/a/intro-to-biology')"
      ),
  • Registration of the get_content tool with the MCP server using server.tool(). Includes tool name, description, input schema, and handler function.
    server.tool(
      "get_content",
      "Get details about a specific Khan Academy content item (video, article, or exercise). Accepts a slug or full URL. Returns title, description, type, and metadata.",
      {
        slug: z
          .string()
          .describe(
            "Content slug or full URL (e.g., 'math/algebra/v/intro-to-algebra', 'https://www.khanacademy.org/science/biology/a/intro-to-biology')"
          ),
      },
      async ({ slug }) => {
        try {
          const content = await client.getContent(slug);
    
          if (!content) {
            return {
              content: [
                {
                  type: "text" as const,
                  text: `Content not found for "${slug}". Check the slug/URL and try again. Use \`search\` to find content.`,
                },
              ],
            };
          }
    
          let text = `## ${content.title}\n`;
          text += `**Type:** ${content.kind}\n`;
          text += `**URL:** ${content.kaUrl}\n`;
    
          if (content.description) {
            text += `\n${content.description}\n`;
          }
    
          if (content.duration) {
            text += `\n**Duration:** ${formatDuration(content.duration)}\n`;
          }
    
          if (content.youtubeId) {
            text += `**YouTube:** https://www.youtube.com/watch?v=${content.youtubeId}\n`;
            text += `\n*Use \`get_transcript\` with this slug to get the video transcript.*\n`;
          }
    
          if (content.authorNames?.length) {
            text += `**Authors:** ${content.authorNames.join(", ")}\n`;
          }
    
          if (content.dateAdded) {
            text += `**Date Added:** ${content.dateAdded}\n`;
          }
    
          return {
            content: [{ type: "text" as const, text }],
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text" as const,
                text: `Error fetching content: ${error instanceof Error ? error.message : "Unknown error"}`,
              },
            ],
            isError: true,
          };
        }
      }
    );
  • TypeScript interface defining KhanContent - the return type for get_content. Contains id, slug, title, kind, url, description, thumbnailUrl, youtubeId, duration, articleContent, exerciseLength, authorNames, dateAdded, and kaUrl fields.
    export interface KhanContent {
      id: string;
      slug: string;
      title: string;
      kind: ContentKind;
      url: string;
      description: string;
      thumbnailUrl?: string;
      // Video-specific
      youtubeId?: string;
      duration?: number;
      // Article-specific
      articleContent?: string;
      // Exercise-specific
      exerciseLength?: number;
      // Common
      authorNames?: string[];
      dateAdded?: string;
      kaUrl: string;
    }
  • The underlying getContent method in KhanClient that fetches content data. Normalizes the slug, checks cache, queries the API via contentForPath(), constructs KhanContent objects, and falls back to scraping if needed.
    async getContent(slugOrUrl: string): Promise<KhanContent | null> {
      const slug = normalizeSlug(slugOrUrl);
      const cacheKey = `content:${slug}`;
      const cached = this.cache.get<KhanContent>(cacheKey);
      if (cached) return cached;
    
      try {
        const result = await this.contentForPath(slug);
    
        if (result?.content) {
          const raw = result.content;
          const content: KhanContent = {
            id: raw.id ?? slug,
            slug: raw.slug ?? raw.nodeSlug ?? slug,
            title: raw.translatedTitle ?? slug,
            kind: (raw.contentKind as ContentKind) ?? detectContentKind(raw.relativeUrl ?? slug),
            url: buildKAUrl(raw.relativeUrl ?? raw.kaUrl ?? slug),
            description: raw.translatedDescription ?? raw.description ?? "",
            thumbnailUrl: raw.imageUrl,
            youtubeId: raw.youtubeId,
            duration: raw.duration,
            authorNames: raw.authorNames,
            dateAdded: raw.dateAdded,
            kaUrl: raw.kaUrl ?? buildKAUrl(raw.relativeUrl ?? slug),
          };
          this.cache.set(cacheKey, content, CACHE_TTL);
          return content;
        }
    
        // If it's a course, return basic info
        if (result?.course) {
          const c = result.course;
          const content: KhanContent = {
            id: c.id ?? slug,
            slug: c.slug ?? slug,
            title: c.translatedTitle ?? slug,
            kind: "Unknown",
            url: buildKAUrl(c.relativeUrl ?? slug),
            description: c.translatedDescription ?? "",
            thumbnailUrl: c.iconPath,
            kaUrl: buildKAUrl(c.relativeUrl ?? slug),
          };
          this.cache.set(cacheKey, content, CACHE_TTL);
          return content;
        }
      } catch {
        // Fall through
      }
    
      // Fallback: scrape
      return await this.scrapeContentPage(slug);
    }
Behavior3/5

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

With no annotations provided, the description carries the full burden. It discloses the tool's behavior by stating it 'Returns title, description, type, and metadata,' which adds value beyond the input schema. However, it doesn't mention potential limitations like rate limits, authentication needs, or error conditions, leaving gaps for a read operation.

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?

The description is appropriately sized and front-loaded, with two sentences that efficiently convey purpose, input, and output. Every sentence earns its place: the first specifies the action and resource, the second covers input format and return values, with no wasted words.

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?

Given the tool's low complexity (single parameter, no output schema, no annotations), the description is mostly complete. It covers purpose, input, and return values. However, without annotations or output schema, it could benefit from more behavioral context (e.g., error handling). The absence of an output schema means the description must explain returns, which it does adequately.

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?

The input schema has 100% description coverage, with the slug parameter well-documented in the schema itself (including examples). The description adds minimal value by repeating that it 'Accepts a slug or full URL,' which is already covered in the schema. Baseline 3 is appropriate as the schema does the heavy lifting.

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 verb ('Get details') and resource ('specific Khan Academy content item') with specific examples of item types (video, article, exercise). It distinguishes from siblings like get_course (course-level), get_topic_tree (hierarchical), get_transcript (transcript-specific), list_subjects (listing), and search (broad search).

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

Usage Guidelines3/5

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

The description implies usage by specifying it's for 'a specific Khan Academy content item' and mentions alternatives like slug or URL, but doesn't explicitly state when to use this vs. siblings like get_course (for course-level details) or search (for broader queries). No explicit exclusions or when-not guidance is provided.

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/aicoder2009/khanacademyMCP'

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