数据集API服务

HF Dataset MCP是一个为Hugging Face数据集查看器API提供的服务器,支持搜索数据集、获取行数据、过滤数据等功能。

  • by cfahlgren1
  • TypeScript
  • 本地部署
  • 更新于
在 GitHub 查看 cfahlgren1/hf-dataset-mcp

使用说明

HF数据集MCP

用于拥抱面部数据集查看器API的MCP服务器。搜索数据集、提取行、过滤数据等。

安装

npx @cfahlgren1/hf-dataset-mcp

配置

克劳德桌面版

添加到您的Claude桌面配置(~/Library/Application Support/Claude/claude_desktop_config.json 在macOS上):

{
  "mcpServers": {
    "hf-datasets": {
      "command": "npx",
      "args": ["-y", "@cfahlgren1/hf-dataset-mcp"],
      "env": {
        "HF_TOKEN": "hf_..."
      }
    }
  }
}

环境变量

变量 描述
HF_TOKEN 拥抱面部API令牌(私有/封闭数据集需要)
HF_DATASETS_SERVER 自定义数据集查看器API URL(默认值: https://datasets-server.huggingface.co)

工具

search_datasets

在Hugging Face Hub上按姓名、标签或作者查找数据集。

search_datasets(search?: string, author?: string, filter?: string[], sort?: string, limit?: number)

validate_dataset

检查数据集是否可访问,以及哪些查看器功能可用。

validate_dataset(dataset: string)

list_splits

获取数据集的所有可用配置和拆分。

list_splits(dataset: string)

get_dataset_info

获取数据集配置的架构、元数据和行数。

get_dataset_info(dataset: string, config: string)

get_rows

从数据集分割中获取行切片。

get_rows(dataset: string, config: string, split: string, offset?: number, length?: number)

search_dataset

使用BM25排名在数据集中进行全文搜索。

search_dataset(dataset: string, config: string, split: string, query: string, offset?: number, length?: number)

filter_rows

使用类似SQL的WHERE条件过滤数据集行。

filter_rows(dataset: string, config: string, split: string, where: string, orderby?: string, offset?: number, length?: number)

WHERE语法: 列名在双引号中,字符串在单引号中。支持 =, <>, >, <, >=, <=, AND, OR, NOT.

例子: "label"=1 AND "text" LIKE '%hello%'

get_dataset_size

获取所有配置和拆分的行数和字节大小。

get_dataset_size(dataset: string)

list_parquet_files

获取数据集Parquet文件的URL,以便直接下载或处理。

list_parquet_files(dataset: string)

get_statistics

获取数据集拆分中每一列的描述性统计数据。

get_statistics(dataset: string, config: string, split: string)

例子

查找文本分类数据集

search_datasets(filter: ["task_categories:text-classification"], sort: "downloads", limit: 10)

获取IMDB数据集信息

list_splits(dataset: "stanfordnlp/imdb")
get_dataset_info(dataset: "stanfordnlp/imdb", config: "plain_text")

从数据集中提取行

get_rows(dataset: "stanfordnlp/imdb", config: "plain_text", split: "train", offset: 0, length: 10)

搜索特定内容

search_dataset(dataset: "stanfordnlp/imdb", config: "plain_text", split: "train", query: "amazing movie")

滤记录

filter_rows(dataset: "stanfordnlp/imdb", config: "plain_text", split: "train", where: "\"label\"=1", length: 10)

许可证

麻省理工学院