ytmcp

ytmcp

Enables AI assistants to fetch YouTube video transcripts with precise timestamps, multi-language support, and time-range filtering.

Category
访问服务器

README

YTMcp - YouTube Transcript MCP Server

PyPI version Python Support License: MIT

A Model Context Protocol (MCP) server that enables AI assistants like Claude to fetch YouTube video transcripts with precise timestamps. Built on top of the excellent youtube-transcript-api by @jdepoix.

🎯 Features

  • 🎥 Fetch YouTube transcripts with start/end timestamps
  • 🌍 Multi-language support with automatic fallback
  • ⏱️ Time-range filtering for specific video segments
  • 📋 List available languages for any video
  • 🔍 Smart URL parsing - works with any YouTube URL format
  • 🤖 MCP compatible - works with Claude Desktop and other MCP clients
  • 🚀 Zero external dependencies - bundled with transcript API
  • 🛡️ Comprehensive error handling for robust operation

📦 Installation

pip install ytmcp

🚀 Quick Start

1. Run as MCP Server

ytmcp

The server will start and listen for MCP requests via stdio.

2. Configure with Claude Desktop

Add to your Claude Desktop configuration file:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "youtube-transcript": {
      "command": "ytmcp"
    }
  }
}

3. Test Installation

# Test the server functionality
ytmcp --test

# Test with a specific video
ytmcp --test --video-id dQw4w9WgXcQ

# Check version
ytmcp --version

4. Use with Claude

Once configured, you can ask Claude natural language questions like:

  • "Get the transcript for this YouTube video: https://www.youtube.com/watch?v=dQw4w9WgXcQ"
  • "What transcript languages are available for this video?"
  • "Get me the transcript from 2:30 to 5:00 in this video"
  • "Summarize the key points from this YouTube video's transcript"

🛠️ Available Tools

get_transcript

Fetch complete video transcript with timestamps.

Parameters:

  • video_url_or_id (required): YouTube URL or video ID
  • languages (optional): Array of language codes in priority order (default: ["en"])
  • preserve_formatting (optional): Keep HTML formatting (default: false)
  • include_timestamps (optional): Include start/end times (default: true)

Example Usage:

{
  "name": "get_transcript",
  "arguments": {
    "video_url_or_id": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
    "languages": ["en", "es"],
    "include_timestamps": true
  }
}

Example Response:

{
  "video_id": "dQw4w9WgXcQ",
  "language": "English",
  "language_code": "en",
  "is_generated": true,
  "transcript_count": 142,
  "transcript": [
    {
      "text": "We're no strangers to love",
      "start": 15.5,
      "duration": 2.3,
      "end": 17.8
    },
    {
      "text": "You know the rules and so do I",
      "start": 17.8,
      "duration": 2.1,
      "end": 19.9
    }
  ]
}

list_available_transcripts

List all available transcript languages for a video.

Parameters:

  • video_url_or_id (required): YouTube URL or video ID

Example Usage:

{
  "name": "list_available_transcripts",
  "arguments": {
    "video_url_or_id": "dQw4w9WgXcQ"
  }
}

Example Response:

{
  "video_id": "dQw4w9WgXcQ",
  "manually_created_transcripts": [
    {
      "language": "English",
      "language_code": "en",
      "is_translatable": true
    }
  ],
  "auto_generated_transcripts": [
    {
      "language": "English (auto-generated)",
      "language_code": "en",
      "is_translatable": true
    }
  ],
  "total_transcripts": 2
}

get_transcript_with_time_range

Get transcript for specific time range.

Parameters:

  • video_url_or_id (required): YouTube URL or video ID
  • start_time (required): Start time in seconds
  • end_time (required): End time in seconds
  • languages (optional): Language preferences (default: ["en"])
  • preserve_formatting (optional): Keep HTML formatting (default: false)

Example Usage:

{
  "name": "get_transcript_with_time_range",
  "arguments": {
    "video_url_or_id": "dQw4w9WgXcQ",
    "start_time": 30.0,
    "end_time": 90.0,
    "languages": ["en"]
  }
}

Example Response:

{
  "video_id": "dQw4w9WgXcQ",
  "language": "English",
  "language_code": "en",
  "is_generated": true,
  "time_range": {
    "start": 30.0,
    "end": 90.0
  },
  "filtered_transcript": [
    {
      "text": "Never gonna give you up",
      "start": 32.1,
      "duration": 1.8,
      "end": 33.9
    }
  ],
  "snippet_count": 15
}

