MCP HubMCP Hub
shreyaskarnik

huggingface-mcp-server

by: shreyaskarnik

huggingface mcp server

38created 19/03/2025
Visit
huggingface
AI

📌Overview

Purpose: The Hugging Face MCP Server offers a protocol for read-only access to the Hugging Face Hub APIs, enabling LLMs to efficiently interact with Hugging Face's extensive range of models, datasets, spaces, papers, and collections.

Overview: This server simplifies access to Hugging Face resources utilizing a custom URI scheme. It is designed for enhanced interaction with models and data through various tools and prompt templates, allowing users to effectively manage and analyze AI resources.

Key Features:

  • Resource Access: Utilizes a custom hf:// URI scheme to access models, datasets, spaces, and collections with descriptive naming and JSON content type, facilitating straightforward resource identification.

  • Prompt Templates: Offers templates like compare-models for model comparisons and summarize-paper for paper summaries, streamlining the analysis and retrieval of insights from various Hugging Face resources.


🤗 Hugging Face MCP Server 🤗

A Model Context Protocol (MCP) server that provides read-only access to the Hugging Face Hub APIs. This server allows LLMs like Claude to interact with Hugging Face's models, datasets, spaces, papers, and collections.

Components

Resources

The server exposes popular Hugging Face resources with a custom hf:// URI scheme:

  • Models: hf://model/{model_id}
  • Datasets: hf://dataset/{dataset_id}
  • Spaces: hf://space/{space_id}

Prompts

Two prompt templates are provided:

  • compare-models: Compares multiple Hugging Face models.

    • Argument: model_ids (comma-separated model IDs)
  • summarize-paper: Summarizes a research paper.

    • Argument: arxiv_id for paper identification
    • Optional: detail_level (brief/detailed)

Tools

Model Tools

  • search-models: Search models with filters.
  • get-model-info: Get detailed information about a specific model.

Dataset Tools

  • search-datasets: Search datasets with filters.
  • get-dataset-info: Get detailed information about a specific dataset.

Space Tools

  • search-spaces: Search Spaces with filters.
  • get-space-info: Get detailed information about a specific Space.

Paper Tools

  • get-paper-info: Get information about a paper.
  • get-daily-papers: Get a curated list of daily papers.

Collection Tools

  • search-collections: Search collections with filters.
  • get-collection-info: Get detailed information about a specific collection.

Configuration

The server does not require configuration but supports optional Hugging Face authentication via HF_TOKEN environment variable. This allows for higher API rate limits and access to private repositories.

Quickstart

Install

Install via Smithery

To install huggingface-mcp-server for Claude Desktop:

npx -y @smithery/cli install @shreyaskarnik/huggingface-mcp-server --client claude

Claude Desktop Configuration

On MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json

On Windows: %APPDATA%/Claude/claude_desktop_config.json

Development

Building and Publishing

To prepare the package for distribution:

  1. Sync dependencies:

    uv sync
    
  2. Build package distributions:

    uv build
    
  3. Publish to PyPI:

    uv publish
    
    • Set PyPI credentials via environment variables or command flags.

Debugging

Use the MCP Inspector for debugging:

npx @modelcontextprotocol/inspector uv --directory /path/to/huggingface-mcp-server run huggingface_mcp_server.py

Example Prompts for Claude

  • "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"

Troubleshooting

  1. Check server logs in Claude Desktop:

    • macOS: ~/Library/Logs/Claude/mcp-server-huggingface.log
    • Windows: %APPDATA%\Claude\logs\mcp-server-huggingface.log
  2. For API rate limiting errors, consider adding a Hugging Face API token.

  3. Ensure your machine has internet connectivity.

  4. Verify data presence on the Hugging Face website if a tool is failing.