Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions client/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,7 @@ export interface MCPServer {
features?: string[];
prerequisites?: string[];
lastEnrichmentTime?: number;
githubLatestCommit?: string;
githubForks?: number;
licenseType?: string | null;
}
8 changes: 4 additions & 4 deletions server/src/lib/githubEnrichment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export interface EnrichedMcpServer extends McpServer {
latest_commit_id?: string;
fork_count?: number;
owner_name?: string;
license_type?: string | null;
license_type?: string | undefined;
}

/**
Expand Down Expand Up @@ -115,7 +115,7 @@ export interface GithubRepoInfo {
latest_commit_id: string;
fork_count: number;
owner_name: string;
license_type: string | null; // Will be null if no license information available
license_type: string | undefined; // Will be undefined if no license information available
}

/**
Expand Down Expand Up @@ -161,7 +161,7 @@ export async function fetchGithubInfo(githubUrl: string): Promise<GithubRepoInfo
latest_commit_id: latestCommit.sha || '',
fork_count: repoData.forks_count,
owner_name: repoData.owner?.login || owner,
license_type: repoData.license?.spdx_id || null
license_type: repoData.license?.spdx_id
};
} catch (error) {
console.error(`Error fetching repository information for ${githubUrl}:`, error);
Expand Down Expand Up @@ -395,7 +395,7 @@ export async function enrichServerData(server: McpServer, locale: string = 'en')
enrichedServer.latest_commit_id = githubInfo.latest_commit_id;
enrichedServer.fork_count = githubInfo.fork_count;
enrichedServer.owner_name = githubInfo.owner_name;
enrichedServer.license_type = githubInfo.license_type || undefined;
enrichedServer.license_type = githubInfo.license_type;
}

// Cache the enriched data using locale-specific key
Expand Down
8 changes: 7 additions & 1 deletion server/src/lib/mcpServers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ export interface McpServer {
createdAt?: string;
updatedAt?: string;
hubId: string;
[key: string]: string | number | boolean | string[] | undefined;
isOfficialIntegration?: boolean;
isReferenceServer?: boolean;
isCommunityServer?: boolean;
githubLatestCommit?: string;
githubForks?: number;
licenseType?: string | null;
[key: string]: string | number | boolean | string[] | null | undefined;
}

// In-memory cache for MCP servers data - now keyed by locale
Expand Down
7 changes: 4 additions & 3 deletions server/src/routes/hub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,14 @@ router.post('/search_servers', async (req: Request, res: Response): Promise<void
}

// Sort servers so that isRecommended: true servers appear first
// Then sort by githubStars in descending order
filteredServers.sort((a, b) => {
// If a is recommended and b is not, a comes first
if (a.isRecommended && !b.isRecommended) return -1;
// If b is recommended and a is not, b comes first
if (!a.isRecommended && b.isRecommended) return 1;
// If both have the same recommendation status, maintain original order
return 0;
// If both have the same recommendation status, sort by githubStars (descending)
return (b.githubStars || 0) - (a.githubStars || 0);
});

// Apply pagination if parameters are provided
Expand Down Expand Up @@ -231,7 +232,7 @@ router.post('/search_servers', async (req: Request, res: Response): Promise<void

const filterInfoString = filterInfo ? `, ${filterInfo}` : '';

console.log(`v1/hub/search_servers Served filtered and sorted MCP servers data (recommended first) for locale: ${requestedLocale}${categoryKey ? `, category: ${categoryKey}` : ''}${filterInfoString}${searchInfo}${page !== undefined && size !== undefined ? `, page: ${page}, size: ${size}` : ''} at ${new Date().toISOString()}`);
console.log(`v1/hub/search_servers Served filtered and sorted MCP servers data (recommended first, then by GitHub stars) for locale: ${requestedLocale}${categoryKey ? `, category: ${categoryKey}` : ''}${filterInfoString}${searchInfo}${page !== undefined && size !== undefined ? `, page: ${page}, size: ${size}` : ''} at ${new Date().toISOString()}`);
} catch (error) {
console.error('Error serving filtered MCP servers:', error);
res.status(500).json({ error: 'Internal server error' });
Expand Down