Skip to main content
Glama
michaelwaves

Hugging Face Hub MCP Server

by michaelwaves

hf_get_croissant

Retrieve Croissant metadata for a dataset from the Hugging Face Hub, enabling structured access to machine learning datasets in a high-level format.

Instructions

Get the Croissant metadata for a dataset. Croissant is a high-level format for machine learning datasets.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_idYesDataset repository ID

Implementation Reference

  • The handler function that executes the tool logic: validates input, calls the HuggingFaceClient to fetch Croissant metadata, and returns the result or error.
    export async function handleGetCroissant(client: HuggingFaceClient, args: unknown): Promise<CallToolResult> {
        try {
            if (!isCroissantArgs(args)) {
                throw new Error("Invalid arguments for hf_get_croissant");
            }
    
            const { repo_id } = args;
            const results = await client.getDatasetCroissant(repo_id);
            
            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,
            };
        }
    }
  • The tool definition including name, description, and input schema (requires repo_id).
    export const getCroissantToolDefinition: Tool = {
        name: "hf_get_croissant",
        description: "Get the Croissant metadata for a dataset. Croissant is a high-level format for machine learning datasets.",
        inputSchema: {
            type: "object",
            properties: {
                repo_id: {
                    type: "string", 
                    description: "Dataset repository ID"
                }
            },
            required: ["repo_id"]
        }
    };
  • src/server.ts:55-66 (registration)
    Registration of the tool definition in the MCP server's list tools request handler.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
        tools: [
            listModelsToolDefinition,
            getModelInfoToolDefinition,
            getModelTagsToolDefinition,
            listDatasetsToolDefinition,
            getDatasetInfoToolDefinition,
            getDatasetParquetToolDefinition,
            getCroissantToolDefinition,
            getDatasetTagsToolDefinition
        ],
    }));
  • src/server.ts:90-91 (registration)
    Mapping of the tool name to its handler function in the MCP server's call tool request switch statement.
    case 'hf_get_croissant':
        return handleGetCroissant(this.client, args);
  • Core client method that makes the HTTP GET request to the Hugging Face API endpoint for Croissant metadata and stringifies the response.
    async getDatasetCroissant(repoId: string): Promise<string> {
        try {
            const response: AxiosResponse = await this.httpClient.get(`/api/datasets/${repoId}/croissant`);
            return JSON.stringify(response.data, null, 2);
        } catch (error) {
            throw new Error(`Failed to fetch Croissant metadata: ${error instanceof Error ? error.message : String(error)}`);
        }
    }
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