get-space-info
Retrieve detailed information about a specific Hugging Face Space, including its configuration, files, and metadata, by providing the Space ID.
Instructions
Get detailed information about a specific Space
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| space_id | Yes | The ID of the Space (e.g., 'huggingface/diffusers-demo') |
Implementation Reference
- src/huggingface/server.py:439-467 (handler)Handler for the 'get-space-info' tool within the @server.call_tool() function. It retrieves space details from the Hugging Face API endpoint '/spaces/{space_id}', handles errors, formats key information including id, name, author, sdk, tags, likes, lastModified, description, and url, then returns formatted JSON.elif name == "get-space-info": space_id = arguments.get("space_id") if not space_id: return [types.TextContent(type="text", text="Error: space_id is required")] data = await make_hf_request(f"spaces/{quote_plus(space_id)}") if "error" in data: return [ types.TextContent( type="text", text=f"Error retrieving space information: {data['error']}", ) ] # Format the result space_info = { "id": data.get("id", ""), "name": data.get("spaceId", ""), "author": data.get("author", ""), "sdk": data.get("sdk", ""), "tags": data.get("tags", []), "likes": data.get("likes", 0), "lastModified": data.get("lastModified", ""), "description": data.get("description", "No description available"), "url": f"https://huggingface.co/spaces/{space_id}", } return [types.TextContent(type="text", text=json.dumps(space_info, indent=2))]
- src/huggingface/server.py:155-168 (schema)Schema and registration of the 'get-space-info' tool in the @server.list_tools() handler. Defines the tool name, description, and input schema requiring a 'space_id' string.types.Tool( name="get-space-info", description="Get detailed information about a specific Space", inputSchema={ "type": "object", "properties": { "space_id": { "type": "string", "description": "The ID of the Space (e.g., 'huggingface/diffusers-demo')", }, }, "required": ["space_id"], }, ),
- src/huggingface/server.py:36-47 (helper)Shared helper function 'make_hf_request' used by the get-space-info handler to perform HTTP GET requests to Hugging Face API endpoints with error handling.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)}