The YouTube MCP Server provides a powerful interface for searching YouTube videos, retrieving transcripts, and performing semantic search over video content through the Model Context Protocol. This server integrates with MCP-compatible clients, enabling AI assistants to interact with YouTube content.
Clone the repository
Create and activate a virtual environment using uv:
uv venv
# On Windows:
.venv\Scripts\activate
# On Unix/MacOS:
source .venv/bin/activate
Install dependencies:
uv pip install -r requirements.txt
Create a .env
file with your Google API key:
GOOGLE_API_KEY=your_api_key_here
You can run the MCP server in two different ways:
Start the server directly from the command line:
uv run python server.py
For Windows without package manager:
"mcpServers": {
"youtube": {
"command": "C:\\Path\\To\\Your\\Project\\.venv\\Scripts\\python.exe",
"args": ["C:\\Path\\To\\Your\\Project\\server.py"],
"env": {
"GOOGLE_API_KEY": "your_api_key_here"
}
}
}
For Windows with Uv package manager:
"mcpServers": {
"youtube": {
"command": "uv",
"args": ["--directory", "C:\\Path\\To\\Your\\Project", "run", "server.py"],
"env": {
"GOOGLE_API_KEY": "your_api_key_here"
}
}
}
The server provides four main tools:
Search for videos based on a query:
query
: Search query stringmax_results
: Maximum number of results (default: 5)Retrieve a video's transcript:
video_url
: URL of the YouTube videoSave video information and transcript in the vector database:
video_url
: URL of the YouTube videometadata
: Optional metadata about the videoPerform semantic search over stored video transcripts:
query
: Search querylimit
: Maximum number of results (default: 3)Connect the server with any MCP-compatible client, such as Claude Desktop App:
If you encounter issues:
.env
fileTo add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "youtube" '{"command":"uv","args":["--directory","C:\\Path\\To\\Your\\Project","run","server.py"],"env":{"GOOGLE_API_KEY":"your_api_key_here"}}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"youtube": {
"command": "uv",
"args": [
"--directory",
"C:\\Path\\To\\Your\\Project",
"run",
"server.py"
],
"env": {
"GOOGLE_API_KEY": "your_api_key_here"
}
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"youtube": {
"command": "uv",
"args": [
"--directory",
"C:\\Path\\To\\Your\\Project",
"run",
"server.py"
],
"env": {
"GOOGLE_API_KEY": "your_api_key_here"
}
}
}
}
3. Restart Claude Desktop for the changes to take effect