Sponsored by Deepsite.site

YouTube MCP Server

Created By
Tisik799 months ago
A Media Control Protocol server for YouTube integration
Content

YouTube MCP Server

A Media Control Protocol (MCP) server for YouTube integration that allows you to control YouTube playback across multiple devices.

Features

  • Play, pause, and control YouTube videos from any device
  • Synchronize playback across multiple clients
  • Search YouTube videos directly from the interface
  • Control volume and playback position
  • Real-time updates using WebSockets
  • Simple and intuitive user interface

Installation

  1. Clone this repository:

    git clone https://github.com/Tisik79/youtube-mcp-server.git
    cd youtube-mcp-server
    
  2. Install dependencies:

    npm install
    
  3. Create a .env file based on the .env.example template:

    cp .env.example .env
    
  4. Edit the .env file and add your YouTube API key:

    YOUTUBE_API_KEY=your_youtube_api_key_here
    

    You can obtain a YouTube API key from the Google Cloud Console:

    • Create a new project
    • Enable the YouTube Data API v3
    • Create API credentials (API Key)

Usage

  1. Start the server:

    npm start
    
  2. For development with automatic restart:

    npm run dev
    
  3. Open your browser and navigate to:

    http://localhost:3000
    

How it Works

The YouTube MCP Server provides a central control point for YouTube playback across multiple devices. It uses:

  • Express.js for the HTTP server and API endpoints
  • Socket.io for real-time communication between clients
  • YouTube Data API for searching videos and fetching video information
  • YouTube IFrame API for controlling video playback

When a client connects to the server:

  1. They can search for videos using the search function
  2. Play videos on their device
  3. Control playback (play, pause, seek, volume)
  4. All commands are broadcasted to other connected clients
  5. Clients can sync with the current playback state

API Endpoints

  • GET /api/video/:videoId - Get video information
  • GET /api/search?q=query - Search for YouTube videos
  • GET /api/clients - Get a list of connected clients

WebSocket Events

Client to Server

  • play - Play a video
  • pause - Pause the current video
  • stop - Stop playback
  • seek - Seek to a specific position
  • volume - Change volume
  • mute - Mute/unmute audio
  • updateTimestamp - Update the current playback position

Server to Client

  • playerStateUpdate - Broadcast player state updates to all clients

Project Structure

youtube-mcp-server/
├── public/               # Client-side files
│   ├── index.html        # Main HTML file
│   ├── app.js            # Client-side JavaScript
│   └── styles.css        # CSS styles
├── server.js             # Main server file
├── package.json          # Dependencies and scripts
└── .env                  # Environment variables (create from .env.example)

Requirements

  • Node.js (v14 or higher)
  • npm (v6 or higher)
  • A YouTube Data API key

Customization

You can customize the server by:

  1. Modifying the UI in the public directory
  2. Adding additional API endpoints in server.js
  3. Extending the Socket.io event handlers for more functionality

Troubleshooting

Common issues:

  • API Key Error: Ensure your YouTube API key is correctly set in the .env file
  • Connection Issues: Make sure your firewall allows connections on the specified port
  • Video Playback Issues: Some videos may have embedding disabled by the owner

License

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

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
Serper MCP ServerA Serper MCP Server
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
WindsurfThe new purpose-built IDE to harness magic
ChatWiseThe second fastest AI chatbot™
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Tavily Mcp
Amap Maps高德地图官方 MCP Server
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
CursorThe AI Code Editor
DeepChatYour AI Partner on Desktop
Playwright McpPlaywright MCP server
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.