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
| Name | Required | Description | Default |
|---|---|---|---|
| repo_id | Yes | Model repository ID (e.g., 'microsoft/DialoGPT-medium') | |
| revision | No | Optional git revision (branch, tag, or commit hash) |
Implementation Reference
- src/tools/models.ts:127-151 (handler)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, }; } }
- src/tools/models.ts:56-74 (schema)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 ], }));
- src/tools/models.ts:93-100 (helper)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" ); }