HU

Hugging Face Dataset Viewer on MCP Server

Explore Hugging Face datasets on MCP server with search, filtering, dataset statistics, and one-click data export for fast analysis.

Overview

This MCP (Model Context Protocol) server provides a lightweight viewer for Hugging Face datasets. It exposes a searchable, filterable interface and simple APIs that let developers inspect dataset metadata, preview examples, compute basic statistics, and export subsets for downstream analysis. The server is intended to speed up data exploration when preparing training or evaluation pipelines that run alongside an MCP-compliant model service.

The viewer is useful when you want to rapidly understand the contents and shape of a dataset without downloading full archives or writing ad-hoc scripts. It supports text- and table-oriented datasets, enables faceted search and sampling, and offers one-click export to common formats so you can iterate faster on preprocessing, labeling, or model-context creation.

GitHub: https://github.com/privetin/dataset-viewer

Features

  • Browse Hugging Face datasets metadata and splits
  • Full-text search and field-level filtering across examples
  • Sample preview of records (configurable sample size)
  • Computation of common dataset statistics (counts, distributions, missing values)
  • One-click export to CSV / JSON for quick analysis
  • REST API endpoints for programmatic access (indexing, search, export)
  • Works as an MCP server component to integrate dataset context with model responses
  • Docker support for quick deployment

Installation / Configuration

Prerequisites: Python 3.8+, Git, and (optionally) Docker. You will typically need a Hugging Face token for private datasets or rate-limited access.

Clone and install locally:

git clone https://github.com/privetin/dataset-viewer.git
cd dataset-viewer
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

Set required environment variables (example):

export HF_TOKEN="hf_xxx"        # optional, required for private datasets or higher rate limits
export DATA_DIR="./data_cache" # optional cache directory for downloaded datasets
export PORT=8080

Run the server with an ASGI server (uvicorn example):

# If the package exposes `app` at dataset_viewer.app:app — adjust import path if different
uvicorn dataset_viewer.app:app --host 0.0.0.0 --port ${PORT}

Docker (build and run):

docker build -t dataset-viewer .
docker run -p 8080:8080 \
  -e HF_TOKEN="hf_xxx" \
  -e DATA_DIR="/data" \
  dataset-viewer

Configuration options can also be provided via a config file (config.yaml) if the project exposes one — check the repo root for default configuration templates.

Environment variables and configuration (common options)

VariablePurposeDefault
HF_TOKENHugging Face access token (optional)none
DATA_DIRLocal cache directory for datasets./data_cache
PORTHTTP port for the server8080
LOG_LEVELLogging verbosity (DEBUG/INFO/WARN)INFO

Available Tools / Resources

  • Web UI: interactive front-end to search, filter, preview, and export dataset slices.
  • REST API: endpoints for programmatic listing of datasets, split metadata, search queries, and export requests.
  • Exporter: background job or synchronous endpoint that writes selected records to CSV or NDJSON for downstream tooling.
  • Statistics engine: computes basic distributions, null counts, and example summaries per field.
  • MCP integration layer: adapters that allow dataset context to be requested by MCP-aware model tooling.

Refer to the repository’s API documentation or code comments for the exact endpoint paths and payload formats.

Use Cases

  1. Quick dataset inspection before training

    • Browse a dataset’s splits and label distribution to decide whether to subsample or re-balance.
    • Export a stratified sample as CSV and run local experiments in a Jupyter notebook.
  2. Data-driven prompt/context building for models

    • Use the REST API to fetch examples matching a query and assemble context windows for an LLM that follows MCP conventions.
  3. Labeling and annotation preparation

    • Filter examples by field value or missing labels, export a CSV subset, and feed it into your annotation tool.
  4. Preprocessing pipeline debugging

    • Preview raw examples and computed statistics to validate tokenization, text normalization, or column mappings before batching into training pipelines.
  5. Lightweight dataset sharing within a team

    • Spin up the Docker container and allow teammates to explore dataset structure and example content without downloading large files locally.

Tips for Developers

  • If you plan to index large datasets, run the server with sufficient disk cache and monitor memory usage.
  • Use HF_TOKEN for private datasets or to avoid low anonymous request limits from the Hugging Face Hub.
  • Check the repository README and API docs for exact route names and sample payloads if you need to automate export workflows.

For more details, sample code, and the latest updates, see the project on GitHub: https://github.com/privetin/dataset-viewer.