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
| Name | Required | Description | Default |
|---|---|---|---|
| repo_id | Yes | Dataset repository ID |
Implementation Reference
- src/tools/datasets.ts:251-275 (handler)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, }; } }
- src/tools/datasets.ts:114-127 (schema)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);
- src/client.ts:119-126 (helper)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)}`); } }