Merge pull request #697 from escapade-mckv/mcp-fetch-issue

chore(dev): reduce smithery api page size
This commit is contained in:
Bobbie 2025-06-10 00:45:02 +05:30 committed by GitHub
commit f7991c37fa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 4 additions and 56 deletions

View File

@ -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)
):
"""

View File

@ -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<BrowseDialogProps> = ({
const [searchQuery, setSearchQuery] = useState('');
const [selectedCategory, setSelectedCategory] = useState<string | null>(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<BrowseDialogProps> = ({
onServerSelect={onServerSelect}
onCategorySelect={setSelectedCategory}
/>
) : popularServers ? (
<div className="space-y-3">
<h3 className="text-sm font-semibold text-muted-foreground">Popular Servers</h3>
<div className="grid grid-cols-1 md:grid-cols-2 gap-3">
{popularServers.servers.map((server) => (
<McpServerCard
key={server.qualifiedName}
server={server}
onClick={onServerSelect}
/>
))}
</div>
</div>
) : null}
</>
)}

View File

@ -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<PopularServersResponse> => {
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({