Skip to main content
Glama

push

Upload quantized AI models to HuggingFace Hub with automated model card generation and metadata inclusion for repository sharing.

Instructions

Push a quantized model to HuggingFace Hub.

Uploads all model files from the output directory to a HuggingFace repository. Generates a model card (README.md) with metadata. Requires HuggingFace authentication (huggingface-cli login or HF_TOKEN).

Args: repo_id: HuggingFace repository ID (e.g. 'username/model-GGUF-4bit'). model_dir: Local directory containing the quantized model files. model: Original model ID for the model card (optional). bits: Bit width used during quantization (for model card metadata).

Returns: Upload result with repository URL and file count.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_idYes
model_dirYes
modelNo
bitsNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The `push` function, registered as an MCP tool, handles uploading quantized model files to the HuggingFace Hub. It manages repository creation, model card generation, and directory traversal for file uploads.
    @mcp.tool()
    def push(
        repo_id: str,
        model_dir: str,
        model: str | None = None,
        bits: int = 4,
    ) -> dict[str, Any]:
        """Push a quantized model to HuggingFace Hub.
    
        Uploads all model files from the output directory to a HuggingFace
        repository. Generates a model card (README.md) with metadata.
        Requires HuggingFace authentication (huggingface-cli login or HF_TOKEN).
    
        Args:
            repo_id: HuggingFace repository ID (e.g. 'username/model-GGUF-4bit').
            model_dir: Local directory containing the quantized model files.
            model: Original model ID for the model card (optional).
            bits: Bit width used during quantization (for model card metadata).
    
        Returns:
            Upload result with repository URL and file count.
        """
        if not os.path.isdir(model_dir):
            return {
                "success": False,
                "error": f"Directory does not exist: {model_dir}",
            }
    
        try:
            from huggingface_hub import HfApi
        except ImportError:
            return {
                "success": False,
                "error": "huggingface-hub required. Install: pip install huggingface-hub",
                "install_cmd": "pip install huggingface-hub",
            }
    
        api = HfApi()
    
        # Check authentication
        try:
            user_info = api.whoami()
            username = user_info.get("name", "unknown")
        except Exception:
            return {
                "success": False,
                "error": (
                    "Not authenticated with HuggingFace. "
                    "Run: huggingface-cli login, or set HF_TOKEN environment variable."
                ),
            }
    
        # Create repo if needed
        try:
            api.create_repo(repo_id, exist_ok=True, repo_type="model")
        except Exception as e:
            return {
                "success": False,
                "error": f"Failed to create repository: {e}",
            }
    
        # Generate model card
        model_source = model or "unknown"
        card = _generate_model_card(model_source, repo_id, bits)
        card_path = os.path.join(model_dir, "README.md")
        with open(card_path, "w") as f:
            f.write(card)
    
        # Upload all files
        files_uploaded = 0
        errors = []
        for root, _dirs, files in os.walk(model_dir):
            for fname in files:
                fpath = os.path.join(root, fname)
                rel_path = os.path.relpath(fpath, model_dir)
                try:
                    api.upload_file(
                        path_or_fileobj=fpath,
                        path_in_repo=rel_path,
                        repo_id=repo_id,
                        repo_type="model",
                    )
                    files_uploaded += 1
                except Exception as e:
                    errors.append(f"{rel_path}: {e}")
    
        result = {
            "success": files_uploaded > 0,
            "repository": f"https://huggingface.co/{repo_id}",
            "files_uploaded": files_uploaded,
            "authenticated_as": username,
        }
Behavior4/5

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

With no annotations provided, the description carries full burden and successfully discloses auth requirements, side effects (generates model card/README.md), and return structure ('Upload result with repository URL'). Missing minor behavioral details like idempotency or overwrite behavior.

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?

Perfectly structured with front-loaded purpose, followed by mechanism, prerequisites, Args, and Returns. Every sentence provides unique value; no repetition of schema structure or tautology.

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?

Comprehensive for a 4-parameter tool with zero schema coverage. The description fully documents all parameters, explains authentication, describes side effects (model card generation), and acknowledges the return value without needing to replicate the output schema.

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

Parameters5/5

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

Given 0% schema description coverage, the Args section compensates excellently by documenting all 4 parameters with precise semantics and an illustrative example for repo_id ('username/model-GGUF-4bit'), including optionality notes for 'model'.

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 opens with a specific verb ('Push') and clear resource ('quantized model to HuggingFace Hub'), immediately distinguishing it from the 'quantize' sibling (which creates the model) by specifying this tool handles the upload of already-quantized files.

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?

Provides clear contextual prerequisites ('Requires HuggingFace authentication') and implies workflow position ('output directory' suggests use after quantization). However, it lacks explicit comparison to siblings (e.g., 'use this after quantize') or explicit 'when not to use' guidance.

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