@upstash/context7-mcp 1.0.17 → 1.0.19

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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Context7 MCP - Up-to-date Code Docs For Any Prompt
4
4
 
5
- [![Website](https://img.shields.io/badge/Website-context7.com-blue)](https://context7.com) [![smithery badge](https://smithery.ai/badge/@upstash/context7-mcp)](https://smithery.ai/server/@upstash/context7-mcp)
5
+ [![Website](https://img.shields.io/badge/Website-context7.com-blue)](https://context7.com) [![smithery badge](https://smithery.ai/badge/@upstash/context7-mcp)](https://smithery.ai/server/@upstash/context7-mcp) [![NPM Version](https://img.shields.io/npm/v/%40upstash%2Fcontext7-mcp?color=red)](https://www.npmjs.com/package/@upstash/context7-mcp) [![MIT licensed](https://img.shields.io/npm/l/%40upstash%2Fcontext7-mcp)](./LICENSE)
6
6
 
7
7
  [![Install MCP Server](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en/install-mcp?name=context7&config=eyJ1cmwiOiJodHRwczovL21jcC5jb250ZXh0Ny5jb20vbWNwIn0%3D) [<img alt="Install in VS Code (npx)" src="https://img.shields.io/badge/Install%20in%20VS%20Code-0098FF?style=for-the-badge&logo=visualstudiocode&logoColor=white">](https://insiders.vscode.dev/redirect?url=vscode%3Amcp%2Finstall%3F%7B%22name%22%3A%22context7%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40upstash%2Fcontext7-mcp%40latest%22%5D%7D)
8
8
 
@@ -36,7 +36,7 @@ Context7 fetches up-to-date code examples and documentation right into your LLM'
36
36
  - 2️⃣ Tell the LLM to `use context7`
37
37
  - 3️⃣ Get working code answers
38
38
 
39
- No tab-switching, no hallucinated APIs that don't exist, no outdated code generations.
39
+ No tab-switching, no hallucinated APIs that don't exist, no outdated code generation.
40
40
 
41
41
  ## 📚 Adding Projects
42
42
 
@@ -217,6 +217,28 @@ You can easily install Context7 through the [Cline MCP Server Marketplace](https
217
217
  3. Use the search bar within the **Marketplace** tab to find _Context7_.
218
218
  4. Click the **Install** button.
219
219
 
220
+ Or you can directly edit MCP servers configuration:
221
+
222
+ 1. Open **Cline**.
223
+ 2. Click the hamburger menu icon (☰) to enter the **MCP Servers** section.
224
+ 3. Choose **Remote Servers** tab.
225
+ 4. Click the **Edit Configuration** button.
226
+ 5. Add context7 to `mcpServers`:
227
+
228
+ ```json
229
+ {
230
+ "mcpServers": {
231
+ "context7": {
232
+ "url": "https://mcp.context7.com/mcp",
233
+ "type": "streamableHttp",
234
+ "headers": {
235
+ "Authorization": "Bearer YOUR_API_KEY"
236
+ }
237
+ }
238
+ }
239
+ }
240
+ ```
241
+
220
242
  </details>
221
243
 
222
244
  <details>
@@ -299,7 +321,10 @@ Add this to your Roo Code MCP configuration file. See [Roo Code MCP docs](https:
299
321
  "mcpServers": {
300
322
  "context7": {
301
323
  "type": "streamable-http",
302
- "url": "https://mcp.context7.com/mcp"
324
+ "url": "https://mcp.context7.com/mcp",
325
+ "headers": {
326
+ "CONTEXT7_API_KEY": "YOUR_API_KEY"
327
+ }
303
328
  }
304
329
  }
305
330
  }
@@ -386,7 +411,7 @@ Open Claude Desktop developer settings and edit your `claude_desktop_config.json
386
411
  <details>
387
412
  <summary><b>Install in Opencode</b></summary>
388
413
 
389
- Add this to your Opencode configuration file. See [Opencode MCP docs](https://opencode.ai/docs/mcp-servers) docs for more info.
414
+ Add this to your Opencode configuration file. See [Opencode MCP docs](https://opencode.ai/docs/mcp-servers) for more info.
390
415
 
391
416
  #### Opencode Remote Server Connection
392
417
 
@@ -418,6 +443,7 @@ Add this to your Opencode configuration file. See [Opencode MCP docs](https://op
418
443
  ```
419
444
 
420
445
  </details>
446
+
421
447
  <details>
422
448
  <summary><b>Install in OpenAI Codex</b></summary>
423
449
 
@@ -431,6 +457,42 @@ args = ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
431
457
  command = "npx"
432
458
  ```
433
459
 
460
+ ⚠️ Windows Notes
461
+
462
+ On Windows, some users may encounter request timed out errors with the default configuration.
463
+ In that case, explicitly configure the MCP server with the full path to Node.js and the installed package:
464
+
465
+ ```toml
466
+ [mcp_servers.context7]
467
+ command = "C:\\Program Files\\nodejs\\node.exe"
468
+ args = [
469
+ "C:\\Users\\yourname\\AppData\\Roaming\\npm\\node_modules\\@upstash\\context7-mcp\\dist\\index.js",
470
+ "--transport",
471
+ "stdio",
472
+ "--api-key",
473
+ "YOUR_API_KEY"
474
+ ]
475
+ ```
476
+
477
+ Alternatively, you can use the following configuration:
478
+
479
+ ```toml
480
+ [mcp_servers.context7]
481
+ command = "cmd"
482
+ args = [
483
+ "/c",
484
+ "npx",
485
+ "-y",
486
+ "@upstash/context7-mcp",
487
+ "--api-key",
488
+ "YOUR_API_KEY"
489
+ ]
490
+ env = { SystemRoot="C:\\Windows" }
491
+ startup_timeout_ms = 20_000
492
+ ```
493
+
494
+ This ensures Codex CLI works reliably on Windows.
495
+
434
496
  </details>
435
497
 
436
498
  <details>
@@ -438,7 +500,7 @@ command = "npx"
438
500
 
439
501
  See [JetBrains AI Assistant Documentation](https://www.jetbrains.com/help/ai-assistant/configure-an-mcp-server.html) for more details.
440
502
 
441
- 1. In JetBrains IDEs go to `Settings` -> `Tools` -> `AI Assistant` -> `Model Context Protocol (MCP)`
503
+ 1. In JetBrains IDEs, go to `Settings` -> `Tools` -> `AI Assistant` -> `Model Context Protocol (MCP)`
442
504
  2. Click `+ Add`.
443
505
  3. Click on `Command` in the top-left corner of the dialog and select the As JSON option from the list
444
506
  4. Add this configuration and click `OK`
@@ -621,7 +683,7 @@ If you prefer to run the MCP server in a Docker container:
621
683
  <details>
622
684
  <summary><b>Install Using the Desktop Extension</b></summary>
623
685
 
624
- Install the [context7.dxt](dxt/context7.dxt) file under the dxt folder and add it to your client. For more information please check out [the desktop extensions docs](https://github.com/anthropics/dxt#desktop-extensions-dxt).
686
+ Install the [context7.mcpb](mcpb/context7.mcpb) file under the mcpb folder and add it to your client. For more information, please check out [MCP bundles docs](https://github.com/anthropics/mcpb#mcp-bundles-mcpb).
625
687
 
626
688
  </details>
627
689
 
@@ -981,25 +1043,33 @@ Context7 MCP provides the following tools that LLMs can use:
981
1043
 
982
1044
  ### Add a Rule
983
1045
 
984
- > If you don’t want to add `use context7` to every prompt, you can define a simple rule in your `.windsurfrules` file in Windsurf or from `Cursor Settings > Rules` section in Cursor (or the equivalent in your MCP client) to auto-invoke Context7 on any code question:
985
- >
986
- > ```toml
987
- > [[calls]]
988
- > match = "when the user requests code examples, setup or configuration steps, or library/API documentation"
989
- > tool = "context7"
990
- > ```
991
- >
992
- > From then on you’ll get Context7’s docs in any related conversation without typing anything extra. You can add your use cases to the match part.
1046
+ If you don’t want to add `use context7` to every prompt, you can define a simple rule in your MCP client's rule section:
1047
+
1048
+ - For Windsurf, in `.windsurfrules` file
1049
+ - For Cursor, from `Cursor Settings > Rules` section
1050
+ - For Claude Code, in `CLAUDE.md` file
1051
+
1052
+ Or the equivalent in your MCP client to auto-invoke Context7 on any code question.
1053
+
1054
+ #### Example Rule
1055
+
1056
+ ```txt
1057
+ Always use context7 when I need code generation, setup or configuration steps, or
1058
+ library/API documentation. This means you should automatically use the Context7 MCP
1059
+ tools to resolve library id and get library docs without me having to explicitly ask.
1060
+ ```
1061
+
1062
+ From then on, you’ll get Context7’s docs in any related conversation without typing anything extra. You can alter the rule to match your use cases.
993
1063
 
994
1064
  ### Use Library Id
995
1065
 
996
- > If you already know exactly which library you want to use, add its Context7 ID to your prompt. That way, Context7 MCP server can skip the library-matching step and directly continue with retrieving docs.
997
- >
998
- > ```txt
999
- > implement basic authentication with supabase. use library /supabase/supabase for api and docs
1000
- > ```
1001
- >
1002
- > The slash syntax tells the MCP tool exactly which library to load docs for.
1066
+ If you already know exactly which library you want to use, add its Context7 ID to your prompt. That way, Context7 MCP server can skip the library-matching step and directly continue with retrieving docs.
1067
+
1068
+ ```txt
1069
+ Implement basic authentication with Supabase. use library /supabase/supabase for API and docs.
1070
+ ```
1071
+
1072
+ The slash syntax tells the MCP tool exactly which library to load docs for.
1003
1073
 
1004
1074
  ### HTTPS Proxy
1005
1075
 
@@ -1033,7 +1103,7 @@ bun run dist/index.js
1033
1103
  - `--port <number>` – Port to listen on when using `http` transport (default `3000`).
1034
1104
  - `--api-key <key>` – API key for authentication. You can get your API key by creating an account at [context7.com/dashboard](https://context7.com/dashboard).
1035
1105
 
1036
- Example with http transport and port 8080:
1106
+ Example with HTTP transport and port 8080:
1037
1107
 
1038
1108
  ```bash
1039
1109
  bun run dist/index.js --transport http --port 8080
@@ -1053,7 +1123,7 @@ bun run dist/index.js --transport stdio --api-key YOUR_API_KEY
1053
1123
  "mcpServers": {
1054
1124
  "context7": {
1055
1125
  "command": "npx",
1056
- "args": ["tsx", "/path/to/folder/context7-mcp/src/index.ts", "--api-key", "YOUR_API_KEY"]
1126
+ "args": ["tsx", "/path/to/folder/context7/src/index.ts", "--api-key", "YOUR_API_KEY"]
1057
1127
  }
1058
1128
  }
1059
1129
  }
package/dist/index.js CHANGED
@@ -77,7 +77,7 @@ function getClientIp(req) {
77
77
  function createServerInstance(clientIp, apiKey) {
78
78
  const server = new McpServer({
79
79
  name: "Context7",
80
- version: "1.0.17",
80
+ version: "1.0.19",
81
81
  }, {
82
82
  instructions: "Use this server to retrieve up-to-date documentation and code examples for any library.",
83
83
  });
@@ -135,7 +135,7 @@ Each result includes:
135
135
  - Description: Short summary
136
136
  - Code Snippets: Number of available code examples
137
137
  - Trust Score: Authority indicator
138
- - Versions: List of versions if available. Use one of those versions if and only if the user explicitly provides a version in their query.
138
+ - 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.
139
139
 
140
140
  For best results, select libraries based on name match, trust score, snippet coverage, and relevance to your use case.
141
141
 
@@ -197,7 +197,7 @@ async function main() {
197
197
  // Keep track of which port we end up using
198
198
  let actualPort = initialPort;
199
199
  const httpServer = createServer(async (req, res) => {
200
- const url = new URL(req.url || "", `http://${req.headers.host}`).pathname;
200
+ const pathname = new URL(req.url || "/", "http://localhost").pathname;
201
201
  // Set CORS headers for all responses
202
202
  res.setHeader("Access-Control-Allow-Origin", "*");
203
203
  res.setHeader("Access-Control-Allow-Methods", "GET,POST,OPTIONS,DELETE");
@@ -242,14 +242,18 @@ async function main() {
242
242
  const clientIp = getClientIp(req);
243
243
  // Create new server instance for each request
244
244
  const requestServer = createServerInstance(clientIp, apiKey);
245
- if (url === "/mcp") {
245
+ if (pathname === "/mcp") {
246
246
  const transport = new StreamableHTTPServerTransport({
247
247
  sessionIdGenerator: undefined,
248
248
  });
249
+ res.on("close", () => {
250
+ transport.close();
251
+ requestServer.close();
252
+ });
249
253
  await requestServer.connect(transport);
250
254
  await transport.handleRequest(req, res);
251
255
  }
252
- else if (url === "/sse" && req.method === "GET") {
256
+ else if (pathname === "/sse" && req.method === "GET") {
253
257
  // Create new SSE transport for GET request
254
258
  const sseTransport = new SSEServerTransport("/messages", res);
255
259
  // Store the transport by session ID
@@ -257,42 +261,54 @@ async function main() {
257
261
  // Clean up transport when connection closes
258
262
  res.on("close", () => {
259
263
  delete sseTransports[sseTransport.sessionId];
264
+ sseTransport.close();
265
+ requestServer.close();
260
266
  });
261
267
  await requestServer.connect(sseTransport);
268
+ // Send initial message to establish communication
269
+ res.write("data: " +
270
+ JSON.stringify({
271
+ type: "connection_established",
272
+ sessionId: sseTransport.sessionId,
273
+ timestamp: new Date().toISOString(),
274
+ }) +
275
+ "\n\n");
262
276
  }
263
- else if (url === "/messages" && req.method === "POST") {
277
+ else if (pathname === "/messages" && req.method === "POST") {
264
278
  // Get session ID from query parameters
265
- const sessionId = new URL(req.url || "", `http://${req.headers.host}`).searchParams.get("sessionId") ??
266
- "";
279
+ const sessionId = new URL(req.url || "/", "http://localhost").searchParams.get("sessionId") ?? "";
267
280
  if (!sessionId) {
268
- res.writeHead(400);
269
- res.end("Missing sessionId parameter");
281
+ res.writeHead(400, { "Content-Type": "application/json" });
282
+ res.end(JSON.stringify({ error: "Missing sessionId parameter", status: 400 }));
270
283
  return;
271
284
  }
272
285
  // Get existing transport for this session
273
286
  const sseTransport = sseTransports[sessionId];
274
287
  if (!sseTransport) {
275
- res.writeHead(400);
276
- res.end(`No transport found for sessionId: ${sessionId}`);
288
+ res.writeHead(400, { "Content-Type": "application/json" });
289
+ res.end(JSON.stringify({
290
+ error: `No transport found for sessionId: ${sessionId}`,
291
+ status: 400,
292
+ }));
277
293
  return;
278
294
  }
279
295
  // Handle the POST message with the existing transport
280
296
  await sseTransport.handlePostMessage(req, res);
281
297
  }
282
- else if (url === "/ping") {
283
- res.writeHead(200, { "Content-Type": "text/plain" });
284
- res.end("pong");
298
+ else if (pathname === "/ping") {
299
+ res.writeHead(200, { "Content-Type": "application/json" });
300
+ res.end(JSON.stringify({ status: "ok", message: "pong" }));
285
301
  }
286
302
  else {
287
- res.writeHead(404);
288
- res.end("Not found");
303
+ res.writeHead(404, { "Content-Type": "application/json" });
304
+ res.end(JSON.stringify({ error: "Not found", status: 404 }));
289
305
  }
290
306
  }
291
307
  catch (error) {
292
308
  console.error("Error handling request:", error);
293
309
  if (!res.headersSent) {
294
- res.writeHead(500);
295
- res.end("Internal Server Error");
310
+ res.writeHead(500, { "Content-Type": "application/json" });
311
+ res.end(JSON.stringify({ error: "Internal Server Error", status: 500 }));
296
312
  }
297
313
  }
298
314
  });
package/dist/lib/api.js CHANGED
@@ -97,7 +97,9 @@ export async function fetchLibraryDocumentation(libraryId, options = {}, clientI
97
97
  return errorMessage;
98
98
  }
99
99
  if (errorCode === 401) {
100
- const errorMessage = "Unauthorized. Please check your API key.";
100
+ const errorMessage = "Unauthorized. Please check your API key. The API key you provided (possibly incorrect) is: " +
101
+ apiKey +
102
+ ". API keys should start with 'ctx7sk'";
101
103
  console.error(errorMessage);
102
104
  return errorMessage;
103
105
  }
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@upstash/context7-mcp","version":"1.0.17","description":"MCP server for Context7","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"tsc && chmod 755 dist/index.js","format":"prettier --write .","lint":"eslint \"**/*.{js,ts,tsx}\" --fix","lint:check":"eslint \"**/*.{js,ts,tsx}\"","start":"node dist/index.js --transport http","pack-dxt":"bun install && bun run build && rm -rf node_modules && bun install --production && mv dxt/.dxtignore .dxtignore && mv dxt/manifest.json manifest.json && dxt validate manifest.json && dxt pack . dxt/context7.dxt && mv manifest.json dxt/manifest.json && mv .dxtignore dxt/.dxtignore && bun install"},"repository":{"type":"git","url":"git+https://github.com/upstash/context7.git"},"keywords":["modelcontextprotocol","mcp","context7"],"author":"abdush","license":"MIT","type":"module","bin":{"context7-mcp":"dist/index.js"},"files":["dist"],"bugs":{"url":"https://github.com/upstash/context7/issues"},"homepage":"https://github.com/upstash/context7#readme","dependencies":{"@modelcontextprotocol/sdk":"^1.13.2","commander":"^14.0.0","undici":"^6.6.3","zod":"^3.24.2"},"devDependencies":{"@types/node":"^22.13.14","@typescript-eslint/eslint-plugin":"^8.28.0","@typescript-eslint/parser":"^8.28.0","eslint":"^9.34.0","eslint-config-prettier":"^10.1.1","eslint-plugin-prettier":"^5.2.5","prettier":"^3.6.2","typescript":"^5.8.2","typescript-eslint":"^8.28.0"}}
1
+ {"name":"@upstash/context7-mcp","version":"1.0.19","description":"MCP server for Context7","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"tsc && chmod 755 dist/index.js","format":"prettier --write .","lint":"eslint \"**/*.{js,ts,tsx}\" --fix","lint:check":"eslint \"**/*.{js,ts,tsx}\"","start":"node dist/index.js --transport http","pack-mcpb":"bun install && bun run build && rm -rf node_modules && bun install --production && mv mcpb/.mcpbignore .mcpbignore && mv mcpb/manifest.json manifest.json && mv public/icon.png icon.png && mcpb validate manifest.json && mcpb pack . mcpb/context7.mcpb && mv manifest.json mcpb/manifest.json && mv .mcpbignore mcpb/.mcpbignore && mv icon.png public/icon.png && bun install"},"repository":{"type":"git","url":"git+https://github.com/upstash/context7.git"},"keywords":["modelcontextprotocol","mcp","context7","vibe-coding","developer tools","documentation","context"],"author":"abdush","license":"MIT","type":"module","bin":{"context7-mcp":"dist/index.js"},"files":["dist"],"bugs":{"url":"https://github.com/upstash/context7/issues"},"homepage":"https://github.com/upstash/context7#readme","dependencies":{"@modelcontextprotocol/sdk":"^1.17.5","commander":"^14.0.0","undici":"^6.6.3","zod":"^3.24.2"},"devDependencies":{"@types/node":"^22.13.14","@typescript-eslint/eslint-plugin":"^8.28.0","@typescript-eslint/parser":"^8.28.0","eslint":"^9.34.0","eslint-config-prettier":"^10.1.1","eslint-plugin-prettier":"^5.2.5","prettier":"^3.6.2","typescript":"^5.8.2","typescript-eslint":"^8.28.0"}}