Skip to content

Commit a7365b5

Browse files
authored
Merge pull request #62 from mcp-agents-ai/feat/leixu/mcp_server_info_enrich
Feat/leixu/mcp server info enrich
2 parents 2c4ff3f + d8d0a80 commit a7365b5

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
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/githubEnrichment.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export interface EnrichedMcpServer extends McpServer {
3737
latest_commit_id?: string;
3838
fork_count?: number;
3939
owner_name?: string;
40-
license_type?: string | null;
40+
license_type?: string | undefined;
4141
}
4242

4343
/**
@@ -115,7 +115,7 @@ export interface GithubRepoInfo {
115115
latest_commit_id: string;
116116
fork_count: number;
117117
owner_name: string;
118-
license_type: string | null; // Will be null if no license information available
118+
license_type: string | undefined; // Will be undefined if no license information available
119119
}
120120

121121
/**
@@ -161,7 +161,7 @@ export async function fetchGithubInfo(githubUrl: string): Promise<GithubRepoInfo
161161
latest_commit_id: latestCommit.sha || '',
162162
fork_count: repoData.forks_count,
163163
owner_name: repoData.owner?.login || owner,
164-
license_type: repoData.license?.spdx_id || null
164+
license_type: repoData.license?.spdx_id
165165
};
166166
} catch (error) {
167167
console.error(`Error fetching repository information for ${githubUrl}:`, error);
@@ -395,7 +395,7 @@ export async function enrichServerData(server: McpServer, locale: string = 'en')
395395
enrichedServer.latest_commit_id = githubInfo.latest_commit_id;
396396
enrichedServer.fork_count = githubInfo.fork_count;
397397
enrichedServer.owner_name = githubInfo.owner_name;
398-
enrichedServer.license_type = githubInfo.license_type || undefined;
398+
enrichedServer.license_type = githubInfo.license_type;
399399
}
400400

401401
// Cache the enriched data using locale-specific key

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)