@upstash/context7-mcp 1.0.13 → 1.0.14

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.
Files changed (3) hide show
  1. package/README.md +86 -9
  2. package/dist/index.js +29 -25
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -203,6 +203,45 @@ Add this to your VS Code MCP config file. See [VS Code MCP docs](https://code.vi
203
203
 
204
204
  </details>
205
205
 
206
+ <details>
207
+ <summary><b>Install in Visual Studio 2022</b></summary>
208
+
209
+ You can configure Context7 MCP in Visual Studio 2022 by following the [Visual Studio MCP Servers documentation](https://learn.microsoft.com/visualstudio/ide/mcp-servers?view=vs-2022).
210
+
211
+ Add this to your Visual Studio MCP config file (see the [Visual Studio docs](https://learn.microsoft.com/visualstudio/ide/mcp-servers?view=vs-2022) for details):
212
+
213
+ ```json
214
+ {
215
+ "mcp": {
216
+ "servers": {
217
+ "context7": {
218
+ "type": "http",
219
+ "url": "https://mcp.context7.com/mcp"
220
+ }
221
+ }
222
+ }
223
+ }
224
+ ```
225
+
226
+ Or, for a local server:
227
+
228
+ ```json
229
+ {
230
+ "mcp": {
231
+ "servers": {
232
+ "context7": {
233
+ "type": "stdio",
234
+ "command": "npx",
235
+ "args": ["-y", "@upstash/context7-mcp"]
236
+ }
237
+ }
238
+ }
239
+ }
240
+ ```
241
+
242
+ For more information and troubleshooting, refer to the [Visual Studio MCP Servers documentation](https://learn.microsoft.com/visualstudio/ide/mcp-servers?view=vs-2022).
243
+ </details>
244
+
206
245
  <details>
207
246
  <summary><b>Install in Zed</b></summary>
208
247
 
@@ -420,27 +459,46 @@ Add this to your Roo Code MCP configuration file. See [Roo Code MCP docs](https:
420
459
 
421
460
  </details>
422
461
 
423
- ## 🔧 Environment Variables
462
+ <details>
463
+ <summary><b>Install in Zencoder</b></summary>
424
464
 
425
- The Context7 MCP server supports the following environment variables:
465
+ To configure Context7 MCP in Zencoder, follow these steps:
426
466
 
427
- - `DEFAULT_MINIMUM_TOKENS`: Set the minimum token count for documentation retrieval (default: 10000)
467
+ 1. Go to the Zencoder menu (...)
468
+ 2. From the dropdown menu, select Agent tools
469
+ 3. Click on the Add custom MCP
470
+ 4. Add the name and server configuration from below, and make sure to hit the Install button
428
471
 
429
- Example configuration with environment variables:
472
+ ```json
473
+ {
474
+ "command": "npx",
475
+ "args": [
476
+ "-y",
477
+ "@upstash/context7-mcp@latest"
478
+ ]
479
+ }
480
+ ```
481
+
482
+ Once the MCP server is added, you can easily continue using it.
483
+
484
+ </details>
485
+
486
+ <details>
487
+ <summary><b>Install in Amazon Q Developer CLI</b></summary>
488
+
489
+ Add this to your Amazon Q Developer CLI configuration file. See [Amazon Q Developer CLI docs](https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/command-line-mcp-configuration.html) for more details.
430
490
 
431
491
  ```json
432
492
  {
433
493
  "mcpServers": {
434
494
  "context7": {
435
495
  "command": "npx",
436
- "args": ["-y", "@upstash/context7-mcp"],
437
- "env": {
438
- "DEFAULT_MINIMUM_TOKENS": "6000"
439
- }
496
+ "args": ["-y", "@upstash/context7-mcp@latest"]
440
497
  }
441
498
  }
442
499
  }
443
500
  ```
501
+ </details>
444
502
 
445
503
  ## 🔨 Available Tools
446
504
 
@@ -453,7 +511,7 @@ Context7 MCP provides the following tools that LLMs can use:
453
511
  - `get-library-docs`: Fetches documentation for a library using a Context7-compatible library ID.
454
512
  - `context7CompatibleLibraryID` (required): Exact Context7-compatible library ID (e.g., `/mongodb/docs`, `/vercel/next.js`)
455
513
  - `topic` (optional): Focus the docs on a specific topic (e.g., "routing", "hooks")
456
- - `tokens` (optional, default 10000): Max number of tokens to return. Values less than the configured `DEFAULT_MINIMUM_TOKENS` value or the default value of 10000 are automatically increased to that value.
514
+ - `tokens` (optional, default 10000): Max number of tokens to return. Values less than the default value of 10000 are automatically increased to 10000.
457
515
 
458
516
  ## 💻 Development
459
517
 
@@ -469,6 +527,25 @@ Build:
469
527
  bun run build
470
528
  ```
471
529
 
530
+ Run the server:
531
+
532
+ ```bash
533
+ bun run dist/index.js
534
+ ```
535
+
536
+ ### CLI Arguments
537
+
538
+ `context7-mcp` accepts the following CLI flags:
539
+
540
+ - `--transport <stdio|http|sse>` – Transport to use (`stdio` by default).
541
+ - `--port <number>` – Port to listen on when using `http` or `sse` transport (default `3000`).
542
+
543
+ Example with http transport and port 8080:
544
+
545
+ ```bash
546
+ bun run dist/index.js --transport http --port 8080
547
+ ```
548
+
472
549
  <details>
473
550
  <summary><b>Local Configuration Example</b></summary>
474
551
 
package/dist/index.js CHANGED
@@ -4,36 +4,40 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
4
4
  import { z } from "zod";
5
5
  import { searchLibraries, fetchLibraryDocumentation } from "./lib/api.js";
6
6
  import { formatSearchResults } from "./lib/utils.js";
7
- import dotenv from "dotenv";
8
7
  import { createServer } from "http";
9
8
  import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
10
9
  import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js";
11
- import { parse } from "url";
12
- // Load environment variables from .env file if present
13
- dotenv.config();
14
- // Get DEFAULT_MINIMUM_TOKENS from environment variable or use default
15
- let DEFAULT_MINIMUM_TOKENS = 10000;
16
- if (process.env.DEFAULT_MINIMUM_TOKENS) {
17
- const parsedValue = parseInt(process.env.DEFAULT_MINIMUM_TOKENS, 10);
18
- if (!isNaN(parsedValue) && parsedValue > 0) {
19
- DEFAULT_MINIMUM_TOKENS = parsedValue;
20
- }
21
- else {
22
- console.warn(`Warning: Invalid DEFAULT_MINIMUM_TOKENS value provided in environment variable. Using default value of 10000`);
23
- }
10
+ import { Command } from "commander";
11
+ const DEFAULT_MINIMUM_TOKENS = 10000;
12
+ // Parse CLI arguments using commander
13
+ const program = new Command()
14
+ .option("--transport <stdio|http|sse>", "transport type", "stdio")
15
+ .option("--port <number>", "port for HTTP/SSE transport", "3000")
16
+ .allowUnknownOption() // let MCP Inspector / other wrappers pass through extra flags
17
+ .parse(process.argv);
18
+ const cliOptions = program.opts();
19
+ // Validate transport option
20
+ const allowedTransports = ["stdio", "http", "sse"];
21
+ if (!allowedTransports.includes(cliOptions.transport)) {
22
+ console.error(`Invalid --transport value: '${cliOptions.transport}'. Must be one of: stdio, http, sse.`);
23
+ process.exit(1);
24
24
  }
25
+ // Transport configuration
26
+ const TRANSPORT_TYPE = (cliOptions.transport || "stdio");
27
+ // HTTP/SSE port configuration
28
+ const CLI_PORT = (() => {
29
+ const parsed = parseInt(cliOptions.port, 10);
30
+ return isNaN(parsed) ? undefined : parsed;
31
+ })();
25
32
  // Store SSE transports by session ID
26
33
  const sseTransports = {};
27
34
  // Function to create a new server instance with all tools registered
28
35
  function createServerInstance() {
29
36
  const server = new McpServer({
30
37
  name: "Context7",
31
- description: "Retrieves up-to-date documentation and code examples for any library.",
32
- version: "v1.0.13",
33
- capabilities: {
34
- resources: {},
35
- tools: {},
36
- },
38
+ version: "v1.0.14",
39
+ }, {
40
+ instructions: "Use this server to retrieve up-to-date documentation and code examples for any library.",
37
41
  });
38
42
  // Register Context7 tools
39
43
  server.tool("resolve-library-id", `Resolves a package/product name to a Context7-compatible library ID and returns a list of matching libraries.
@@ -136,14 +140,14 @@ ${resultsText}`,
136
140
  return server;
137
141
  }
138
142
  async function main() {
139
- const transportType = process.env.MCP_TRANSPORT || "stdio";
143
+ const transportType = TRANSPORT_TYPE;
140
144
  if (transportType === "http" || transportType === "sse") {
141
145
  // Get initial port from environment or use default
142
- const initialPort = process.env.PORT ? parseInt(process.env.PORT, 10) : 3000;
146
+ const initialPort = CLI_PORT ?? 3000;
143
147
  // Keep track of which port we end up using
144
148
  let actualPort = initialPort;
145
149
  const httpServer = createServer(async (req, res) => {
146
- const url = parse(req.url || "").pathname;
150
+ const url = new URL(req.url || "", `http://${req.headers.host}`).pathname;
147
151
  // Set CORS headers for all responses
148
152
  res.setHeader("Access-Control-Allow-Origin", "*");
149
153
  res.setHeader("Access-Control-Allow-Methods", "GET,POST,OPTIONS,DELETE");
@@ -177,8 +181,8 @@ async function main() {
177
181
  }
178
182
  else if (url === "/messages" && req.method === "POST") {
179
183
  // Get session ID from query parameters
180
- const parsedUrl = parse(req.url || "", true);
181
- const sessionId = parsedUrl.query.sessionId;
184
+ const sessionId = new URL(req.url || "", `http://${req.headers.host}`).searchParams.get("sessionId") ??
185
+ "";
182
186
  if (!sessionId) {
183
187
  res.writeHead(400);
184
188
  res.end("Missing sessionId parameter");
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@upstash/context7-mcp","version":"v1.0.13","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":"MCP_TRANSPORT=http node dist/index.js"},"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.12.0","dotenv":"^16.5.0","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.23.0","eslint-config-prettier":"^10.1.1","eslint-plugin-prettier":"^5.2.5","prettier":"^3.5.3","typescript":"^5.8.2","typescript-eslint":"^8.28.0"}}
1
+ {"name":"@upstash/context7-mcp","version":"v1.0.14","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"},"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.12.0","commander":"^14.0.0","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.23.0","eslint-config-prettier":"^10.1.1","eslint-plugin-prettier":"^5.2.5","prettier":"^3.5.3","typescript":"^5.8.2","typescript-eslint":"^8.28.0"}}