Skip to main content
Glama
michaelwaves

Hugging Face Hub MCP Server

by michaelwaves

hf_get_dataset_info

Retrieve comprehensive details about a dataset, including metadata, files, and configurations from the Hugging Face Hub. Specify the dataset repository ID and optional revision for targeted information.

Instructions

Get detailed information for a specific dataset including metadata, files, configuration, and more.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fullNoWhether to fetch most dataset data including all tags and files
repo_idYesDataset repository ID (e.g., 'squad', 'imdb')
revisionNoOptional git revision (branch, tag, or commit hash)

Implementation Reference

  • The handler function that executes the tool logic: validates arguments, calls the HuggingFaceClient to retrieve dataset information, and returns formatted result or error.
    export async function handleGetDatasetInfo(client: HuggingFaceClient, args: unknown): Promise<CallToolResult> {
        try {
            if (!isDatasetInfoArgs(args)) {
                throw new Error("Invalid arguments for hf_get_dataset_info");
            }
    
            const { repo_id, revision, full } = args;
            const params = full ? { full } : {};
            const results = await client.getDatasetInfo(repo_id, revision, params);
            
            return {
                content: [{ type: "text", text: results }],
                isError: false,
            };
        } catch (error) {
            return {
                content: [
                    {
                        type: "text",
                        text: `Error: ${error instanceof Error ? error.message : String(error)}`,
                    },
                ],
                isError: true,
            };
        }
    }
  • Tool definition object containing the name, description, and input schema (JSON schema) for validating tool arguments.
    export const getDatasetInfoToolDefinition: Tool = {
        name: "hf_get_dataset_info",
        description:
            "Get detailed information for a specific dataset including metadata, files, configuration, and more.",
        inputSchema: {
            type: "object",
            properties: {
                repo_id: {
                    type: "string",
                    description: "Dataset repository ID (e.g., 'squad', 'imdb')"
                },
                revision: {
                    type: "string", 
                    description: "Optional git revision (branch, tag, or commit hash)"
                },
                full: {
                    type: "boolean",
                    description: "Whether to fetch most dataset data including all tags and files"
                }
            },
            required: ["repo_id"]
        }
    };
  • src/server.ts:84-85 (registration)
    Registration in the tool dispatch switch statement: routes calls to 'hf_get_dataset_info' to the handleGetDatasetInfo handler.
    case 'hf_get_dataset_info':
        return handleGetDatasetInfo(this.client, args);
  • src/server.ts:57-64 (registration)
    Registration of the tool definition in the ListToolsRequest handler, making the schema available to clients.
    listModelsToolDefinition,
    getModelInfoToolDefinition,
    getModelTagsToolDefinition,
    listDatasetsToolDefinition,
    getDatasetInfoToolDefinition,
    getDatasetParquetToolDefinition,
    getCroissantToolDefinition,
    getDatasetTagsToolDefinition
  • Type guard helper function used by the handler to validate input arguments before processing.
    function isDatasetInfoArgs(args: unknown): args is DatasetInfoArgs {
        return (
            typeof args === "object" &&
            args !== null &&
            "repo_id" in args &&
            typeof (args as { repo_id: string }).repo_id === "string"
        );
Install Server

Other Tools

Related 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/michaelwaves/hf-mcp'

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