@upstash/context7-mcp 1.0.27 → 1.0.28

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
@@ -20,7 +20,7 @@ LLMs rely on outdated or generic information about the libraries you use. You ge
20
20
 
21
21
  Context7 MCP pulls up-to-date, version-specific documentation and code examples straight from the source — and places them directly into your prompt.
22
22
 
23
- Add `use context7` to your prompt in Cursor:
23
+ Add `use context7` to your prompt (or [set up a rule](#️-installation) to auto-invoke):
24
24
 
25
25
  ```txt
26
26
  Create a Next.js middleware that checks for a valid JWT in cookies
@@ -35,7 +35,7 @@ JSON API responses for five minutes. use context7
35
35
  Context7 fetches up-to-date code examples and documentation right into your LLM's context.
36
36
 
37
37
  - 1️⃣ Write your prompt naturally
38
- - 2️⃣ Tell the LLM to `use context7`
38
+ - 2️⃣ Tell the LLM to `use context7` (or [set up a rule](#️-installation) once)
39
39
  - 3️⃣ Get working code answers
40
40
 
41
41
  No tab-switching, no hallucinated APIs that don't exist, no outdated code generation.
@@ -55,6 +55,26 @@ Check out our [project addition guide](https://context7.com/docs/adding-librarie
55
55
  - Cursor, Claude Code, VSCode, Windsurf or another MCP Client
56
56
  - Context7 API Key (Optional) for higher rate limits and private repositories (Get yours by creating an account at [context7.com/dashboard](https://context7.com/dashboard))
57
57
 
58
+ > [!TIP]
59
+ > **Recommended Post-Setup: Add a Rule to Auto-Invoke Context7**
60
+ >
61
+ > After installing Context7 (see instructions below), enhance your workflow by adding a rule so you don't have to type `use context7` in every prompt. Define a simple rule in your MCP client's rule section to automatically invoke Context7 on any code question:
62
+ >
63
+ > - For Windsurf, in `.windsurfrules` file
64
+ > - For Cursor, from `Cursor Settings > Rules` section
65
+ > - For Claude Code, in `CLAUDE.md` file
66
+ > - Or the equivalent in your MCP client
67
+ >
68
+ > **Example Rule:**
69
+ >
70
+ > ```txt
71
+ > Always use context7 when I need code generation, setup or configuration steps, or
72
+ > library/API documentation. This means you should automatically use the Context7 MCP
73
+ > tools to resolve library id and get library docs without me having to explicitly ask.
74
+ > ```
75
+ >
76
+ > 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.
77
+
58
78
  <details>
59
79
  <summary><b>Installing via Smithery</b></summary>
60
80
 
@@ -260,6 +280,76 @@ Or you can directly edit MCP servers configuration:
260
280
 
261
281
  </details>
262
282
 
283
+ <details>
284
+ <summary><b>Install in Kilo Code</b></summary>
285
+
286
+ You can configure the Context7 MCP server in **Kilo Code** using either the UI or by editing your project's MCP configuration file.
287
+
288
+ Kilo Code supports two configuration levels:
289
+
290
+ - **Global MCP Configuration** — stored in `mcp_settings.json`
291
+ - **Project-level MCP Configuration** — stored in `.kilocode/mcp.json` (recommended)
292
+
293
+ If a server is defined in both places, the **project-level configuration overrides the global one**.
294
+
295
+ ---
296
+
297
+ ## Configure via Kilo Code UI
298
+
299
+ 1. Open **Kilo Code**.
300
+ 2. Click the **Settings** icon in the top-right corner.
301
+ 3. Navigate to **Settings → MCP Servers**.
302
+ 4. Click **Add Server**.
303
+ 5. Choose **HTTP Server** (Streamable HTTP Transport).
304
+ 6. Enter the details:
305
+
306
+ **URL**
307
+ `https://mcp.context7.com/mcp`
308
+
309
+ **Headers → Add Header**
310
+ - **Key:** `Authorization`
311
+ - **Value:** `Bearer YOUR_API_KEY`
312
+
313
+ 7. Click **Save**.
314
+ 8. Ensure the server toggle is **enabled**.
315
+ 9. If needed, click **Refresh MCP Servers** to reload the configuration.
316
+
317
+ ---
318
+
319
+ ## Manual Configuration (`.kilocode/mcp.json`)
320
+
321
+ To configure the server at the project level (recommended for team environments), create the following file:
322
+
323
+ **`.kilocode/mcp.json`:**
324
+
325
+ ```json
326
+ {
327
+ "mcpServers": {
328
+ "context7": {
329
+ "type": "streamable-http",
330
+ "url": "https://mcp.context7.com/mcp",
331
+ "headers": {
332
+ "Authorization": "Bearer YOUR_API_KEY"
333
+ },
334
+ "alwaysAllow": [],
335
+ "disabled": false
336
+ }
337
+ }
338
+ }
339
+ ```
340
+
341
+ Replace YOUR_API_KEY with your actual Context7 API key.
342
+
343
+ After saving the file:
344
+
345
+ - Open Settings → MCP Servers
346
+
347
+ - Click Refresh MCP Servers
348
+
349
+ Kilo Code will automatically detect and load the configuration.
350
+
351
+ </details>
352
+
263
353
  <details>
264
354
  <summary><b>Install in Zed</b></summary>
265
355
 
@@ -857,10 +947,7 @@ For more information, see the [official GitHub documentation](https://docs.githu
857
947
  "headers": {
858
948
  "CONTEXT7_API_KEY": "YOUR_API_KEY"
859
949
  },
860
- "tools": [
861
- "get-library-docs",
862
- "resolve-library-id"
863
- ]
950
+ "tools": ["get-library-docs", "resolve-library-id"]
864
951
  }
865
952
  }
866
953
  }
