@upstash/context7-mcp 1.0.34-canary.3 → 1.0.34-canary.4
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 +37 -13
- package/dist/lib/api.js +3 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -77,9 +77,22 @@ 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.`,
|
|
83
96
|
inputSchema: {
|
|
84
97
|
query: z
|
|
85
98
|
.string()
|
|
@@ -104,11 +117,28 @@ Select the best match based on: name similarity, description relevance, snippet
|
|
|
104
117
|
],
|
|
105
118
|
};
|
|
106
119
|
}
|
|
120
|
+
const resultsText = formatSearchResults(searchResponse);
|
|
121
|
+
const responseText = `Available Libraries:
|
|
122
|
+
|
|
123
|
+
Each result includes:
|
|
124
|
+
- Library ID: Context7-compatible identifier (format: /org/project)
|
|
125
|
+
- Name: Library or package name
|
|
126
|
+
- Description: Short summary
|
|
127
|
+
- Code Snippets: Number of available code examples
|
|
128
|
+
- Source Reputation: Authority indicator (High, Medium, Low, or Unknown)
|
|
129
|
+
- Benchmark Score: Quality indicator (100 is the highest score)
|
|
130
|
+
- 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.
|
|
131
|
+
|
|
132
|
+
For best results, select libraries based on name match, source reputation, snippet coverage, benchmark score, and relevance to your use case.
|
|
133
|
+
|
|
134
|
+
----------
|
|
135
|
+
|
|
136
|
+
${resultsText}`;
|
|
107
137
|
return {
|
|
108
138
|
content: [
|
|
109
139
|
{
|
|
110
140
|
type: "text",
|
|
111
|
-
text:
|
|
141
|
+
text: responseText,
|
|
112
142
|
},
|
|
113
143
|
],
|
|
114
144
|
};
|
|
@@ -117,20 +147,14 @@ server.registerTool("query-docs", {
|
|
|
117
147
|
title: "Query Documentation",
|
|
118
148
|
description: `Retrieves and queries up-to-date documentation and code examples from Context7 for any programming library or framework.
|
|
119
149
|
|
|
120
|
-
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
|
-
|
|
122
|
-
USE THIS TOOL TO:
|
|
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`,
|
|
150
|
+
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.`,
|
|
127
151
|
inputSchema: {
|
|
152
|
+
libraryId: z
|
|
153
|
+
.string()
|
|
154
|
+
.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
155
|
query: z
|
|
129
156
|
.string()
|
|
130
157
|
.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
158
|
},
|
|
135
159
|
}, async ({ query, libraryId }) => {
|
|
136
160
|
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
|
}
|