Skip to main content
Glama

get-model-info

Retrieve detailed metadata about Hugging Face models, including architecture, usage, and specifications, to inform model selection and implementation decisions.

Instructions

Get detailed information about a specific model

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
model_idYesThe ID of the model (e.g., 'google/bert-base-uncased')

Implementation Reference

  • The execution handler for the 'get-model-info' tool within the @server.call_tool() decorated function. It retrieves model information from the Hugging Face API using the provided model_id, handles errors, formats the response including model card if available, and returns it as JSON.
    elif name == "get-model-info": model_id = arguments.get("model_id") if not model_id: return [types.TextContent(type="text", text="Error: model_id is required")] data = await make_hf_request(f"models/{quote_plus(model_id)}") if "error" in data: return [ types.TextContent( type="text", text=f"Error retrieving model information: {data['error']}", ) ] # Format the result model_info = { "id": data.get("id", ""), "name": data.get("modelId", ""), "author": data.get("author", ""), "tags": data.get("tags", []), "pipeline_tag": data.get("pipeline_tag", ""), "downloads": data.get("downloads", 0), "likes": data.get("likes", 0), "lastModified": data.get("lastModified", ""), "description": data.get("description", "No description available"), } # Add model card if available if "card" in data and data["card"]: model_info["model_card"] = ( data["card"].get("data", {}).get("text", "No model card available") ) return [types.TextContent(type="text", text=json.dumps(model_info, indent=2))]
  • Registration of the 'get-model-info' tool in the @server.list_tools() handler, defining its name, description, and input schema requiring 'model_id'.
    types.Tool( name="get-model-info", description="Get detailed information about a specific model", inputSchema={ "type": "object", "properties": { "model_id": { "type": "string", "description": "The ID of the model (e.g., 'google/bert-base-uncased')", }, }, "required": ["model_id"], }, ),
  • Helper function used by the get-model-info handler to make HTTP requests to the Hugging Face API and handle responses or errors.
    async def make_hf_request( endpoint: str, params: Optional[Dict[str, Any]] = None ) -> Dict: """Make a request to the Hugging Face API with proper error handling.""" url = f"{HF_API_BASE}/{endpoint}" try: response = await http_client.get(url, params=params) response.raise_for_status() return response.json() except Exception as e: return {"error": str(e)}

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/shreyaskarnik/huggingface-mcp-server'

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