Skip to main content
Glama
michaelwaves

Hugging Face Hub MCP Server

by michaelwaves

hf_list_models

Search and retrieve metadata for machine learning models on Hugging Face Hub. Filter by search terms, authors, tags, and sort by downloads, likes, or other properties for precise results.

Instructions

Get information from all models in the Hub. Supports filtering by search terms, authors, tags, and more. Returns paginated results with model metadata including downloads, likes, and tags.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
authorNoFilter models by author or organization (e.g., 'huggingface', 'microsoft')
configNoWhether to also fetch the repo config
directionNoSort direction: '-1' for descending, anything else for ascending
filterNoFilter based on tags (e.g., 'text-classification', 'spacy')
fullNoWhether to fetch most model data including all tags and files
limitNoLimit the number of models fetched
searchNoFilter based on substrings for repos and their usernames (e.g., 'resnet', 'microsoft')
sortNoProperty to use when sorting (e.g., 'downloads', 'author')

Implementation Reference

  • The handler function that implements the core logic for the 'hf_list_models' tool. It validates the input arguments using isModelSearchArgs, calls HuggingFaceClient.getModels with the arguments, and returns the result as text content or an error response.
    export async function handleListModels(client: HuggingFaceClient, args: unknown): Promise<CallToolResult> {
        try {
            if (!isModelSearchArgs(args)) {
                throw new Error("Invalid arguments for hf_list_models");
            }
    
            const results = await client.getModels(args as Record<string, any>);
            
            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,
            };
        }
    }
  • The tool schema definition for 'hf_list_models', including name, description, and detailed inputSchema with properties for filtering, sorting, and pagination.
    export const listModelsToolDefinition: Tool = {
        name: "hf_list_models",
        description: 
            "Get information from all models in the Hub. Supports filtering by search terms, authors, tags, and more. " +
            "Returns paginated results with model metadata including downloads, likes, and tags.",
        inputSchema: {
            type: "object",
            properties: {
                search: {
                    type: "string",
                    description: "Filter based on substrings for repos and their usernames (e.g., 'resnet', 'microsoft')"
                },
                author: {
                    type: "string", 
                    description: "Filter models by author or organization (e.g., 'huggingface', 'microsoft')"
                },
                filter: {
                    type: "string",
                    description: "Filter based on tags (e.g., 'text-classification', 'spacy')"
                },
                sort: {
                    type: "string",
                    description: "Property to use when sorting (e.g., 'downloads', 'author')"
                },
                direction: {
                    type: "string", 
                    description: "Sort direction: '-1' for descending, anything else for ascending"
                },
                limit: {
                    type: "number",
                    description: "Limit the number of models fetched"
                },
                full: {
                    type: "boolean",
                    description: "Whether to fetch most model data including all tags and files"
                },
                config: {
                    type: "boolean", 
                    description: "Whether to also fetch the repo config"
                }
            },
            required: []
        }
    };
  • src/server.ts:72-74 (registration)
    Registration of the 'hf_list_models' tool handler in the MCP server's CallToolRequestHandler switch statement within the HuggingFaceServer class.
    case 'hf_list_models':
        return handleListModels(this.client, args);
  • src/server.ts:154-156 (registration)
    Registration of the 'hf_list_models' tool handler in the standalone server factory's CallToolRequestHandler switch statement.
    case 'hf_list_models':
        return handleListModels(client, args);
  • Helper function to validate input arguments for the 'hf_list_models' tool.
    function isModelSearchArgs(args: unknown): args is ModelSearchArgs {
        return typeof args === "object" && args !== null;
    }
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes key behaviors: it's a read operation ('Get information'), supports filtering and pagination, and returns metadata. However, it doesn't cover important aspects like rate limits, authentication needs, error handling, or whether the operation is idempotent, leaving gaps for a tool with 8 parameters.

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 efficiently structured in two sentences: the first states the core purpose and filtering support, the second covers return behavior. Every phrase adds value without redundancy, making it easy to parse and front-loaded with essential information.

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 tool's complexity (8 parameters, no output schema, no annotations), the description is adequate but incomplete. It covers the basic purpose and return format but lacks details on authentication, rate limits, error cases, and parameter constraints. For a tool with rich filtering capabilities and no structured output documentation, more contextual guidance would be beneficial.

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?

The description mentions filtering capabilities ('search terms, authors, tags, and more') which aligns with parameters like author, filter, and search, but doesn't add significant meaning beyond the schema's 100% coverage. It doesn't explain parameter interactions, default values, or provide examples beyond what's in the schema descriptions, so it meets the baseline for high schema coverage.

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 tool's purpose: 'Get information from all models in the Hub' with specific filtering capabilities. It distinguishes itself from sibling tools like hf_get_model_info (which gets info for a specific model) by focusing on listing all models with filtering. However, it doesn't explicitly contrast with hf_list_datasets, which follows a similar pattern for datasets.

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 context through 'Supports filtering by search terms, authors, tags, and more' and mentions pagination, suggesting when to use it for broad model discovery. However, it lacks explicit guidance on when to choose this tool versus alternatives like hf_get_model_info for single-model details or hf_list_datasets for datasets, and doesn't mention prerequisites or exclusions.

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

Related 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/michaelwaves/hf-mcp'

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