@upstash/context7-mcp 2.1.1 → 2.1.3
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/README.md +4 -2
- package/dist/index.js +25 -17
- package/dist/lib/encryption.js +0 -3
- package/dist/lib/utils.js +3 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -139,15 +139,17 @@ Run this command. See [Claude Code MCP docs](https://docs.anthropic.com/en/docs/
|
|
|
139
139
|
#### Claude Code Local Server Connection
|
|
140
140
|
|
|
141
141
|
```sh
|
|
142
|
-
claude mcp add context7 -- npx -y @upstash/context7-mcp --api-key YOUR_API_KEY
|
|
142
|
+
claude mcp add --scope user context7 -- npx -y @upstash/context7-mcp --api-key YOUR_API_KEY
|
|
143
143
|
```
|
|
144
144
|
|
|
145
145
|
#### Claude Code Remote Server Connection
|
|
146
146
|
|
|
147
147
|
```sh
|
|
148
|
-
claude mcp add --header "CONTEXT7_API_KEY: YOUR_API_KEY" --transport http context7 https://mcp.context7.com/mcp
|
|
148
|
+
claude mcp add --scope user --header "CONTEXT7_API_KEY: YOUR_API_KEY" --transport http context7 https://mcp.context7.com/mcp
|
|
149
149
|
```
|
|
150
150
|
|
|
151
|
+
> Remove `--scope user` to install for the current project only.
|
|
152
|
+
|
|
151
153
|
</details>
|
|
152
154
|
|
|
153
155
|
<details>
|
package/dist/index.js
CHANGED
|
@@ -108,7 +108,18 @@ server.registerTool("resolve-library-id", {
|
|
|
108
108
|
title: "Resolve Context7 Library ID",
|
|
109
109
|
description: `Resolves a package/product name to a Context7-compatible library ID and returns matching libraries.
|
|
110
110
|
|
|
111
|
-
You MUST call this function before '
|
|
111
|
+
You MUST call this function before 'Query Documentation' tool 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.
|
|
112
|
+
|
|
113
|
+
Each result includes:
|
|
114
|
+
- Library ID: Context7-compatible identifier (format: /org/project)
|
|
115
|
+
- Name: Library or package name
|
|
116
|
+
- Description: Short summary
|
|
117
|
+
- Code Snippets: Number of available code examples
|
|
118
|
+
- Source Reputation: Authority indicator (High, Medium, Low, or Unknown)
|
|
119
|
+
- Benchmark Score: Quality indicator (100 is the highest score)
|
|
120
|
+
- 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.
|
|
121
|
+
|
|
122
|
+
For best results, select libraries based on name match, source reputation, snippet coverage, benchmark score, and relevance to your use case.
|
|
112
123
|
|
|
113
124
|
Selection Process:
|
|
114
125
|
1. Analyze the query to understand what library/package the user is looking for
|
|
@@ -131,7 +142,7 @@ IMPORTANT: Do not call this tool more than 3 times per question. If you cannot f
|
|
|
131
142
|
inputSchema: {
|
|
132
143
|
query: z
|
|
133
144
|
.string()
|
|
134
|
-
.describe("The
|
|
145
|
+
.describe("The question or task you need help with. This is used to rank library results by relevance to what the user is trying to accomplish. The query is sent to the Context7 API for processing. Do not include any sensitive or confidential information such as API keys, passwords, credentials, personal data, or proprietary code in your query."),
|
|
135
146
|
libraryName: z
|
|
136
147
|
.string()
|
|
137
148
|
.describe("Library name to search for and retrieve a Context7-compatible library ID."),
|
|
@@ -156,19 +167,6 @@ IMPORTANT: Do not call this tool more than 3 times per question. If you cannot f
|
|
|
156
167
|
const resultsText = formatSearchResults(searchResponse);
|
|
157
168
|
const responseText = `Available Libraries:
|
|
158
169
|
|
|
159
|
-
Each result includes:
|
|
160
|
-
- Library ID: Context7-compatible identifier (format: /org/project)
|
|
161
|
-
- Name: Library or package name
|
|
162
|
-
- Description: Short summary
|
|
163
|
-
- Code Snippets: Number of available code examples
|
|
164
|
-
- Source Reputation: Authority indicator (High, Medium, Low, or Unknown)
|
|
165
|
-
- Benchmark Score: Quality indicator (100 is the highest score)
|
|
166
|
-
- 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.
|
|
167
|
-
|
|
168
|
-
For best results, select libraries based on name match, source reputation, snippet coverage, benchmark score, and relevance to your use case.
|
|
169
|
-
|
|
170
|
-
----------
|
|
171
|
-
|
|
172
170
|
${resultsText}`;
|
|
173
171
|
return {
|
|
174
172
|
content: [
|
|
@@ -183,7 +181,7 @@ server.registerTool("query-docs", {
|
|
|
183
181
|
title: "Query Documentation",
|
|
184
182
|
description: `Retrieves and queries up-to-date documentation and code examples from Context7 for any programming library or framework.
|
|
185
183
|
|
|
186
|
-
You must call '
|
|
184
|
+
You must call 'Resolve Context7 Library ID' tool 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.
|
|
187
185
|
|
|
188
186
|
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.`,
|
|
189
187
|
inputSchema: {
|
|
@@ -192,7 +190,7 @@ IMPORTANT: Do not call this tool more than 3 times per question. If you cannot f
|
|
|
192
190
|
.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'."),
|
|
193
191
|
query: z
|
|
194
192
|
.string()
|
|
195
|
-
.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'.
|
|
193
|
+
.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'. The query is sent to the Context7 API for processing. Do not include any sensitive or confidential information such as API keys, passwords, credentials, personal data, or proprietary code in your query."),
|
|
196
194
|
},
|
|
197
195
|
annotations: {
|
|
198
196
|
readOnlyHint: true,
|
|
@@ -247,6 +245,16 @@ async function main() {
|
|
|
247
245
|
extractHeaderValue(req.headers["x_api_key"]));
|
|
248
246
|
};
|
|
249
247
|
const handleMcpRequest = async (req, res, requireAuth) => {
|
|
248
|
+
// Reject GET requests — this server is stateless and does not send server-initiated
|
|
249
|
+
// notifications, so SSE streams serve no purpose and cause mass NGINX timeouts.
|
|
250
|
+
// Returning 405 is spec-compliant per MCP StreamableHTTP (2025-03-26).
|
|
251
|
+
if (req.method === "GET") {
|
|
252
|
+
return res.status(405).json({
|
|
253
|
+
jsonrpc: "2.0",
|
|
254
|
+
error: { code: -32000, message: "Server does not support GET requests" },
|
|
255
|
+
id: null,
|
|
256
|
+
});
|
|
257
|
+
}
|
|
250
258
|
try {
|
|
251
259
|
const apiKey = extractApiKey(req);
|
|
252
260
|
const resourceUrl = RESOURCE_URL;
|
package/dist/lib/encryption.js
CHANGED
|
@@ -3,9 +3,6 @@ import { SERVER_VERSION } from "./constants.js";
|
|
|
3
3
|
const DEFAULT_ENCRYPTION_KEY = "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f";
|
|
4
4
|
const ENCRYPTION_KEY = process.env.CLIENT_IP_ENCRYPTION_KEY || DEFAULT_ENCRYPTION_KEY;
|
|
5
5
|
const ALGORITHM = "aes-256-cbc";
|
|
6
|
-
if (ENCRYPTION_KEY === DEFAULT_ENCRYPTION_KEY) {
|
|
7
|
-
console.warn("WARNING: Using default CLIENT_IP_ENCRYPTION_KEY.");
|
|
8
|
-
}
|
|
9
6
|
function validateEncryptionKey(key) {
|
|
10
7
|
// Must be exactly 64 hex characters (32 bytes)
|
|
11
8
|
return /^[0-9a-fA-F]{64}$/.test(key);
|
package/dist/lib/utils.js
CHANGED
|
@@ -41,6 +41,9 @@ export function formatSearchResult(result) {
|
|
|
41
41
|
if (result.versions !== undefined && result.versions.length > 0) {
|
|
42
42
|
formattedResult.push(`- Versions: ${result.versions.join(", ")}`);
|
|
43
43
|
}
|
|
44
|
+
if (result.source) {
|
|
45
|
+
formattedResult.push(`- Source: ${result.source}`);
|
|
46
|
+
}
|
|
44
47
|
// Join all parts with newlines
|
|
45
48
|
return formattedResult.join("\n");
|
|
46
49
|
}
|