Skip to main content
Glama
YouTube Transcript to Markdown MCP Server

YouTube Transcript to Markdown MCP Server

by ncockram

YouTube Transcript to Markdown MCP Server

An MCP (Model Context Protocol) server that converts YouTube video transcripts to Markdown format using the youtube-transcript-api Python package.

Features

  • Extract transcripts from YouTube videos

  • Convert transcripts to well-formatted Markdown

  • Include video metadata (title, URL) in output

  • Support multiple YouTube URL formats

  • Comprehensive error handling

  • MCP tool integration

Related MCP server: YouTube Transcript MCP Server

Installation

Prerequisites

  • Python 3.9 or higher

  • pip package manager

Install from Source

  1. Clone this repository:

git clone <repository-url>
cd youtube-transcript-to-markdown-mcp
  1. Create and activate a virtual environment (recommended):

python -m venv venv
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate
  1. Install dependencies:

pip install -r requirements.txt

Or install in development mode with test dependencies:

pip install -e ".[dev]"

Quick Test

To quickly test the installation and basic functionality, you can run the test implementation (if available in your workspace):

python test_implementation.py

Or use the VS Code task if available.

MCP Integration

This server implements the Model Context Protocol (MCP) and can be used with any MCP-compatible client. The server runs using stdio transport for communication.

Adding to MCP Client Configuration

To use this server with an MCP client, add it to your client's configuration:

{
  "mcpServers": {
    "youtube-transcript": {
      "command": "youtube-transcript-mcp",
      "args": []
    }
  }
}

For development or if installed from source:

{
  "mcpServers": {
    "youtube-transcript": {
      "command": "python",
      "args": ["-m", "youtube_transcript_mcp.server"]
    }
  }
}

Usage

As MCP Server

The server provides a get_youtube_transcript tool that can be called by MCP clients.

Tool Schema

{
  "name": "get_youtube_transcript",
  "description": "Extract transcript from YouTube video and save as Markdown file",
  "inputSchema": {
    "type": "object",
    "properties": {
      "youtube_url": {
        "type": "string",
        "description": "YouTube video URL (supports various formats like youtube.com/watch?v=ID or youtu.be/ID)"
      },
      "output_filename": {
        "type": "string",
        "description": "Local filename to save the Markdown transcript (will be sanitized and .md extension added if missing)"
      }
    },
    "required": ["youtube_url", "output_filename"]
  }
}

Example Usage

{
  "youtube_url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
  "output_filename": "transcript.md"
}

Running the Server

youtube-transcript-mcp

Or run directly:

python -m youtube_transcript_mcp.server

Configuration

The server supports the following command-line options:

  • --debug: Enable debug logging

  • --transport: Transport type (default: stdio)

Example:

youtube-transcript-mcp --debug

Supported YouTube URL Formats

  • https://www.youtube.com/watch?v=VIDEO_ID

  • https://youtu.be/VIDEO_ID

  • https://youtube.com/watch?v=VIDEO_ID

  • https://m.youtube.com/watch?v=VIDEO_ID

Output Format

The generated Markdown file includes:

  1. Video title as main header

  2. Video metadata block with URL, video ID, and generation timestamp

  3. Formatted transcript content with timestamps (if available)

  4. Generator attribution

Example output:

# Video Title Here

> **Video URL:** https://www.youtube.com/watch?v=VIDEO_ID  
> **Video ID:** `VIDEO_ID`  
> **Generated:** 2025-07-20 10:30:45

---

## 📝 Transcript

[00:00] First line of transcript...
[00:05] Second line of transcript...

---

> *This transcript was generated using the YouTube Transcript to Markdown MCP Server.*

Error Handling

The server handles various error scenarios:

  • Invalid YouTube URLs

  • Videos without available transcripts

  • Private or unavailable videos

  • Network connectivity issues

  • File system permission errors

Development

Running Tests

Run the test suite:

pytest

Run tests with coverage:

pytest --cov=youtube_transcript_mcp

Run a specific test file:

pytest tests/test_transcript_extractor.py

Code Formatting

Format code with Black:

black src/ tests/

Sort imports with isort:

isort src/ tests/

Type Checking

mypy src/

Project Structure

youtube-transcript-to-markdown-mcp/
├── src/
│   └── youtube_transcript_mcp/
│       ├── __init__.py                 # Package initialization
│       ├── server.py                   # MCP server implementation
│       ├── transcript_extractor.py     # YouTube transcript extraction
│       ├── markdown_generator.py       # Markdown formatting
│       └── utils.py                    # Utility functions
├── tests/                              # Test suite
├── pyproject.toml                      # Project configuration
├── requirements.txt                    # Dependencies
└── README.md                          # This file

Dependencies

  • mcp: Model Context Protocol Python SDK

  • youtube-transcript-api: YouTube transcript extraction

  • pydantic: Data validation and settings management

  • typing-extensions: Type hint extensions

License

MIT License - see LICENSE file for details.

Contributing

  1. Fork the repository

  2. Create a feature branch

  3. Make your changes

  4. Add tests for new functionality

  5. Ensure all tests pass

  6. Submit a pull request

Troubleshooting

Common Issues

  1. "No transcript available": Some videos don't have transcripts, they may be disabled, or only auto-generated captions are available

  2. "Video not found": The URL may be invalid, the video may be private/deleted, or region-restricted

  3. Permission errors: Ensure you have write permissions to the output directory

  4. Import errors: Make sure all dependencies are installed and you're using Python 3.9+

  5. MCP connection issues: Verify the server is running and the MCP client configuration is correct

Debug Mode

Enable debug logging to get more detailed error information:

youtube-transcript-mcp --debug

Support

For issues and questions, please open an issue on the GitHub repository.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers