
🤗 Hugging Face MCP Server 🤗

2025.03.20
39
PythonAI 模型服务数据访问中间件开发效率
Hugging Face MCP Server 是一个基于 Model Context Protocol (MCP) 的服务,提供对 Hugging Face Hub API 的只读访问。该服务允许像 Claude 这样的 LLM 与 Hugging Face 的模型、数据集、空间、论文和集合进行交互。
View on GitHub
Overview
基本能力
产品定位
Hugging Face MCP Server 是一个中间件服务,旨在为大型语言模型(如 Claude)提供便捷的 Hugging Face Hub 资源访问能力。
核心功能
- 提供对 Hugging Face 多种资源的访问:
- 模型(Models)
- 数据集(Datasets)
- 空间(Spaces)
- 论文(Papers)
- 集合(Collections)
- 支持自定义
hf://
URI 方案访问资源 - 提供两种提示模板:
compare-models
:比较多个 Hugging Face 模型summarize-paper
:总结研究论文- 实现多种工具类别:
- 模型工具(搜索模型、获取模型信息)
- 数据集工具(搜索数据集、获取数据集信息)
- 空间工具(搜索空间、获取空间信息)
- 论文工具(获取论文信息、获取每日论文)
- 集合工具(搜索集合、获取集合信息)
适用场景
- 需要让 LLM 访问 Hugging Face 资源的应用场景
- 需要比较不同模型性能的研究工作
- 需要快速获取和总结 AI 研究论文的场景
- 需要批量处理 Hugging Face 资源的自动化任务
工具列表
- Model Tools
search-models
: 根据查询、作者、标签等条件搜索模型get-model-info
: 获取特定模型的详细信息- Dataset Tools
search-datasets
: 搜索数据集get-dataset-info
: 获取特定数据集的详细信息- Space Tools
search-spaces
: 搜索空间,包括 SDK 类型过滤get-space-info
: 获取特定空间的详细信息- Paper Tools
get-paper-info
: 获取论文及其实现的信息get-daily-papers
: 获取每日精选论文列表- Collection Tools
search-collections
: 搜索集合get-collection-info
: 获取特定集合的详细信息
常见问题解答
- API 速率限制问题:考虑添加 Hugging Face API 令牌
- 连接问题:确保机器可以访问 Hugging Face API
- 特定工具失败:尝试通过 Hugging Face 网站验证数据是否存在
- 日志位置:
- macOS:
~/Library/Logs/Claude/mcp-server-huggingface.log
- Windows:
%APPDATA%\Claude\logs\mcp-server-huggingface.log
使用教程
使用依赖
- 需要安装 Node.js 和 npm
- 可选:Hugging Face API 令牌(用于提高 API 速率限制)
安装教程
通过 Smithery 安装
npx -y @smithery/cli install @shreyaskarnik/huggingface-mcp-server --client claude
手动配置(开发/未发布服务器)
"mcpServers": {
"huggingface": {
"command": "uv",
"args": [
"--directory",
"/absolute/path/to/huggingface-mcp-server",
"run",
"huggingface_mcp_server.py"
],
"env": {
"HF_TOKEN": "your_token_here" // 可选
}
}
}
调试方式
使用 MCP Inspector 进行调试:
npx @modelcontextprotocol/inspector uv --directory /path/to/huggingface-mcp-server run huggingface_mcp_server.py
示例提示
- "Search for BERT models on Hugging Face with less than 100 million parameters"
- "Find the most popular datasets for text classification on Hugging Face"
- "What are today's featured AI research papers on Hugging Face?"
- "Summarize the paper with arXiv ID 2307.09288 using the Hugging Face MCP server"
- "Compare the Llama-3-8B and Mistral-7B models from Hugging Face"
- "Show me the most popular Gradio spaces for image generation"
- "Find collections created by TheBloke that include Mixtral models"