From f5d24de092e43d76212a7f9cfefa7b4aaa9719f2 Mon Sep 17 00:00:00 2001 From: Soumyadas15 Date: Tue, 10 Jun 2025 00:44:05 +0530 Subject: [PATCH] chore(dev): reduce smithery api page size --- backend/mcp_local/api.py | 2 +- .../agents/_components/mcp/browse-dialog.tsx | 18 +-------- .../hooks/react-query/mcp/use-mcp-servers.ts | 40 +------------------ 3 files changed, 4 insertions(+), 56 deletions(-) diff --git a/backend/mcp_local/api.py b/backend/mcp_local/api.py index c946d6ee..62d1f9eb 100644 --- a/backend/mcp_local/api.py +++ b/backend/mcp_local/api.py @@ -295,7 +295,7 @@ async def get_popular_mcp_servers( @router.get("/mcp/popular-servers/v2", response_model=PopularServersV2Response) async def get_popular_mcp_servers_v2( page: int = Query(1, ge=1, description="Page number"), - pageSize: int = Query(200, ge=1, le=500, description="Items per page (max 500 for comprehensive categorization)"), + pageSize: int = Query(100, ge=1, le=200, description="Items per page (max 500 for comprehensive categorization)"), user_id: str = Depends(get_current_user_id_from_jwt) ): """ diff --git a/frontend/src/app/(dashboard)/agents/_components/mcp/browse-dialog.tsx b/frontend/src/app/(dashboard)/agents/_components/mcp/browse-dialog.tsx index 2bfc88b1..0ff721a7 100644 --- a/frontend/src/app/(dashboard)/agents/_components/mcp/browse-dialog.tsx +++ b/frontend/src/app/(dashboard)/agents/_components/mcp/browse-dialog.tsx @@ -4,7 +4,7 @@ import { Input } from '@/components/ui/input'; import { ScrollArea } from '@/components/ui/scroll-area'; import { Button } from '@/components/ui/button'; import { Search, ChevronLeft, ChevronRight } from 'lucide-react'; -import { usePopularMCPServers, usePopularMCPServersV2, useMCPServers } from '@/hooks/react-query/mcp/use-mcp-servers'; +import { usePopularMCPServersV2, useMCPServers } from '@/hooks/react-query/mcp/use-mcp-servers'; import { McpServerCard } from './mcp-server-card'; import { CategorySidebar } from './category-sidebar'; import { SearchResults } from './search-results'; @@ -25,9 +25,8 @@ export const BrowseDialog: React.FC = ({ const [searchQuery, setSearchQuery] = useState(''); const [selectedCategory, setSelectedCategory] = useState(null); const [currentPage, setCurrentPage] = useState(1); - const [pageSize] = useState(200); + const [pageSize] = useState(100); - const { data: popularServers } = usePopularMCPServers(); const { data: popularServersV2, isLoading: isLoadingV2 } = usePopularMCPServersV2(currentPage, pageSize); const { data: searchResults, isLoading: isSearching } = useMCPServers( searchQuery.length > 2 ? searchQuery : undefined @@ -94,19 +93,6 @@ export const BrowseDialog: React.FC = ({ onServerSelect={onServerSelect} onCategorySelect={setSelectedCategory} /> - ) : popularServers ? ( -
-

Popular Servers

-
- {popularServers.servers.map((server) => ( - - ))} -
-
) : null} )} diff --git a/frontend/src/hooks/react-query/mcp/use-mcp-servers.ts b/frontend/src/hooks/react-query/mcp/use-mcp-servers.ts index f59c31f6..be361fe2 100644 --- a/frontend/src/hooks/react-query/mcp/use-mcp-servers.ts +++ b/frontend/src/hooks/react-query/mcp/use-mcp-servers.ts @@ -37,16 +37,6 @@ interface MCPServerDetailResponse { tools?: any[]; } -interface PopularServersResponse { - servers: Array<{ - qualifiedName: string; - displayName: string; - description: string; - icon: string; - category: string; - }>; -} - interface PopularServersV2Response { success: boolean; servers: Array<{ @@ -142,35 +132,7 @@ export const useMCPServerDetails = (qualifiedName: string, enabled: boolean = tr }); }; -export const usePopularMCPServers = () => { - const supabase = createClient(); - - return useQuery({ - queryKey: ['mcp-servers-popular'], - queryFn: async (): Promise => { - const { data: { session } } = await supabase.auth.getSession(); - if (!session) throw new Error('No session'); - - const response = await fetch( - `${API_URL}/mcp/popular-servers`, - { - headers: { - 'Authorization': `Bearer ${session.access_token}`, - }, - } - ); - - if (!response.ok) { - throw new Error('Failed to fetch popular MCP servers'); - } - - return response.json(); - }, - staleTime: 30 * 60 * 1000, - }); -}; - -export const usePopularMCPServersV2 = (page: number = 1, pageSize: number = 200) => { +export const usePopularMCPServersV2 = (page: number = 1, pageSize: number = 50) => { const supabase = createClient(); return useQuery({