Skip to main content
Glama
shreyaskarnik

Hugging Face MCP Server

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)}
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It states the tool retrieves information, implying a read-only operation, but doesn't disclose behavioral traits such as authentication requirements, rate limits, error handling, or what 'detailed information' entails. This leaves significant gaps for an agent to understand how to use it effectively.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with no wasted words. It's front-loaded with the core purpose, making it easy to scan and understand quickly. Every word earns its place, adhering to best practices for conciseness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the low complexity (1 parameter, no output schema, no annotations), the description is minimally adequate. It states what the tool does but lacks details on behavior, output format, or error cases. Without annotations or output schema, more context would be helpful for completeness, but it's not severely lacking.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with the single parameter 'model_id' well-documented in the schema. The description adds no additional meaning beyond the schema, such as examples of model IDs beyond the one in the schema or constraints. Baseline 3 is appropriate since the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Get detailed information') and resource ('about a specific model'), making the purpose understandable. It distinguishes from siblings like 'search-models' by focusing on retrieving details for a single model rather than searching. However, it doesn't specify what 'detailed information' includes, which keeps it from being fully specific.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage when you need details for a known model ID, as opposed to 'search-models' for finding models. However, it lacks explicit guidance on when to use this versus alternatives like 'get-collection-info' or 'get-dataset-info', and doesn't mention prerequisites or exclusions, leaving some ambiguity.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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

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