Skip to content

Commit d8d0a80

Browse files
committed
feat: Add githubLatestCommit and githubForks fields to MCPServer interface; enhance sorting by githubStars in search_servers route
1 parent e08ef93 commit d8d0a80

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

client/src/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,7 @@ export interface MCPServer {
2323
features?: string[];
2424
prerequisites?: string[];
2525
lastEnrichmentTime?: number;
26+
githubLatestCommit?: string;
27+
githubForks?: number;
28+
licenseType?: string | null;
2629
}

server/src/lib/mcpServers.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,13 @@ export interface McpServer {
2323
createdAt?: string;
2424
updatedAt?: string;
2525
hubId: string;
26-
[key: string]: string | number | boolean | string[] | undefined;
26+
isOfficialIntegration?: boolean;
27+
isReferenceServer?: boolean;
28+
isCommunityServer?: boolean;
29+
githubLatestCommit?: string;
30+
githubForks?: number;
31+
licenseType?: string | null;
32+
[key: string]: string | number | boolean | string[] | null | undefined;
2733
}
2834

2935
// In-memory cache for MCP servers data - now keyed by locale

server/src/routes/hub.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,14 @@ router.post('/search_servers', async (req: Request, res: Response): Promise<void
187187
}
188188

189189
// Sort servers so that isRecommended: true servers appear first
190+
// Then sort by githubStars in descending order
190191
filteredServers.sort((a, b) => {
191192
// If a is recommended and b is not, a comes first
192193
if (a.isRecommended && !b.isRecommended) return -1;
193194
// If b is recommended and a is not, b comes first
194195
if (!a.isRecommended && b.isRecommended) return 1;
195-
// If both have the same recommendation status, maintain original order
196-
return 0;
196+
// If both have the same recommendation status, sort by githubStars (descending)
197+
return (b.githubStars || 0) - (a.githubStars || 0);
197198
});
198199

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

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

234-
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()}`);
235+
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()}`);
235236
} catch (error) {
236237
console.error('Error serving filtered MCP servers:', error);
237238
res.status(500).json({ error: 'Internal server error' });

0 commit comments

Comments
 (0)