Skip to main content
Glama
shreyaskarnik

Hugging Face MCP Server

search-spaces

Find and filter Hugging Face Spaces by search terms, authors, tags, or SDK to discover AI applications and demos.

Instructions

Search for Spaces on Hugging Face Hub

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryNoSearch term
authorNoFilter by author/organization
tagsNoFilter by tags
sdkNoFilter by SDK (e.g., 'streamlit', 'gradio', 'docker')
limitNoMaximum number of results to return

Implementation Reference

  • Handler function that executes the search-spaces tool by querying the Hugging Face Spaces API and formatting the results as JSON.
    elif name == "search-spaces":
        query = arguments.get("query")
        author = arguments.get("author")
        tags = arguments.get("tags")
        sdk = arguments.get("sdk")
        limit = arguments.get("limit", 10)
    
        params = {"limit": limit}
        if query:
            params["search"] = query
        if author:
            params["author"] = author
        if tags:
            params["filter"] = tags
        if sdk:
            params["filter"] = params.get("filter", "") + f" sdk:{sdk}"
    
        data = await make_hf_request("spaces", params)
    
        if "error" in data:
            return [
                types.TextContent(
                    type="text", text=f"Error searching spaces: {data['error']}"
                )
            ]
    
        # Format the results
        results = []
        for space in data:
            space_info = {
                "id": space.get("id", ""),
                "name": space.get("spaceId", ""),
                "author": space.get("author", ""),
                "sdk": space.get("sdk", ""),
                "tags": space.get("tags", []),
                "likes": space.get("likes", 0),
                "lastModified": space.get("lastModified", ""),
            }
            results.append(space_info)
    
        return [types.TextContent(type="text", text=json.dumps(results, indent=2))]
  • Registration of the search-spaces tool within the @server.list_tools() handler, including its description and input schema.
    types.Tool(
        name="search-spaces",
        description="Search for Spaces on Hugging Face Hub",
        inputSchema={
            "type": "object",
            "properties": {
                "query": {"type": "string", "description": "Search term"},
                "author": {
                    "type": "string",
                    "description": "Filter by author/organization",
                },
                "tags": {"type": "string", "description": "Filter by tags"},
                "sdk": {
                    "type": "string",
                    "description": "Filter by SDK (e.g., 'streamlit', 'gradio', 'docker')",
                },
                "limit": {
                    "type": "integer",
                    "description": "Maximum number of results to return",
                },
            },
        },
    ),
  • JSON Schema defining the input parameters for the search-spaces tool.
    inputSchema={
        "type": "object",
        "properties": {
            "query": {"type": "string", "description": "Search term"},
            "author": {
                "type": "string",
                "description": "Filter by author/organization",
            },
            "tags": {"type": "string", "description": "Filter by tags"},
            "sdk": {
                "type": "string",
                "description": "Filter by SDK (e.g., 'streamlit', 'gradio', 'docker')",
            },
            "limit": {
                "type": "integer",
                "description": "Maximum number of results to return",
            },
        },
  • Helper function used by the search-spaces handler to make HTTP requests to the Hugging Face API.
    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?

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It doesn't disclose whether this is a read-only operation, what authentication might be required, rate limits, pagination behavior, or what the output format looks like (especially problematic since there's no output schema). The description only states what it does, not how it behaves.

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 that states the core purpose without any wasted words. It's appropriately sized for a search tool and front-loads the essential information. Every word earns its place.

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

Completeness2/5

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

Given the lack of annotations and output schema, the description is insufficiently complete. For a search tool with 5 parameters, it should provide more context about what 'Spaces' are, typical use cases, and what information the search returns. The description doesn't compensate for the missing structured data that would help an agent understand the tool's behavior and output.

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 input schema has 100% description coverage, providing clear documentation for all 5 parameters. The description adds no additional parameter information beyond what's in the schema, so it meets the baseline of 3 where the schema does the heavy lifting but doesn't compensate with extra context.

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 ('Search for') and resource ('Spaces on Hugging Face Hub'), making the purpose immediately understandable. It distinguishes from most siblings (e.g., search-datasets, search-models) by specifying 'Spaces', though it doesn't explicitly differentiate from non-search siblings like get-space-info.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives. It doesn't mention when to prefer search-spaces over get-space-info for retrieving information about a specific space, or how it relates to other search tools like search-datasets. The description offers no context about typical use cases 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

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