Skip to main content
Glama

info

Retrieve HuggingFace model metadata including architecture, parameter count, size, hidden dimensions, layers, vocabulary size, and context length. No GPU required.

Instructions

Get model info from HuggingFace — parameters, size, architecture.

Lightweight call using the HuggingFace API. No GPU or heavy dependencies required.

Args: model: HuggingFace model ID (e.g. 'meta-llama/Llama-3.1-8B-Instruct') or local path to a model directory.

Returns: Model metadata including architecture, parameter count, size, hidden dimensions, number of layers, vocabulary size, and context length.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
modelYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The `info` tool handler — registered via @mcp.tool() decorator. Calls get_model_info() and returns model metadata (architecture, parameters, size, context length).
    @mcp.tool()
    def info(model: str) -> dict[str, Any]:
        """Get model info from HuggingFace — parameters, size, architecture.
    
        Lightweight call using the HuggingFace API. No GPU or heavy
        dependencies required.
    
        Args:
            model: HuggingFace model ID (e.g. 'meta-llama/Llama-3.1-8B-Instruct')
                   or local path to a model directory.
    
        Returns:
            Model metadata including architecture, parameter count, size,
            hidden dimensions, number of layers, vocabulary size, and
            context length.
        """
        result = get_model_info(model)
    
        if not result.get("found"):
            return {
                "error": f"Model not found: {result.get('error', 'unknown')}",
                "model": model,
            }
    
        # Build a clean response (strip internal fields like raw config)
        output = {
            "model": result.get("model_id", result.get("source")),
            "found": True,
            "architecture": result.get("arch", "unknown"),
            "parameters": result.get("params_human", "unknown"),
            "size": result.get("size_human", "unknown"),
            "size_bytes": result.get("size_bytes", 0),
            "hidden_size": result.get("hidden_size", 0),
            "num_layers": result.get("num_layers", 0),
            "vocab_size": result.get("vocab_size", 0),
            "context_length": result.get("context_length", 0),
        }
    
        if result.get("local"):
            output["local"] = True
    
        # Add compression estimates
        if result.get("size_bytes"):
            sz = result["size_bytes"]
            output["estimated_sizes"] = {
                "4bit": format_size(sz / estimate_compression(16, 4)),
                "8bit": format_size(sz / estimate_compression(16, 8)),
            }
    
        return output
  • Docstring of the `info` tool serving as input schema — accepts a single 'model' string (HuggingFace model ID or local path).
    def info(model: str) -> dict[str, Any]:
        """Get model info from HuggingFace — parameters, size, architecture.
    
        Lightweight call using the HuggingFace API. No GPU or heavy
        dependencies required.
    
        Args:
            model: HuggingFace model ID (e.g. 'meta-llama/Llama-3.1-8B-Instruct')
                   or local path to a model directory.
    
        Returns:
            Model metadata including architecture, parameter count, size,
            hidden dimensions, number of layers, vocabulary size, and
            context length.
        """
  • Tool registered via @mcp.tool() decorator on the FastMCP instance named 'TurboQuant'.
    @mcp.tool()
  • The `get_model_info()` helper function — fetches model info from HuggingFace Hub or local path, extracts architecture, parameter count, size, context length.
    def get_model_info(model_id_or_path: str) -> dict[str, Any]:
        """Get model information from HuggingFace or local path."""
        info: dict[str, Any] = {"source": model_id_or_path}
    
        try:
            from huggingface_hub import hf_hub_download, model_info as hf_model_info
    
            mi = hf_model_info(model_id_or_path)
            info["model_id"] = mi.id
            info["size_bytes"] = sum(
                s.size
                for s in mi.siblings
                if s.rfilename.endswith((".safetensors", ".bin")) and s.size is not None
            )
            info["size_human"] = format_size(info["size_bytes"])
    
            # Try to get parameter count from config
            config_path = hf_hub_download(model_id_or_path, "config.json")
            with open(config_path) as f:
                config = json.load(f)
            info["config"] = config
            info["arch"] = config.get("architectures", ["unknown"])[0]
            info["hidden_size"] = (
                config.get("hidden_size")
                or config.get("n_embd")
                or config.get("d_model")
                or 0
            )
            info["num_layers"] = (
                config.get("num_hidden_layers")
                or config.get("n_layer")
                or config.get("num_layers")
                or 0
            )
            info["vocab_size"] = config.get("vocab_size", 0)
            info["context_length"] = (
                config.get("max_position_embeddings")
                or config.get("n_positions")
                or config.get("max_seq_len")
                or config.get("seq_length")
                or 0
            )
    
            # Estimate parameters
            h = info["hidden_size"]
            n = info["num_layers"]
            v = info["vocab_size"]
            if h and n and v:
                params = 12 * n * h * h + v * h
                info["params_estimate"] = params
                info["params_human"] = (
                    f"{params / 1e9:.1f}B" if params > 1e9 else f"{params / 1e6:.0f}M"
                )
    
            # If HF API didn't return file sizes, estimate from parameters
            if not info["size_bytes"] and info.get("params_estimate"):
                info["size_bytes"] = info["params_estimate"] * 2  # FP16
                info["size_human"] = format_size(info["size_bytes"]) + " (estimated)"
    
            info["found"] = True
        except Exception as e:
            # Check if local path
            if os.path.isdir(model_id_or_path):
                info["found"] = True
                info["local"] = True
                total = sum(
                    os.path.getsize(os.path.join(dp, f))
                    for dp, _, fns in os.walk(model_id_or_path)
                    for f in fns
                    if f.endswith((".safetensors", ".bin"))
                )
                info["size_bytes"] = total
                info["size_human"] = format_size(total)
                local_config = os.path.join(model_id_or_path, "config.json")
                if os.path.exists(local_config):
                    with open(local_config) as f:
                        config = json.load(f)
                    info["config"] = config
                    info["arch"] = config.get("architectures", ["unknown"])[0]
                    info["hidden_size"] = (
                        config.get("hidden_size")
                        or config.get("n_embd")
                        or config.get("d_model")
                        or 0
                    )
                    info["num_layers"] = (
                        config.get("num_hidden_layers")
                        or config.get("n_layer")
                        or config.get("num_layers")
                        or 0
                    )
                    info["vocab_size"] = config.get("vocab_size", 0)
                    info["context_length"] = (
                        config.get("max_position_embeddings")
                        or config.get("n_positions")
                        or config.get("max_seq_len")
                        or 0
                    )
            else:
                info["found"] = False
                info["error"] = str(e)
    
        return info
  • Helper `format_size()` — converts bytes to human-readable string, used by the info tool to format model size.
    def format_size(size_bytes: int | float) -> str:
        """Format bytes to human-readable string."""
        for unit in ["B", "KB", "MB", "GB", "TB"]:
            if size_bytes < 1024:
                return f"{size_bytes:.1f} {unit}"
            size_bytes /= 1024
        return f"{size_bytes:.1f} PB"
