SELECT 
    s.space_id,
    s.title,
    s.description,
    s.url as space_url,
    s.tags,
    e.endpoint_url as schema_url,
    COUNT(t.tool_name) as tool_count
FROM spaces s
JOIN endpoints e ON s.space_id = e.space_id AND e.endpoint_type = 'schema'
JOIN tools t ON s.space_id = t.space_id
GROUP BY s.space_id, s.title, s.description, s.url, s.tags, e.endpoint_url
HAVING tool_count > 0; 