Skip to main content
Glama
shreyaskarnik

Hugging Face MCP Server

get-paper-info

Retrieve detailed information about research papers using their arXiv ID to access metadata and content from Hugging Face Hub.

Instructions

Get information about a specific paper on Hugging Face

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
arxiv_idYesThe arXiv ID of the paper (e.g., '1810.04805')

Implementation Reference

  • Handler function that executes the get-paper-info tool. Fetches paper details from Hugging Face API endpoint /papers/{arxiv_id}, formats the info including title, authors, summary, and implementations from /arxiv/{arxiv_id}/repos, returns JSON.
    elif name == "get-paper-info":
        arxiv_id = arguments.get("arxiv_id")
        if not arxiv_id:
            return [types.TextContent(type="text", text="Error: arxiv_id is required")]
    
        data = await make_hf_request(f"papers/{arxiv_id}")
    
        if "error" in data:
            return [
                types.TextContent(
                    type="text",
                    text=f"Error retrieving paper information: {data['error']}",
                )
            ]
    
        # Format the result
        paper_info = {
            "arxiv_id": data.get("arxivId", ""),
            "title": data.get("title", ""),
            "authors": data.get("authors", []),
            "summary": data.get("summary", "No summary available"),
            "url": f"https://huggingface.co/papers/{arxiv_id}",
        }
    
        # Get implementations
        implementations = await make_hf_request(f"arxiv/{arxiv_id}/repos")
        if "error" not in implementations:
            paper_info["implementations"] = implementations
    
        return [types.TextContent(type="text", text=json.dumps(paper_info, indent=2))]
  • JSON Schema definition for the get-paper-info tool input, requiring 'arxiv_id' string.
    types.Tool(
        name="get-paper-info",
        description="Get information about a specific paper on Hugging Face",
        inputSchema={
            "type": "object",
            "properties": {
                "arxiv_id": {
                    "type": "string",
                    "description": "The arXiv ID of the paper (e.g., '1810.04805')",
                },
            },
            "required": ["arxiv_id"],
        },
    ),
  • The tool is registered in the handle_list_tools() function via @server.list_tools() decorator, which returns a list including the Tool object for get-paper-info.
    @server.list_tools()
    async def handle_list_tools() -> list[types.Tool]:
        """
        List available tools for interacting with the Hugging Face Hub.
        Each tool specifies its arguments using JSON Schema validation.
        """
        return [
            # Model Tools
            types.Tool(
                name="search-models",
                description="Search for models on Hugging Face Hub",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "query": {
                            "type": "string",
                            "description": "Search term (e.g., 'bert', 'gpt')",
                        },
                        "author": {
                            "type": "string",
                            "description": "Filter by author/organization (e.g., 'huggingface', 'google')",
                        },
                        "tags": {
                            "type": "string",
                            "description": "Filter by tags (e.g., 'text-classification', 'translation')",
                        },
                        "limit": {
                            "type": "integer",
                            "description": "Maximum number of results to return",
                        },
                    },
                },
            ),
            types.Tool(
                name="get-model-info",
                description="Get detailed information about a specific model",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "model_id": {
                            "type": "string",
                            "description": "The ID of the model (e.g., 'google/bert-base-uncased')",
                        },
                    },
                    "required": ["model_id"],
                },
            ),
            # Dataset Tools
            types.Tool(
                name="search-datasets",
                description="Search for datasets on Hugging Face Hub",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "query": {"type": "string", "description": "Search term"},
                        "author": {
                            "type": "string",
                            "description": "Filter by author/organization",
                        },
                        "tags": {"type": "string", "description": "Filter by tags"},
                        "limit": {
                            "type": "integer",
                            "description": "Maximum number of results to return",
                        },
                    },
                },
            ),
            types.Tool(
                name="get-dataset-info",
                description="Get detailed information about a specific dataset",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "dataset_id": {
                            "type": "string",
                            "description": "The ID of the dataset (e.g., 'squad')",
                        },
                    },
                    "required": ["dataset_id"],
                },
            ),
            # Space Tools
            types.Tool(
                name="search-spaces",
                description="Search for Spaces on Hugging Face Hub",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "query": {"type": "string", "description": "Search term"},
                        "author": {
                            "type": "string",
                            "description": "Filter by author/organization",
                        },
                        "tags": {"type": "string", "description": "Filter by tags"},
                        "sdk": {
                            "type": "string",
                            "description": "Filter by SDK (e.g., 'streamlit', 'gradio', 'docker')",
                        },
                        "limit": {
                            "type": "integer",
                            "description": "Maximum number of results to return",
                        },
                    },
                },
            ),
            types.Tool(
                name="get-space-info",
                description="Get detailed information about a specific Space",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "space_id": {
                            "type": "string",
                            "description": "The ID of the Space (e.g., 'huggingface/diffusers-demo')",
                        },
                    },
                    "required": ["space_id"],
                },
            ),
            # Papers Tools
            types.Tool(
                name="get-paper-info",
                description="Get information about a specific paper on Hugging Face",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "arxiv_id": {
                            "type": "string",
                            "description": "The arXiv ID of the paper (e.g., '1810.04805')",
                        },
                    },
                    "required": ["arxiv_id"],
                },
            ),
            types.Tool(
                name="get-daily-papers",
                description="Get the list of daily papers curated by Hugging Face",
                inputSchema={
                    "type": "object",
                    "properties": {},
                },
            ),
            # Collections Tools
            types.Tool(
                name="search-collections",
                description="Search for collections on Hugging Face Hub",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "owner": {"type": "string", "description": "Filter by owner"},
                        "item": {
                            "type": "string",
                            "description": "Filter by item (e.g., 'models/teknium/OpenHermes-2.5-Mistral-7B')",
                        },
                        "query": {
                            "type": "string",
                            "description": "Search term for titles and descriptions",
                        },
                        "limit": {
                            "type": "integer",
                            "description": "Maximum number of results to return",
                        },
                    },
                },
            ),
            types.Tool(
                name="get-collection-info",
                description="Get detailed information about a specific collection",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "namespace": {
                            "type": "string",
                            "description": "The namespace of the collection (user or organization)",
                        },
                        "collection_id": {
                            "type": "string",
                            "description": "The ID part of the collection",
                        },
                    },
                    "required": ["namespace", "collection_id"],
                },
            ),
        ]
  • Helper function used by the handler to make API requests to Hugging Face endpoints.
    async def make_hf_request(
        endpoint: str, params: Optional[Dict[str, Any]] = None
    ) -> Dict:
        """Make a request to the Hugging Face API with proper error handling."""
        url = f"{HF_API_BASE}/{endpoint}"
        try:
            response = await http_client.get(url, params=params)
            response.raise_for_status()
            return response.json()
        except Exception as e:
            return {"error": str(e)}

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/shreyaskarnik/huggingface-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server