Skip to main content
Glama
michaelwaves

Hugging Face Hub MCP Server

by michaelwaves

hf_get_model_info

Retrieve detailed metadata, files, and configuration for any model on the Hugging Face Hub by specifying its repository ID, enabling comprehensive exploration and analysis.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_idYesModel repository ID (e.g., 'microsoft/DialoGPT-medium')
revisionNoOptional git revision (branch, tag, or commit hash)

Implementation Reference

  • The main handler function that implements the hf_get_model_info tool logic. It validates the arguments using isModelInfoArgs, extracts repo_id and optional revision, calls client.getModelInfo, and returns the result or error.
    export async function handleGetModelInfo(client: HuggingFaceClient, args: unknown): Promise<CallToolResult> { try { if (!isModelInfoArgs(args)) { throw new Error("Invalid arguments for hf_get_model_info"); } const { repo_id, revision } = args; const results = await client.getModelInfo(repo_id, revision); 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 object for hf_get_model_info, including name, description, and input schema for validation.
    export const getModelInfoToolDefinition: Tool = { name: "hf_get_model_info", description: "Get detailed information for a specific model including metadata, files, configuration, and more.", inputSchema: { type: "object", properties: { repo_id: { type: "string", description: "Model repository ID (e.g., 'microsoft/DialoGPT-medium')" }, revision: { type: "string", description: "Optional git revision (branch, tag, or commit hash)" } }, required: ["repo_id"] } };
  • src/server.ts:68-102 (registration)
    Registration of the hf_get_model_info handler in the MCP server's CallToolRequestSchema handler via switch case dispatch.
    this.server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; switch (name) { case 'hf_list_models': return handleListModels(this.client, args); case 'hf_get_model_info': return handleGetModelInfo(this.client, args); case 'hf_get_model_tags': return handleGetModelTags(this.client, args); case 'hf_list_datasets': return handleListDatasets(this.client, args); case 'hf_get_dataset_info': return handleGetDatasetInfo(this.client, args); case 'hf_get_dataset_parquet': return handleGetDatasetParquet(this.client, args); case 'hf_get_croissant': return handleGetCroissant(this.client, args); case 'hf_get_dataset_tags': return handleGetDatasetTags(this.client, args); default: throw new McpError( ErrorCode.MethodNotFound, `Unknown tool: ${name}` ); } });
  • src/server.ts:55-66 (registration)
    Registration of the hf_get_model_info tool definition in the MCP server's ListToolsRequestSchema response.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ listModelsToolDefinition, getModelInfoToolDefinition, getModelTagsToolDefinition, listDatasetsToolDefinition, getDatasetInfoToolDefinition, getDatasetParquetToolDefinition, getCroissantToolDefinition, getDatasetTagsToolDefinition ], }));
  • Type guard helper function used in the handler to validate input arguments for hf_get_model_info.
    function isModelInfoArgs(args: unknown): args is ModelInfoArgs { return ( typeof args === "object" && args !== null && "repo_id" in args && typeof (args as { repo_id: string }).repo_id === "string" ); }

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