@@ -619,7 +619,14 @@ <h1 class="serif text-4xl md:text-5xl mb-2 gradient-text">
619619
620620CRITICAL RULES FOR TOOL SELECTION:
6216211. If user asks about ORGANIZATIONS (like "which organizations", "organizations with most datasets", "list organizations"):
622- → Use ckan_organization_list with all_fields=true and sort="package_count desc"
622+ → Use ckan_organization_list with ONLY these parameters:
623+ {
624+ "server_url": "CKAN_SERVER",
625+ "all_fields": true,
626+ "limit": 100,
627+ "response_format": "json"
628+ }
629+ Do NOT use sort parameter - results will be sorted client-side by package_count
623630
6246312. If user asks about DATASETS (like "find datasets about X", "datasets on topic Y"):
625632 → Use ckan_package_search or ckan_find_relevant_datasets
@@ -638,7 +645,7 @@ <h1 class="serif text-4xl md:text-5xl mb-2 gradient-text">
638645 }
639646}
640647
641- Always include server_url parameter .
648+ Always include server_url and response_format="json" .
642649Use conversation context to refine queries.` ;
643650
644651 const contents = [
@@ -775,7 +782,15 @@ <h1 class="serif text-4xl md:text-5xl mb-2 gradient-text">
775782 // Handle different tool types
776783 if ( tool . includes ( "organization" ) ) {
777784 // Organization tools
778- const items = data . results || data || [ ] ;
785+ let items = data . results || data || [ ] ;
786+
787+ // Sort by package_count descending (client-side)
788+ items = items . sort ( ( a , b ) => {
789+ const countA = a . package_count || 0 ;
790+ const countB = b . package_count || 0 ;
791+ return countB - countA ;
792+ } ) ;
793+
779794 const summary = document . createElement ( "p" ) ;
780795 summary . className = "text-sm font-medium mb-1" ;
781796 summary . style . color = "var(--primary)" ;
0 commit comments