mirror of https://github.com/kortix-ai/suna.git
Merge pull request #697 from escapade-mckv/mcp-fetch-issue
chore(dev): reduce smithery api page size
This commit is contained in:
commit
f7991c37fa
|
@ -295,7 +295,7 @@ async def get_popular_mcp_servers(
|
||||||
@router.get("/mcp/popular-servers/v2", response_model=PopularServersV2Response)
|
@router.get("/mcp/popular-servers/v2", response_model=PopularServersV2Response)
|
||||||
async def get_popular_mcp_servers_v2(
|
async def get_popular_mcp_servers_v2(
|
||||||
page: int = Query(1, ge=1, description="Page number"),
|
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)
|
user_id: str = Depends(get_current_user_id_from_jwt)
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { Input } from '@/components/ui/input';
|
||||||
import { ScrollArea } from '@/components/ui/scroll-area';
|
import { ScrollArea } from '@/components/ui/scroll-area';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { Search, ChevronLeft, ChevronRight } from 'lucide-react';
|
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 { McpServerCard } from './mcp-server-card';
|
||||||
import { CategorySidebar } from './category-sidebar';
|
import { CategorySidebar } from './category-sidebar';
|
||||||
import { SearchResults } from './search-results';
|
import { SearchResults } from './search-results';
|
||||||
|
@ -25,9 +25,8 @@ export const BrowseDialog: React.FC<BrowseDialogProps> = ({
|
||||||
const [searchQuery, setSearchQuery] = useState('');
|
const [searchQuery, setSearchQuery] = useState('');
|
||||||
const [selectedCategory, setSelectedCategory] = useState<string | null>(null);
|
const [selectedCategory, setSelectedCategory] = useState<string | null>(null);
|
||||||
const [currentPage, setCurrentPage] = useState(1);
|
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: popularServersV2, isLoading: isLoadingV2 } = usePopularMCPServersV2(currentPage, pageSize);
|
||||||
const { data: searchResults, isLoading: isSearching } = useMCPServers(
|
const { data: searchResults, isLoading: isSearching } = useMCPServers(
|
||||||
searchQuery.length > 2 ? searchQuery : undefined
|
searchQuery.length > 2 ? searchQuery : undefined
|
||||||
|
@ -94,19 +93,6 @@ export const BrowseDialog: React.FC<BrowseDialogProps> = ({
|
||||||
onServerSelect={onServerSelect}
|
onServerSelect={onServerSelect}
|
||||||
onCategorySelect={setSelectedCategory}
|
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}
|
) : null}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -37,16 +37,6 @@ interface MCPServerDetailResponse {
|
||||||
tools?: any[];
|
tools?: any[];
|
||||||
}
|
}
|
||||||
|
|
||||||
interface PopularServersResponse {
|
|
||||||
servers: Array<{
|
|
||||||
qualifiedName: string;
|
|
||||||
displayName: string;
|
|
||||||
description: string;
|
|
||||||
icon: string;
|
|
||||||
category: string;
|
|
||||||
}>;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface PopularServersV2Response {
|
interface PopularServersV2Response {
|
||||||
success: boolean;
|
success: boolean;
|
||||||
servers: Array<{
|
servers: Array<{
|
||||||
|
@ -142,35 +132,7 @@ export const useMCPServerDetails = (qualifiedName: string, enabled: boolean = tr
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const usePopularMCPServers = () => {
|
export const usePopularMCPServersV2 = (page: number = 1, pageSize: number = 50) => {
|
||||||
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) => {
|
|
||||||
const supabase = createClient();
|
const supabase = createClient();
|
||||||
|
|
||||||
return useQuery({
|
return useQuery({
|
||||||
|
|
Loading…
Reference in New Issue