使用说明
Youtube MCP服务器
关于
该服务器是Youtube API和人工智能助手之间的桥梁,基于 模型上下文协议.
什么是MCP?
模型上下文协议(MCP)是一个允许人工智能应用程序(如Claude Desktop)连接到外部工具和数据源的系统。它为AI助手提供了一种清晰安全的方式来使用本地服务和API,同时让用户保持控制。
这个服务器做什么?
- [x] 下载给定视频的隐藏字幕
实际使用案例
- [x] 创建视频摘要
先决条件
安装
uv tool install git+https://github.com/sparfenyuk/mcp-youtube
[!注意] 如果您已经安装了服务器,可以使用以下命令进行更新
uv tool upgrade --reinstall命令。
[!注意] 如果要删除服务器,请使用
uv tool uninstall mcp-youtube命令。
配置
Claude桌面配置
配置Claude Desktop以识别Youtube MCP服务器。
-
打开Claude Desktop配置文件:
- 在MacOS中,配置文件位于
~/Library/Application Support/Claude/claude_desktop_config.json - 在Windows中,配置文件位于
%APPDATA%\Claude\claude_desktop_config.json
注: 您还可以在claude desktop应用程序的设置中找到claude_desktop_config.json
- 在MacOS中,配置文件位于
-
添加服务器配置
{ "mcpServers": { "mcp-youtube": { "command": "mcp-youtube", } } } }
发展
入门
-
克隆存储库
-
安装依赖项
uv sync -
运行服务器
uv run mcp-youtube --help
工具可以添加到 src/mcp_youtube/tools.py 文件。
如何添加新工具:
-
创建一个继承自ToolArgs的新类
class NewTool(ToolArgs): """Description of the new tool.""" pass类的属性将用作工具的参数。 类docstring将用作工具描述。
-
为新类实现tool_runner函数
@tool_runner.register async def new_tool(args: NewTool) -> t.Sequence[TextContent | ImageContent | EmbeddedResource]: pass该函数应返回TextContent、ImageContent或EmbeddedResource的序列。 该函数应该是异步的,并接受新类的单个参数。
-
完成!重新启动客户端,新工具应该可用。
验证可以通过Claude Desktop或直接运行该工具来完成。
在检查器中调试服务器
MCP检查器是一个使用花哨的UI帮助调试服务器的工具。要运行它,请使用以下命令:
npx @modelcontextprotocol/inspector uv run mcp-youtube
故障排除
消息“无法连接到MCP服务器MCP youtube”
如果您在Claude Desktop中看到消息“无法连接到MCP服务器MCP youtube”,则表示服务器配置不正确。
尝试以下操作:
- 使用完整路径
mcp-youtube配置文件中的二进制文件