Skip to main content
Glama
shreyaskarnik

Hugging Face MCP Server

get-dataset-info

Retrieve detailed metadata about Hugging Face datasets to understand their structure, contents, and usage requirements before downloading or processing.

Instructions

Get detailed information about a specific dataset

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dataset_idYesThe ID of the dataset (e.g., 'squad')

Implementation Reference

  • Handler logic for the 'get-dataset-info' tool: retrieves dataset information from the Hugging Face API using make_hf_request, formats the response including dataset card if available, and returns it as JSON.
    elif name == "get-dataset-info":
        dataset_id = arguments.get("dataset_id")
        if not dataset_id:
            return [
                types.TextContent(type="text", text="Error: dataset_id is required")
            ]
    
        data = await make_hf_request(f"datasets/{quote_plus(dataset_id)}")
    
        if "error" in data:
            return [
                types.TextContent(
                    type="text",
                    text=f"Error retrieving dataset information: {data['error']}",
                )
            ]
    
        # Format the result
        dataset_info = {
            "id": data.get("id", ""),
            "name": data.get("datasetId", ""),
            "author": data.get("author", ""),
            "tags": data.get("tags", []),
            "downloads": data.get("downloads", 0),
            "likes": data.get("likes", 0),
            "lastModified": data.get("lastModified", ""),
            "description": data.get("description", "No description available"),
        }
    
        # Add dataset card if available
        if "card" in data and data["card"]:
            dataset_info["dataset_card"] = (
                data["card"].get("data", {}).get("text", "No dataset card available")
            )
    
        return [types.TextContent(type="text", text=json.dumps(dataset_info, indent=2))]
  • Input schema and registration for the 'get-dataset-info' tool in the list_tools handler, defining the required 'dataset_id' parameter.
    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"],
        },
    ),
  • The list_tools handler that registers the 'get-dataset-info' tool among others.
    @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 get-dataset-info handler to make API requests to Hugging Face.
    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)}
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden for behavioral disclosure. It states this is a read operation ('Get'), but doesn't mention authentication requirements, rate limits, error conditions, response format, or whether it returns metadata, statistics, or other details. For a tool with zero annotation coverage, this is inadequate.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It's appropriately sized for a simple retrieval tool and front-loads the essential information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, the description is insufficiently complete. It doesn't explain what 'detailed information' includes, the response format, or behavioral aspects like error handling. For a tool that presumably returns structured data about datasets, more context is needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, with the single parameter 'dataset_id' fully documented in the schema. The description adds no additional parameter information beyond what's already in the structured schema, so it meets the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Get detailed information') and resource ('about a specific dataset'), making the purpose understandable. However, it doesn't distinguish this tool from potential siblings like 'search-datasets' or 'get-collection-info' that might also provide dataset information, preventing a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With siblings like 'search-datasets' available, there's no indication whether this is for known dataset IDs versus exploratory searches, or how it differs from other info-retrieval tools like 'get-model-info'.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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