Behavior3/5

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

With no annotations provided, the description carries full burden. It explains the tool is lightweight and lists return values, but omits details like authentication requirements, rate limits, or error handling. This is adequate for a simple retrieval tool but lacks full transparency.

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 well-organized with an Args/Returns section, uses plain language, and contains no redundant information. Every sentence adds value, achieving conciseness without sacrificing clarity.

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

Completeness5/5

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

Given the simple input (one parameter) and existence of an output schema, the description covers all necessary context: tool purpose, parameter details, and return values. It is fully self-contained and sufficient for an agent to invoke correctly.

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

Parameters4/5

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

Schema coverage is 0%, so the description must compensate. It provides examples ('meta-llama/Llama-3.1-8B-Instruct'), specifies it can be a local path, and defines the parameter's format. This adds significant meaning beyond the raw schema, earning a high score.

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

Purpose5/5

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

The description clearly states the tool retrieves model info from HuggingFace, listing specific attributes (parameters, size, architecture). This verb+resource pair is distinct from sibling tools like 'check', 'evaluate', 'push', 'quantize', and 'recommend', which all serve different purposes.

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

Usage Guidelines4/5

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

The description notes it is a 'lightweight call using the HuggingFace API' with 'No GPU or heavy dependencies required,' providing context on when to use it. However, it does not explicitly state when not to use it or mention alternatives among sibling tools, though the distinct purpose makes this less critical.

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/ShipItAndPray/mcp-turboquant'

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