@@ -874,16 +961,8 @@ Or, for a local server:
874
961
  "context7": {
875
962
  "type": "local",
876
963
  "command": "npx",
877
- "tools": [
878
- "get-library-docs",
879
- "resolve-library-id"
880
- ],
881
- "args": [
882
- "-y",
883
- "@upstash/context7-mcp",
884
- "--api-key",
885
- "YOUR_API_KEY"
886
- ]
964
+ "tools": ["get-library-docs", "resolve-library-id"],
965
+ "args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
887
966
  }
888
967
  }
889
968
  }
@@ -1190,23 +1269,7 @@ Context7 MCP provides the following tools that LLMs can use:
1190
1269
 
1191
1270
  ### Add a Rule
1192
1271
 
1193
- 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:
1194
-
1195
- - For Windsurf, in `.windsurfrules` file
1196
- - For Cursor, from `Cursor Settings > Rules` section
1197
- - For Claude Code, in `CLAUDE.md` file
1198
-
1199
- Or the equivalent in your MCP client to auto-invoke Context7 on any code question.
1200
-
1201
- #### Example Rule
1202
-
1203
- ```txt
1204
- Always use context7 when I need code generation, setup or configuration steps, or
1205
- library/API documentation. This means you should automatically use the Context7 MCP
1206
- tools to resolve library id and get library docs without me having to explicitly ask.
1207
- ```
1208
-
1209
- 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.
1272
+ To avoid typing `use context7` in every prompt, you can add a rule to your MCP client that automatically invokes Context7 for code-related questions. See the [recommended setup in the Installation section](#️-installation) for detailed instructions and example rules.
1210
1273
 
1211
1274
  ### Use Library Id
1212
1275
 
package/dist/index.js CHANGED
@@ -8,10 +8,8 @@ import express from "express";
8
8
  import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
9
9
  import { Command } from "commander";
10
10
  import { AsyncLocalStorage } from "async_hooks";
11
- /** Minimum allowed tokens for documentation retrieval */
12
- const MINIMUM_TOKENS = 1000;
13
- /** Default tokens when none specified */
14
- const DEFAULT_TOKENS = 5000;
11
+ /** Default number of results to return per page */
12
+ const DEFAULT_RESULTS_LIMIT = 10;
15
13
  /** Default HTTP server port */
16
14
  const DEFAULT_PORT = 3000;
17
15
  // Parse CLI arguments using commander
@@ -47,6 +45,8 @@ const CLI_PORT = (() => {
47
45
  return isNaN(parsed) ? undefined : parsed;
48
46
  })();
49
47
  const requestContext = new AsyncLocalStorage();
48
+ // Store API key globally for stdio mode (where requestContext may not be available in tool handlers)
49
+ let globalApiKey;
50
50
  function getClientIp(req) {
51
51
  const forwardedFor = req.headers["x-forwarded-for"] || req.headers["X-Forwarded-For"];
52
52
  if (forwardedFor) {
@@ -69,7 +69,7 @@ function getClientIp(req) {
69
69
  }
70
70
  const server = new McpServer({
71
71
  name: "Context7",
72
- version: "1.0.27",
72
+ version: "1.0.28",
73
73
  }, {
74
74
  instructions: "Use this server to retrieve up-to-date documentation and code examples for any library.",
75
75
  });
@@ -127,7 +127,7 @@ Each result includes:
127
127
  - Benchmark Score: Quality indicator (100 is the highest score)
128
128
  - 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.
129
129
 
130
- For best results, select libraries based on name match, source reputation, snippet coverage, and relevance to your use case.
130
+ For best results, select libraries based on name match, source reputation, snippet coverage, benchmark score, and relevance to your use case.
131
131
 
132
132
  ----------
133
133
 
@@ -152,18 +152,21 @@ server.registerTool("get-library-docs", {
152
152
  .string()
153
153
  .optional()
154
154
  .describe("Topic to focus documentation on (e.g., 'hooks', 'routing')."),
155
- tokens: z
156
- .preprocess((val) => (typeof val === "string" ? Number(val) : val), z.number())
157
- .transform((val) => (val < MINIMUM_TOKENS ? MINIMUM_TOKENS : val))
158
- .optional()
159
- .describe(`Maximum number of tokens of documentation to retrieve (default: ${DEFAULT_TOKENS}). Higher values provide more context but consume more tokens.`),
155
+ page: z
156
+ .number()
157
+ .int()
158
+ .min(1)
159
+ .max(10)
160
+ .describe("Page number for pagination (start: 1). If the context is not sufficient, try page=2, page=3, page=4, etc. with the same topic."),
160
161
  },
161
- }, async ({ context7CompatibleLibraryID, tokens = DEFAULT_TOKENS, topic = "" }) => {
162
+ }, async ({ context7CompatibleLibraryID, page = 1, topic = "" }) => {
162
163
  const ctx = requestContext.getStore();
164
+ const apiKey = ctx?.apiKey || globalApiKey;
163
165
  const fetchDocsResponse = await fetchLibraryDocumentation(context7CompatibleLibraryID, {
164
- tokens,
166
+ page,
167
+ limit: DEFAULT_RESULTS_LIMIT,
165
168
  topic,
166
- }, ctx?.clientIp, ctx?.apiKey);
169
+ }, ctx?.clientIp, apiKey);
167
170
  if (!fetchDocsResponse) {
168
171
  return {
169
172
  content: [
@@ -283,6 +286,7 @@ async function main() {
283
286
  }
284
287
  else {
285
288
  const apiKey = cliOptions.apiKey || process.env.CONTEXT7_API_KEY;
289
+ globalApiKey = apiKey; // Store globally for tool handlers in stdio mode
286
290
  const transport = new StdioServerTransport();
287
291
  await requestContext.run({ apiKey }, async () => {
288
292
  await server.connect(transport);
package/dist/lib/api.js CHANGED
@@ -84,9 +84,11 @@ export async function fetchLibraryDocumentation(libraryId, options = {}, clientI
84
84
  if (libraryId.startsWith("/")) {
85
85
  libraryId = libraryId.slice(1);
86
86
  }
87
- const url = new URL(`${CONTEXT7_API_BASE_URL}/v1/${libraryId}`);
88
- if (options.tokens)
89
- url.searchParams.set("tokens", options.tokens.toString());
87
+ const url = new URL(`${CONTEXT7_API_BASE_URL}/v2/docs/code/${libraryId}`);
88
+ if (options.page)
89
+ url.searchParams.set("page", options.page.toString());
90
+ if (options.limit)
91
+ url.searchParams.set("limit", options.limit.toString());
90
92
  if (options.topic)
91
93
  url.searchParams.set("topic", options.topic);
92
94
  url.searchParams.set("type", DEFAULT_TYPE);
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@upstash/context7-mcp","version":"1.0.27","mcpName":"io.github.upstash/context7","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","@types/express":"^5.0.4","commander":"^14.0.0","express":"^5.1.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.28","mcpName":"io.github.upstash/context7","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","@types/express":"^5.0.4","commander":"^14.0.0","express":"^5.1.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"}}