Context7 Platform -- Up-to-date docs for AI agents
refactor: replace GitHub stars with trust score in search results and API types
Abdusshh5326cc389066
diff --git a/src/index.ts b/src/index.tsindex 23874593..5bac298f 100644--- a/src/index.ts+++ b/src/index.ts@@ -37,17 +37,25 @@ const server = new McpServer({// Register Context7 toolsserver.tool("resolve-library-id",- `Resolves a package name to a Context7-compatible library ID and returns a list of matching libraries.+ `Resolves a package/product name to a Context7-compatible library ID and returns a list of matching libraries.You MUST call this function before 'get-library-docs' to obtain a valid Context7-compatible library ID.-When selecting the best match, consider:-- Name similarity to the query-- Description relevance-- Code Snippet count (documentation coverage)-- GitHub Stars (popularity)--Return the selected library ID and explain your choice. If there are multiple good matches, mention this but proceed with the most relevant one.`,+Selection Process:+1. Analyze the query to understand what library/package the user is looking for+2. Return the most relevant match based on:+- Name similarity to the query (exact matches prioritized)+- Description relevance to the query's intent+- Documentation coverage (prioritize libraries with higher Code Snippet counts)+- Trust score (consider libraries with scores of 7-10 more authoritative)++Response Format:+- Return the selected library ID in a clearly marked section+- Provide a brief explanation for why this library was chosen+- If multiple good matches exist, acknowledge this but proceed with the most relevant one+- If no good matches exist, clearly state this and suggest query refinements++For ambiguous queries, request clarification before proceeding with a best-guess match.`,{libraryName: z.string()@@ -91,11 +99,11 @@ Each result includes:- Name: Library or package name- Description: Short summary- Code Snippets: Number of available code examples-- GitHub Stars: Popularity indicator+- Trust Score: Authority indicator-For best results, select libraries based on name match, popularity (stars), snippet coverage, and relevance to your use case.+For best results, select libraries based on name match, trust score, snippet coverage, and relevance to your use case.----+----------${resultsText}`,},diff --git a/src/lib/types.ts b/src/lib/types.tsindex f107b70d..6bfe10f4 100644--- a/src/lib/types.ts+++ b/src/lib/types.ts@@ -1,14 +1,15 @@export interface SearchResult {id: string;title: string;- description?: string;+ description: string;branch: string;- lastUpdate: string;+ lastUpdateDate: string;state: DocumentState;totalTokens: number;totalSnippets: number;totalPages: number;- stars: number;+ stars?: number;+ trustScore?: number;}export interface SearchResponse {diff --git a/src/lib/utils.ts b/src/lib/utils.tsindex 24a1602e..742e9bf0 100644--- a/src/lib/utils.ts+++ b/src/lib/utils.ts@@ -20,9 +20,9 @@ export function formatSearchResult(result: SearchResult): string {formattedResult.push(`- Code Snippets: ${result.totalSnippets}`);}- // Only add GitHub stars if it's a valid value- if (result.stars !== -1 && result.stars !== undefined) {- formattedResult.push(`- GitHub Stars: ${result.stars}`);+ // Only add trust score if it's a valid value+ if (result.trustScore !== -1 && result.trustScore !== undefined) {+ formattedResult.push(`- Trust Score: ${result.trustScore}`);}// Join all parts with newlines@@ -42,5 +42,5 @@ export function formatSearchResults(searchResponse: SearchResponse): string {}const formattedResults = searchResponse.results.map(formatSearchResult);- return formattedResults.join("\n---\n");+ return formattedResults.join("\n----------\n");}