search-spaces
Find Spaces on Hugging Face Hub using keywords, authors, tags, or SDK. Filter and retrieve results efficiently for machine learning projects.
Instructions
Search for Spaces on Hugging Face Hub
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| author | No | Filter by author/organization | |
| limit | No | Maximum number of results to return | |
| query | No | Search term | |
| sdk | No | Filter by SDK (e.g., 'streamlit', 'gradio', 'docker') | |
| tags | No | Filter by tags |
Implementation Reference
- src/huggingface/server.py:397-437 (handler)The main handler logic for the 'search-spaces' tool within the @server.call_tool() function. It constructs query parameters from inputs, calls the Hugging Face API endpoint '/spaces', formats the results into a list of space info dictionaries, and returns them 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))]
- src/huggingface/server.py:132-154 (registration)The tool registration in @server.list_tools(), defining the name, description, and input schema (JSON Schema) for the 'search-spaces' tool.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", }, }, }, ),