🔧 Configuration Options

Language Codes

YTMcp supports all language codes that YouTube provides. Common ones include:

  • en - English
  • es - Spanish
  • fr - French
  • de - German
  • it - Italian
  • pt - Portuguese
  • ru - Russian
  • ja - Japanese
  • ko - Korean
  • zh - Chinese

URL Format Support

YTMcp automatically extracts video IDs from various YouTube URL formats:

  • https://www.youtube.com/watch?v=VIDEO_ID
  • https://youtu.be/VIDEO_ID
  • https://www.youtube.com/embed/VIDEO_ID
  • https://www.youtube.com/watch?v=VIDEO_ID&t=120s
  • Or just the video ID directly: VIDEO_ID

⚠️ Error Handling

YTMcp provides comprehensive error handling for various scenarios:

Common Error Types

  • Invalid Video ID: Invalid URL or video ID format
  • No Transcript Found: No transcripts available in requested languages
  • Transcripts Disabled: Video has disabled subtitles/captions
  • Video Unavailable: Video is private, deleted, or restricted
  • Request Blocked: IP blocked by YouTube (consider using proxies)
  • Age Restricted: Video requires authentication

Error Response Format

{
  "content": [
    {
      "type": "text",
      "text": "Error: No transcript found for languages: ['de']"
    }
  ]
}

🔄 Advanced Usage

Running as Python Module

python -m ytmcp

Development Mode

# Install in development mode
pip install -e .

# Run tests
ytmcp --test

# Test with verbose output
ytmcp --test --video-id dQw4w9WgXcQ

Proxy Support

If you encounter IP blocking issues, you can extend the server by modifying the YouTube API configuration to use proxies. See the youtube-transcript-api documentation for proxy configuration options.

📚 Use Cases

Content Analysis

  • Video Summarization: Extract transcripts for AI-powered summaries
  • Content Research: Analyze video content programmatically
  • Educational Tools: Create study materials from lecture videos

Accessibility

  • Transcript Generation: Provide text alternatives for video content
  • Translation: Use with translation APIs for multilingual access
  • Search & Discovery: Make video content searchable

Development

  • API Integration: Embed transcript functionality in applications
  • Data Pipeline: Process video transcripts in bulk
  • AI Training: Use transcripts as training data

🐛 Troubleshooting

Installation Issues

# If you get import errors
pip install --upgrade ytmcp

# If command not found
pip install --force-reinstall ytmcp

# Check installation
ytmcp --version

Common Problems

1. Video Not Found

  • Verify the video ID/URL is correct
  • Check if the video is public and available
  • Ensure the video has captions enabled

2. Language Not Available

  • Use list_available_transcripts to see available languages
  • Try fallback languages like ["en", "auto"]
  • Some videos only have auto-generated transcripts

3. Rate Limiting

  • YouTube may temporarily block requests from your IP
  • Consider using proxy configuration for high-volume usage
  • Space out your requests to avoid hitting rate limits

4. Permission Errors

  • Check file permissions if running on Unix systems
  • Ensure Python has permission to execute the script
  • Try running with appropriate user privileges

🤝 Contributing

We welcome contributions! Here's how you can help:

Development Setup

git clone https://github.com/shubhamshnd/ytmcp.git
cd ytmcp
pip install -e ".[dev]"

Running Tests

pytest tests/

Code Style

black ytmcp/
flake8 ytmcp/
mypy ytmcp/

Submitting Changes

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Credits

This project is built on top of the excellent youtube-transcript-api by @jdepoix. All core transcript fetching functionality is provided by this library.

Key Dependencies:

🔗 Related Projects

📞 Support

🚀 Roadmap

  • [ ] Translation Support: Automatic transcript translation
  • [ ] Batch Processing: Handle multiple videos simultaneously
  • [ ] Caching: Cache transcripts for improved performance
  • [ ] WebSocket Support: Real-time transcript streaming
  • [ ] Export Formats: SRT, VTT, and other subtitle formats
  • [ ] Search: Full-text search within transcripts
  • [ ] Webhooks: Notification system for transcript updates

Made with ❤️ for the MCP and AI community

If you find this project useful, please consider giving it a ⭐ on GitHub!

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选