Skip to content

Add get_episode_info and list_recent_episodes tools#3

Open
jonathanmoore wants to merge 1 commit into
apple-podcastsfrom
episode-info
Open

Add get_episode_info and list_recent_episodes tools#3
jonathanmoore wants to merge 1 commit into
apple-podcastsfrom
episode-info

Conversation

@jonathanmoore
Copy link
Copy Markdown
Owner

Summary

Two new MCP tools that expand TLDL beyond "give me the transcript":

  • get_episode_info(url) — metadata-only response, no transcript. Useful when you want to confirm "is this the right episode?" or just reference an episode cheaply.
  • list_recent_episodes(url, limit=10) — discovery. Numbered markdown list of recent episodes/videos with titles, dates, durations.

Stacked PR: base is apple-podcasts (#1), since this builds on the iTunes Lookup infrastructure introduced there. GitHub will auto-retarget to main once #1 merges.

What's new

get_episode_info

Platform Source Fields
YouTube yt-dlp title, channel, duration, upload_date, description
Apple iTunes Lookup title, show, duration, release_date, description, audio_url
Spotify oEmbed title, show only — Spotify exposes no duration or release date publicly

list_recent_episodes

Platform Source Notes
Apple show URL iTunes Lookup Up to 200 most recent episodes; ?i= is ignored if present
YouTube channel/playlist yt-dlp extract_flat Bare channel URLs auto-resolve to /videos so you get videos instead of sub-tabs
Spotify n/a Returns a clear "not supported" error — Spotify has no public episodes API

limit is capped at 50.

Implementation

  • apple.py: factored out _itunes_fetch + _episode_to_info, refactored existing _itunes_lookup to share them, added fetch_apple_episode_info and list_apple_episodes
  • youtube.py: list_youtube_videos with bare-channel /videos auto-append; fetch_youtube_metadata now also returns description
  • spotify.py: fetch_spotify_episode_info (oEmbed-based)
  • markdown.py: render_episode_info and render_episode_list formatters reusing existing frontmatter helpers
  • server.py: registered both new @mcp.tool functions with cross-tool error helpers (e.g. show URL passed to get_episode_info gets a "use list_recent_episodes" message)

Test plan

Smoke-tested against the live local server:

  • get_episode_info on YouTube video → full metadata
  • get_episode_info on Apple episode (DOAC Christianity ep) → full metadata, 2:26:56 duration, release date, description
  • get_episode_info on Spotify episode → title + show only (limited as documented)
  • get_episode_info on Apple show URL (no ?i=) → clean "use list_recent_episodes" error
  • list_recent_episodes on Apple show (DOAC) → 5 recent episodes with dates and durations
  • list_recent_episodes on YouTube channel @LexClips → 3 recent videos (after /videos auto-append fix)
  • list_recent_episodes on YouTube video URL → clean "pass a channel URL" error
  • list_recent_episodes on Spotify URL → "not supported" message
  • get_transcript still works (regression check)
  • tools/list returns all three tools with descriptions

🤖 Generated with Claude Code

Two new MCP tools that expand TLDL beyond "give me the transcript":

- get_episode_info(url): returns markdown with metadata frontmatter and
  a description body, no transcript fetched. Useful for confirming an
  episode or referencing it cheaply. Works for YouTube (full metadata
  via yt-dlp), Apple (full metadata via iTunes Lookup), and Spotify
  (limited to title + show via oEmbed).

- list_recent_episodes(url, limit=10): returns a numbered markdown
  list of recent episodes/videos with titles, dates, and durations.
  Works for Apple show URLs (iTunes Lookup), YouTube channel and
  playlist URLs (yt-dlp). Bare YouTube channel URLs are auto-resolved
  to the /videos tab so we get actual videos instead of sub-tabs.
  Spotify show URLs return an explicit "not supported" error since
  Spotify has no public episodes API.

Implementation:
- apple.py: factored out _itunes_fetch and _episode_to_info helpers;
  refactored _itunes_lookup to use them; added fetch_apple_episode_info
  and list_apple_episodes
- youtube.py: added list_youtube_videos with bare-channel /videos
  auto-append; fetch_youtube_metadata now also returns description
- spotify.py: added fetch_spotify_episode_info (oEmbed-based)
- markdown.py: added render_episode_info and render_episode_list
  formatters that reuse the existing frontmatter helpers
- server.py: registered both new @mcp.tool functions; added URL-pattern
  helpers (_is_youtube_video_url, _is_apple_episode_url, _YOUTUBE_LISTABLE_RE)
  for clear cross-tool error messages

Smoke-tested all combinations:
- get_episode_info on YouTube/Apple/Spotify episodes (all return
  appropriate metadata)
- get_episode_info on Apple show URL → clean ToolError
- list_recent_episodes on Apple show URL → 5 recent DOAC episodes
- list_recent_episodes on YouTube channel @LexClips → 3 recent videos
- list_recent_episodes on YouTube video URL → clean ToolError
- list_recent_episodes on Spotify URL → "not supported" message
- get_transcript still works (regression check passed)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant