Skip to main content
Glama

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
NameRequiredDescriptionDefault
itemNoFilter by item (e.g., 'models/teknium/OpenHermes-2.5-Mistral-7B')
limitNoMaximum number of results to return
ownerNoFilter by owner
queryNoSearch term for titles and descriptions

Implementation Reference

  • 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))]
  • 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", }, }, }, ),
  • 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", }, },

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/shreyaskarnik/huggingface-mcp-server'

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