search-collections
Find specific collections on Hugging Face Hub by owner, item, or search term, with customizable result limits for efficient discovery.
Instructions
Search for collections on Hugging Face Hub
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| item | No | Filter by item (e.g., 'models/teknium/OpenHermes-2.5-Mistral-7B') | |
| limit | No | Maximum number of results to return | |
| owner | No | Filter by owner | |
| query | No | Search term for titles and descriptions |
Implementation Reference
- src/huggingface/server.py:525-564 (handler)Handler function implementing the 'search-collections' tool. Extracts parameters, makes API request to HF collections endpoint, handles errors, formats and returns JSON results.elif name == "search-collections": owner = arguments.get("owner") item = arguments.get("item") query = arguments.get("query") limit = arguments.get("limit", 10) params = {"limit": limit} if owner: params["owner"] = owner if item: params["item"] = item if query: params["q"] = query data = await make_hf_request("collections", params) if "error" in data: return [ types.TextContent( type="text", text=f"Error searching collections: {data['error']}" ) ] # Format the results results = [] for collection in data: collection_info = { "id": collection.get("id", ""), "title": collection.get("title", ""), "owner": collection.get("owner", {}).get("name", ""), "description": collection.get( "description", "No description available" ), "items_count": collection.get("itemsCount", 0), "upvotes": collection.get("upvotes", 0), "last_modified": collection.get("lastModified", ""), } results.append(collection_info) return [types.TextContent(type="text", text=json.dumps(results, indent=2))]
- src/huggingface/server.py:193-214 (registration)Registration of the 'search-collections' tool in the list_tools handler, including name, description, and input schema definition.types.Tool( name="search-collections", description="Search for collections on Hugging Face Hub", inputSchema={ "type": "object", "properties": { "owner": {"type": "string", "description": "Filter by owner"}, "item": { "type": "string", "description": "Filter by item (e.g., 'models/teknium/OpenHermes-2.5-Mistral-7B')", }, "query": { "type": "string", "description": "Search term for titles and descriptions", }, "limit": { "type": "integer", "description": "Maximum number of results to return", }, }, }, ),
- src/huggingface/server.py:196-212 (schema)JSON schema defining the input parameters for the 'search-collections' tool.inputSchema={ "type": "object", "properties": { "owner": {"type": "string", "description": "Filter by owner"}, "item": { "type": "string", "description": "Filter by item (e.g., 'models/teknium/OpenHermes-2.5-Mistral-7B')", }, "query": { "type": "string", "description": "Search term for titles and descriptions", }, "limit": { "type": "integer", "description": "Maximum number of results to return", }, },