Skip to main content
Glama
privetin

Dataset Viewer MCP Server

by privetin

validate

Verify Hugging Face dataset availability and accessibility by checking dataset existence and permissions with optional authentication for private datasets.

Instructions

Check if a Hugging Face dataset exists and is accessible

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
datasetYesHugging Face dataset identifier in the format owner/dataset
auth_tokenNoHugging Face auth token for private/gated datasets

Implementation Reference

  • Handler for the 'validate' tool in the call_tool method. Validates dataset format with regex and checks existence via GET /is-valid endpoint on datasets-server.huggingface.co, returning JSON result or error messages as TextContent.
    elif name == "validate":
        dataset = arguments["dataset"]
        try:
            # First check format
            if not re.match(r"^[^/]+/[^/]+$", dataset):
                return [
                    types.TextContent(
                        type="text",
                        text="Dataset must be in the format 'owner/dataset'"
                    )
                ]
                
            # Then check if dataset exists and is accessible
            response = await DatasetViewerAPI(auth_token=auth_token).client.get("/is-valid", params={"dataset": dataset})
            response.raise_for_status()
            result = response.json()
            
            return [
                types.TextContent(
                    type="text",
                    text=json.dumps(result, indent=2)
                )
            ]
        except httpx.NetworkError as e:
            return [
                types.TextContent(
                    type="text",
                    text=str(e)
                )
            ]
        except httpx.HTTPStatusError as e:
            if e.response.status_code == 404:
                return [
                    types.TextContent(
                        type="text",
                        text=f"Dataset '{dataset}' not found"
                    )
                ]
            elif e.response.status_code == 403:
                return [
                    types.TextContent(
                        type="text",
                        text=f"Dataset '{dataset}' requires authentication"
                    )
                ]
            else:
                return [
                    types.TextContent(
                        type="text",
                        text=str(e)
                    )
                ]
  • Registration of the 'validate' MCP tool in list_tools(), including name, description, and inputSchema defining 'dataset' as required string with pattern and optional auth_token.
    types.Tool(
        name="validate",
        description="Check if a Hugging Face dataset exists and is accessible",
        inputSchema={
            "type": "object",
            "properties": {
                "dataset": {
                    "type": "string", 
                    "description": "Hugging Face dataset identifier in the format owner/dataset",
                    "pattern": "^[^/]+/[^/]+$",
                    "examples": ["ylecun/mnist", "stanfordnlp/imdb"]
                },
                "auth_token": {
                    "type": "string",
                    "description": "Hugging Face auth token for private/gated datasets",
                    "optional": True
                }
            },
            "required": ["dataset"],
        }
    ),
  • Input schema for the 'validate' tool, specifying object with required 'dataset' string (pattern ^[^/]+/[^/]+$) and optional 'auth_token'.
    inputSchema={
        "type": "object",
        "properties": {
            "dataset": {
                "type": "string", 
                "description": "Hugging Face dataset identifier in the format owner/dataset",
                "pattern": "^[^/]+/[^/]+$",
                "examples": ["ylecun/mnist", "stanfordnlp/imdb"]
            },
            "auth_token": {
                "type": "string",
                "description": "Hugging Face auth token for private/gated datasets",
                "optional": True
            }
        },
        "required": ["dataset"],
    }
  • Helper method 'validate_dataset' in DatasetViewerAPI class that validates dataset format and existence using HEAD /is-valid, raising specific errors. Similar logic to tool handler but raises exceptions instead of returning content.
    async def validate_dataset(self, dataset: str) -> None:
        """Validate dataset ID format and check if it exists"""
        # Validate format (username/dataset-name)
        if not re.match(r"^[^/]+/[^/]+$", dataset):
            raise ValueError("Dataset ID must be in the format 'owner/dataset'")
            
        # Check if dataset exists and is accessible
        try:
            response = await self.client.head(f"/is-valid?dataset={dataset}")
            response.raise_for_status()
        except httpx.NetworkError as e:
            raise ConnectionError(f"Network error while validating dataset: {e}")
        except httpx.HTTPStatusError as e:
            if e.response.status_code == 404:
                raise ValueError(f"Dataset '{dataset}' not found")
            elif e.response.status_code == 403:
                raise ValueError(f"Dataset '{dataset}' exists but requires authentication")
            else:
                raise RuntimeError(f"Error validating dataset: {e}")
Behavior2/5

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

With no annotations, the description carries full burden but only states the basic check. It lacks details on behavior such as error handling, rate limits, or what 'accessible' entails (e.g., public vs. private datasets). This leaves gaps for an agent to understand operational constraints.

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 front-loads the core purpose without unnecessary words. Every part earns its place by clearly stating the tool's function.

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

Completeness3/5

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

Given no annotations and no output schema, the description is minimal but adequate for a simple validation tool. However, it could benefit from more behavioral context (e.g., response format or error cases) to fully guide an agent, especially with siblings that might overlap in functionality.

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?

Schema description coverage is 100%, so parameters are well-documented in the schema. The description adds no additional meaning beyond implying the 'auth_token' is for private/gated datasets, which is already covered in the schema. Baseline 3 is appropriate as the schema does the heavy lifting.

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

Purpose5/5

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

The description clearly states the specific action ('check if exists and is accessible') and the resource ('Hugging Face dataset'), distinguishing it from siblings like 'get_info' or 'search_dataset' which likely retrieve data rather than validate accessibility.

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?

No explicit guidance on when to use this tool versus alternatives is provided. The description implies validation, but it doesn't specify scenarios like pre-download checks or differentiate from 'get_info' which might also confirm existence.

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/privetin/dataset-viewer'

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