MCP Youtube

I added a Model Context Protocol (MCP) module that can be integrated to your Claude Code, or any LLM. MCPs integrate experiences and content with Large Language Models, any model that you can run and execute is compative with the MCP specification. In my case I am using Llama.cpp running a model in a dual spark DGX system, the models are Qwen3-thinking (Qwen3-235B-IQ3_M, quantized model), Qwen3-coder, Gemma4 or any other models.

On Github at https://github.com/win2013/MCP-Youtube 

…..  But the user’s question is straightforward: “When was the last update for MCP specification”. Since I don’t have context on what MCP stands for, the best approach is to use a web search to find the latest update date.

So, using web_search_exa with a query like “MCP specification latest update date” or “most recent MCP specification release”. Let’s craft the query as “latest update date for MCP specification” to get current info.

Wait, the web_search_exa description says to use natural language describing the ideal page. So maybe “official MCP specification latest update date” or “when was the MCP specification last updated”.

Let me call web_search_exa with query: “MCP specification latest update date” to find recent information.

Based on the search results, the latest official update for the Model Context Protocol (MCP) specification is version 2026-07-28, announced in a blog post by the project maintainers.

Key Details:

  • Release Date: July 28, 2026 (as per the specification versioning scheme)
  • Changes: This version replaces the prior release (2025-11-25) and includes updates documented in the changelog.
  • SDK Support: All four Tier 1 SDKs are compatible with this version as of the release date.

How will you use an MCP Server on an LLM

In general the use case is:

Key Components

  • FastMCP Framework: Core server with JSON-RPC handling
  • CORS Middleware: Enables cross-origin requests from Llama.cpp WebUI
  • Envelope Middleware: Handles Llama.cpp envelope format compatibility
  • YouTubeClient: YouTube API integration with error handling
  • Multiple Transports: HTTP, SSE, and STDIO support

Request Flow

The document details the complete request flow from client → HTTP server → CORS → Envelope → FastMCP → Tool Handler → YouTubeClient → External APIs → Response.

Configuration & Environment

  • .env.example – Template for YouTube API key configuration
  • .env_yt – Actual configuration (git-ignored)
  • Environment variables for API keys, ports, and loggin

Summary of Challenges Making This MCP Server with YouTube

Based on the codebase and documentation, here are the key challenges encountered:

1. YouTube API Authentication & Configuration

  • Challenge: Securing YouTube API keys without committing them to Git
  • Solution: Created .env.example as a template with placeholder values
  • Status .env_yt is properly git-ignored – Run conda or Python -m venv env_yt if needed. 
  • Files.env.example.env_yt.gitignore

2. CORS (Cross-Origin Resource Sharing) Issues

  • Challenge: Browser blocking requests due to missing CORS headers from Llama.cpp
  • ErrorHTTP POST http://192.168.1.125:9091/mcp failed: Failed to fetch (check CORS?)
  • Solution: Added CORS middleware to FastMCP/FastAPI app
  • Configuration:cors_middleware = [ Middleware( CORSMiddleware, allow_origins=["*"], allow_credentials=True, allow_methods=["GET", "POST", "OPTIONS", "DELETE"], allow_headers=["Content-Type", "Authorization", "mcp-protocol-version", ...], ) ]

3. Llama.cpp  Format Compatibility

  • Challenge: Llama.cpp sends MCP requests in an envelope format that FastMCP needs to process
  • Issue: Missing body.value field in Llama.cpp envelope format
  • Solution: Created EnvelopeMiddleware to extract the JSON-RPC request from the envelope
  • Status: Middleware needs to be properly applied to the FastMCP app

4. HTTP Transport Header Compatibility

  • Challenge: FastMCP’s streamable HTTP transport has strict Accept header requirements
  • Issue: Server rejected requests with application/json, text/event-stream headers
  • Solution: Patched _check_accept_headers function to accept both content types
  • Code:# Patch to accept json, event-stream, or both streamable_http_module.StreamableHTTPServerTransport._check_accept_headers = patched_check_accept_headers

5. YouTube API Integration

  • Challenge: YouTube Data API v3 requires proper authentication
  • Implementation:
    • Uses google-api-python-client library
    • Extracts video IDs from various URL formats
    • Fetches video details, transcripts, and similar videos
  • Key Methods:
    • get_video_details()
    • get_transcript()
    • get_similar_videos()
    • search_videos()

Server Deployment & Restart

  • Challenge: Code changes need to be deployed and server restarted
  • Solution: Documentation for SSH deployment and service restart
  • Commandskill <PID> or sudo systemctl restart mcp-server

Request Timeouts

  • Challenge: Requests may hang indefinitely
  • Solution: Added --max-time 30 to curl commands
  • Importance: Prevents hanging requests to external services

Multiple Transport Methods

  • Challenge: Supporting TCP, STDIO, and SSE transports
  • Solution: Implemented run_all_transports() function that spawns multiple processes
  • Transport Types:
    • streamable-http (default for HTTP requests)
    • sse (Server-Sent Events)
    • stdio (Standard Input/Output)

Environment Configuration

  • Challenge: Managing different environments (local, server)
  • Environment Variables:
    • YOUTUBE_API_KEY (required)
    • MCP_PORT (default: 9090)
    • MCP_TOKEN_KEY (auto-generated)
    • LOG_LEVEL (default: INFO)

Would you like me to work on any specific challenge, such as:

  1. Testing the CORS configuration
  2. Verifying the envelope middleware works
  3. Setting up proper deployment documentation
    Total iterations: 8