@upstash/context7-mcp 1.0.34-canary.3 → 1.0.34-canary.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +39 -11
- package/dist/lib/api.js +3 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -77,9 +77,24 @@ server.registerTool("resolve-library-id", {
|
|
|
77
77
|
|
|
78
78
|
You MUST call this function before 'query-docs' to obtain a valid Context7-compatible library ID UNLESS the user explicitly provides a library ID in the format '/org/project' or '/org/project/version' in their query.
|
|
79
79
|
|
|
80
|
-
|
|
80
|
+
Selection Process:
|
|
81
|
+
1. Analyze the query to understand what library/package the user is looking for
|
|
82
|
+
2. Return the most relevant match based on:
|
|
83
|
+
- Name similarity to the query (exact matches prioritized)
|
|
84
|
+
- Description relevance to the query's intent
|
|
85
|
+
- Documentation coverage (prioritize libraries with higher Code Snippet counts)
|
|
86
|
+
- Source reputation (consider libraries with High or Medium reputation more authoritative)
|
|
87
|
+
- Benchmark Score: Quality indicator (100 is the highest score)
|
|
81
88
|
|
|
82
|
-
|
|
89
|
+
Response Format:
|
|
90
|
+
- Return the selected library ID in a clearly marked section
|
|
91
|
+
- Provide a brief explanation for why this library was chosen
|
|
92
|
+
- If multiple good matches exist, acknowledge this but proceed with the most relevant one
|
|
93
|
+
- If no good matches exist, clearly state this and suggest query refinements
|
|
94
|
+
|
|
95
|
+
For ambiguous queries, request clarification before proceeding with a best-guess match.
|
|
96
|
+
|
|
97
|
+
IMPORTANT: Do not call this tool more than 3 times per question. If you cannot find what you need after 3 calls, use the best result you have.`,
|
|
83
98
|
inputSchema: {
|
|
84
99
|
query: z
|
|
85
100
|
.string()
|
|
@@ -104,11 +119,28 @@ Select the best match based on: name similarity, description relevance, snippet
|
|
|
104
119
|
],
|
|
105
120
|
};
|
|
106
121
|
}
|
|
122
|
+
const resultsText = formatSearchResults(searchResponse);
|
|
123
|
+
const responseText = `Available Libraries:
|
|
124
|
+
|
|
125
|
+
Each result includes:
|
|
126
|
+
- Library ID: Context7-compatible identifier (format: /org/project)
|
|
127
|
+
- Name: Library or package name
|
|
128
|
+
- Description: Short summary
|
|
129
|
+
- Code Snippets: Number of available code examples
|
|
130
|
+
- Source Reputation: Authority indicator (High, Medium, Low, or Unknown)
|
|
131
|
+
- Benchmark Score: Quality indicator (100 is the highest score)
|
|
132
|
+
- Versions: List of versions if available. Use one of those versions if the user provides a version in their query. The format of the version is /org/project/version.
|
|
133
|
+
|
|
134
|
+
For best results, select libraries based on name match, source reputation, snippet coverage, benchmark score, and relevance to your use case.
|
|
135
|
+
|
|
136
|
+
----------
|
|
137
|
+
|
|
138
|
+
${resultsText}`;
|
|
107
139
|
return {
|
|
108
140
|
content: [
|
|
109
141
|
{
|
|
110
142
|
type: "text",
|
|
111
|
-
text:
|
|
143
|
+
text: responseText,
|
|
112
144
|
},
|
|
113
145
|
],
|
|
114
146
|
};
|
|
@@ -119,18 +151,14 @@ server.registerTool("query-docs", {
|
|
|
119
151
|
|
|
120
152
|
You must call 'resolve-library-id' first to obtain the exact Context7-compatible library ID required to use this tool, UNLESS the user explicitly provides a library ID in the format '/org/project' or '/org/project/version' in their query.
|
|
121
153
|
|
|
122
|
-
|
|
123
|
-
- Get current, accurate documentation for libraries (e.g., React, Next.js, Express, LangChain)
|
|
124
|
-
- Find working code examples and implementation patterns
|
|
125
|
-
- Answer "how do I..." questions about specific libraries
|
|
126
|
-
- Look up API references, configuration options, and best practices`,
|
|
154
|
+
IMPORTANT: Do not call this tool more than 3 times per question. If you cannot find what you need after 3 calls, use the best information you have.`,
|
|
127
155
|
inputSchema: {
|
|
156
|
+
libraryId: z
|
|
157
|
+
.string()
|
|
158
|
+
.describe("Exact Context7-compatible library ID (e.g., '/mongodb/docs', '/vercel/next.js', '/supabase/supabase', '/vercel/next.js/v14.3.0-canary.87') retrieved from 'resolve-library-id' or directly from user query in the format '/org/project' or '/org/project/version'."),
|
|
128
159
|
query: z
|
|
129
160
|
.string()
|
|
130
161
|
.describe("The question or task you need help with. Be specific and include relevant details. Good: 'How to set up authentication with JWT in Express.js' or 'React useEffect cleanup function examples'. Bad: 'auth' or 'hooks'. IMPORTANT: Do not include any sensitive or confidential information such as API keys, passwords, credentials, or personal data in your query."),
|
|
131
|
-
libraryId: z
|
|
132
|
-
.string()
|
|
133
|
-
.describe("Context7-compatible library ID (e.g., '/mongodb/docs' or '/vercel/next.js'). Retrieved from 'resolve-library-id' or directly from user query in the format '/org/project' or '/org/project/version'."),
|
|
134
162
|
},
|
|
135
163
|
}, async ({ query, libraryId }) => {
|
|
136
164
|
const ctx = requestContext.getStore();
|
package/dist/lib/api.js
CHANGED
|
@@ -105,7 +105,9 @@ export async function fetchLibraryContext(request, clientIp, apiKey) {
|
|
|
105
105
|
}
|
|
106
106
|
const text = await response.text();
|
|
107
107
|
if (!text) {
|
|
108
|
-
return {
|
|
108
|
+
return {
|
|
109
|
+
data: "Documentation not found or not finalized for this library. This might have happened because you used an invalid Context7-compatible library ID. To get a valid Context7-compatible library ID, use the 'resolve-library-id' with the package name you wish to retrieve documentation for.",
|
|
110
|
+
};
|
|
109
111
|
}
|
|
110
112
|
return { data: text };
|
|
111
113
|
}
|