@upstash/context7-mcp 1.0.6 → 1.0.8

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
@@ -1,8 +1,9 @@
1
- # Context7 MCP - Up-to-date Docs For Any Prompt
1
+ # Context7 MCP - Up-to-date Code Docs For Any Prompt
2
2
 
3
- [![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) [<img alt="Install in VS Code (npx)" src="https://img.shields.io/badge/VS_Code-VS_Code?style=flat-square&label=Install%20Context7%20MCP&color=0098FF">](https://insiders.vscode.dev/redirect?url=vscode%3Amcp%2Finstall%3F%257B%2522name%2522%253A%2522context7%2522%252C%2522config%2522%253A%257B%2522command%2522%253A%2522npx%2522%252C%2522args%2522%253A%255B%2522-y%2522%252C%2522%2540upstash%252Fcontext7-mcp%2540latest%2522%255D%257D%257D)
3
+ [![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) [<img alt="Install in VS Code (npx)" src="https://img.shields.io/badge/VS_Code-VS_Code?style=flat-square&label=Install%20Context7%20MCP&color=0098FF">](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)
4
+
5
+ [![中文文档](https://img.shields.io/badge/docs-中文版-yellow)](./docs/README.zh-CN.md) [![한국어 문서](https://img.shields.io/badge/docs-한국어-green)](./docs/README.ko.md) [![Documentación en Español](https://img.shields.io/badge/docs-Español-orange)](./docs/README.es.md) [![Documentation en Français](https://img.shields.io/badge/docs-Français-blue)](./docs/README.fr.md) [![Documentação em Português (Brasil)](https://img.shields.io/badge/docs-Português%20(Brasil)-purple)](./docs/README.pt-BR.md) [![Documentazione in italiano](https://img.shields.io/badge/docs-Italian-red)](./docs/README.it.md) [![Dokumentasi Bahasa Indonesia](https://img.shields.io/badge/docs-Bahasa%20Indonesia-pink)](./docs/README.id-ID.md) [![Dokumentation auf Deutsch](https://img.shields.io/badge/docs-Deutsch-darkgreen)](./docs/README.de.md) [![Документация на русском языке](https://img.shields.io/badge/docs-Русский-darkblue)](./docs/README.ru.md) [![Türkçe Doküman](https://img.shields.io/badge/docs-Türkçe-blue)](./docs/README.tr.md)
4
6
 
5
- [![中文文档](https://img.shields.io/badge/docs-中文版-yellow)](./docs/README.zh-CN.md) [![한국어 문서](https://img.shields.io/badge/docs-한국어-green)](./docs/README.ko.md)
6
7
 
7
8
  ## ❌ Without Context7
8
9
 
@@ -53,7 +54,7 @@ npx -y @smithery/cli install @upstash/context7-mcp --client claude
53
54
 
54
55
  Go to: `Settings` -> `Cursor Settings` -> `MCP` -> `Add new global MCP server`
55
56
 
56
- Pasting the following configuration into your Cursor `~/.cursor/mcp.json` file is the recommended approach. See [Cursor MCP docs](https://docs.cursor.com/context/model-context-protocol) for more info.
57
+ Pasting the following configuration into your Cursor `~/.cursor/mcp.json` file is the recommended approach. You may also install in a specific project by creating `.cursor/mcp.json` in your project folder. See [Cursor MCP docs](https://docs.cursor.com/context/model-context-protocol) for more info.
57
58
 
58
59
  ```json
59
60
  {
@@ -90,7 +91,7 @@ Pasting the following configuration into your Cursor `~/.cursor/mcp.json` file i
90
91
  "mcpServers": {
91
92
  "context7": {
92
93
  "command": "deno",
93
- "args": ["run", "--allow-net", "npm:@upstash/context7-mcp"]
94
+ "args": ["run", "--allow-env", "--allow-net", "npm:@upstash/context7-mcp"]
94
95
  }
95
96
  }
96
97
  }
@@ -115,8 +116,8 @@ Add this to your Windsurf MCP config file. See [Windsurf MCP docs](https://docs.
115
116
 
116
117
  ### Install in VS Code
117
118
 
118
- [<img alt="Install in VS Code (npx)" src="https://img.shields.io/badge/VS_Code-VS_Code?style=flat-square&label=Install%20Context7%20MCP&color=0098FF">](https://insiders.vscode.dev/redirect?url=vscode%3Amcp%2Finstall%3F%257B%2522name%2522%253A%2522context7%2522%252C%2522config%2522%253A%257B%2522command%2522%253A%2522npx%2522%252C%2522args%2522%253A%255B%2522-y%2522%252C%2522%2540upstash%252Fcontext7-mcp%2540latest%2522%255D%257D%257D)
119
- [<img alt="Install in VS Code Insiders (npx)" src="https://img.shields.io/badge/VS_Code_Insiders-VS_Code_Insiders?style=flat-square&label=Install%20Context7%20MCP&color=24bfa5">](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Amcp%2Finstall%3F%257B%2522name%2522%253A%2522context7%2522%252C%2522config%2522%253A%257B%2522command%2522%253A%2522npx%2522%252C%2522args%2522%253A%255B%2522-y%2522%252C%2522%2540upstash%252Fcontext7-mcp%2540latest%2522%255D%257D%257D)
119
+ [<img alt="Install in VS Code (npx)" src="https://img.shields.io/badge/VS_Code-VS_Code?style=flat-square&label=Install%20Context7%20MCP&color=0098FF">](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)
120
+ [<img alt="Install in VS Code Insiders (npx)" src="https://img.shields.io/badge/VS_Code_Insiders-VS_Code_Insiders?style=flat-square&label=Install%20Context7%20MCP&color=24bfa5">](https://insiders.vscode.dev/redirect?url=vscode-insiders%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)
120
121
 
121
122
  Add this to your VS Code MCP config file. See [VS Code MCP docs](https://code.visualstudio.com/docs/copilot/chat/mcp-servers) for more info.
122
123
 
@@ -132,6 +133,24 @@ Add this to your VS Code MCP config file. See [VS Code MCP docs](https://code.vi
132
133
  }
133
134
  ```
134
135
 
136
+ ### Install in Zed
137
+
138
+ It can be installed via [Zed Extensions](https://zed.dev/extensions?query=Context7) or you can add this to your Zed `settings.json`. See [Zed Context Server docs](https://zed.dev/docs/assistant/context-servers) for more info.
139
+
140
+ ```json
141
+ {
142
+ "context_servers": {
143
+ "Context7": {
144
+ "command": {
145
+ "path": "npx",
146
+ "args": ["-y", "@upstash/context7-mcp@latest"]
147
+ },
148
+ "settings": {}
149
+ }
150
+ }
151
+ }
152
+ ```
153
+
135
154
  ### Install in Claude Code
136
155
 
137
156
  Run this command. See [Claude Code MCP docs](https://docs.anthropic.com/en/docs/agents-and-tools/claude-code/tutorials#set-up-model-context-protocol-mcp) for more info.
@@ -155,6 +174,120 @@ Add this to your Claude Desktop `claude_desktop_config.json` file. See [Claude D
155
174
  }
156
175
  ```
157
176
 
177
+ ### Install in BoltAI
178
+
179
+ Open the "Settings" page of the app, navigate to "Plugins," and enter the following JSON:
180
+
181
+ ```json
182
+ {
183
+ "mcpServers": {
184
+ "context7": {
185
+ "args": ["-y", "@upstash/context7-mcp@latest"],
186
+ "command": "npx"
187
+ }
188
+ }
189
+ }
190
+ ```
191
+
192
+ Once saved, enter in the chat `get-library-docs` followed by your Context7 documentation ID (e.g., `get-library-docs /nuxt/ui`). More information is available on [BoltAI's Documentation site](https://docs.boltai.com/docs/plugins/mcp-servers). For BoltAI on iOS, [see this guide](https://docs.boltai.com/docs/boltai-mobile/mcp-servers).
193
+
194
+ ### Using Docker
195
+
196
+ If you prefer to run the MCP server in a Docker container:
197
+
198
+ 1. **Build the Docker Image:**
199
+
200
+ First, create a `Dockerfile` in the project root (or anywhere you prefer):
201
+
202
+ <details>
203
+ <summary>Click to see Dockerfile content</summary>
204
+
205
+ ```Dockerfile
206
+ FROM node:18-alpine
207
+
208
+ WORKDIR /app
209
+
210
+ # Install the latest version globally
211
+ RUN npm install -g @upstash/context7-mcp@latest
212
+
213
+ # Expose default port if needed (optional, depends on MCP client interaction)
214
+ # EXPOSE 3000
215
+
216
+ # Default command to run the server
217
+ CMD ["context7-mcp"]
218
+ ```
219
+
220
+ </details>
221
+
222
+ Then, build the image using a tag (e.g., `context7-mcp`). **Make sure Docker Desktop (or the Docker daemon) is running.** Run the following command in the same directory where you saved the `Dockerfile`:
223
+
224
+ ```bash
225
+ docker build -t context7-mcp .
226
+ ```
227
+
228
+ 2. **Configure Your MCP Client:**
229
+
230
+ Update your MCP client's configuration to use the Docker command.
231
+
232
+ *Example for a cline_mcp_settings.json:*
233
+
234
+ ```json
235
+ {
236
+ "mcpServers": {
237
+ "Сontext7": {
238
+ "autoApprove": [],
239
+ "disabled": false,
240
+ "timeout": 60,
241
+ "command": "docker",
242
+ "args": ["run", "-i", "--rm", "context7-mcp"],
243
+ "transportType": "stdio"
244
+ }
245
+ }
246
+ }
247
+ ```
248
+
249
+ *Note: This is an example configuration. Please refer to the specific examples for your MCP client (like Cursor, VS Code, etc.) earlier in this README to adapt the structure (e.g., `mcpServers` vs `servers`). Also, ensure the image name in `args` matches the tag used during the `docker build` command.*
250
+
251
+ ### Install in Windows
252
+ The configuration on Windows is slightly different compared to Linux or macOS (*`Cline` is used in the example*). The same principle applies to other editors; refer to the configuration of `command` and `args`.
253
+ ```json
254
+ {
255
+ "mcpServers": {
256
+ "github.com/upstash/context7-mcp": {
257
+ "command": "cmd",
258
+ "args": [
259
+ "/c",
260
+ "npx",
261
+ "-y",
262
+ "@upstash/context7-mcp@latest"
263
+ ],
264
+ "disabled": false,
265
+ "autoApprove": []
266
+ }
267
+ }
268
+ }
269
+ ```
270
+
271
+ ### Environment Variables
272
+
273
+ - `DEFAULT_MINIMUM_TOKENS`: Set the minimum token count for documentation retrieval (default: 10000).
274
+
275
+ Examples:
276
+
277
+ ```json
278
+ {
279
+ "mcpServers": {
280
+ "context7": {
281
+ "command": "npx",
282
+ "args": ["-y", "@upstash/context7-mcp@latest"],
283
+ "env": {
284
+ "DEFAULT_MINIMUM_TOKENS": "10000"
285
+ }
286
+ }
287
+ }
288
+ }
289
+ ```
290
+
158
291
  ### Available Tools
159
292
 
160
293
  - `resolve-library-id`: Resolves a general library name into a Context7-compatible library ID.
@@ -162,7 +295,7 @@ Add this to your Claude Desktop `claude_desktop_config.json` file. See [Claude D
162
295
  - `get-library-docs`: Fetches documentation for a library using a Context7-compatible library ID.
163
296
  - `context7CompatibleLibraryID` (required)
164
297
  - `topic` (optional): Focus the docs on a specific topic (e.g., "routing", "hooks")
165
- - `tokens` (optional, default 5000): Max number of tokens to return. Values less than 5000 are automatically increased to 5000.
298
+ - `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.
166
299
 
167
300
  ## Development
168
301
 
@@ -216,6 +349,25 @@ If you see this error, try using `bunx` instead of `npx`.
216
349
 
217
350
  This often resolves module resolution issues, especially in environments where `npx` does not properly install or resolve packages.
218
351
 
352
+ ### ESM Resolution Issues
353
+
354
+ If you encounter an error like: `Error: Cannot find module 'uriTemplate.js'` try running with the `--experimental-vm-modules` flag:
355
+
356
+ ```json
357
+ {
358
+ "mcpServers": {
359
+ "context7": {
360
+ "command": "npx",
361
+ "args": [
362
+ "-y",
363
+ "--node-options=--experimental-vm-modules",
364
+ "@upstash/context7-mcp@1.0.6"
365
+ ]
366
+ }
367
+ }
368
+ }
369
+ ```
370
+
219
371
  ### MCP Client Errors
220
372
 
221
373
  1. Try removing `@latest` from the package name.
@@ -224,6 +376,12 @@ This often resolves module resolution issues, especially in environments where `
224
376
 
225
377
  3. Try using `deno` as an alternative.
226
378
 
379
+ 4. Make sure you are using Node v18 or higher to have native fetch support with `npx`.
380
+
381
+ ## Disclaimer
382
+
383
+ Context7 projects are community-contributed and while we strive to maintain high quality, we cannot guarantee the accuracy, completeness, or security of all library documentation. Projects listed in Context7 are developed and maintained by their respective owners, not by Context7. If you encounter any suspicious, inappropriate, or potentially harmful content, please use the "Report" button on the project page to notify us immediately. We take all reports seriously and will review flagged content promptly to maintain the integrity and safety of our platform. By using Context7, you acknowledge that you do so at your own discretion and risk.
384
+
227
385
  ## Context7 In Media
228
386
 
229
387
  - [Better Stack: "Free Tool Makes Cursor 10x Smarter"](https://youtu.be/52FC3qObp9E)
@@ -232,6 +390,8 @@ This often resolves module resolution issues, especially in environments where `
232
390
  - [Julian Goldie SEO: "Context7: New MCP AI Agent Update"](https://www.youtube.com/watch?v=CTZm6fBYisc)
233
391
  - [JeredBlu: "Context 7 MCP: Get Documentation Instantly + VS Code Setup"](https://www.youtube.com/watch?v=-ls0D-rtET4)
234
392
  - [Income stream surfers: "Context7: The New MCP Server That Will CHANGE AI Coding"](https://www.youtube.com/watch?v=PS-2Azb-C3M)
393
+ - [AICodeKing: "Context7 + Cline & RooCode: This MCP Server Makes CLINE 100X MORE EFFECTIVE!"](https://www.youtube.com/watch?v=qZfENAPMnyo)
394
+ - [Sean Kochel: "5 MCP Servers For Vibe Coding Glory (Just Plug-In & Go)"](https://www.youtube.com/watch?v=LqTQi8qexJM)
235
395
 
236
396
  ## Star History
237
397
 
package/dist/index.js CHANGED
@@ -4,19 +4,42 @@ 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
- const DEFAULT_MINIMUM_TOKENS = 5000;
7
+ import dotenv from "dotenv";
8
+ // Load environment variables from .env file if present
9
+ dotenv.config();
10
+ // Get DEFAULT_MINIMUM_TOKENS from environment variable or use default
11
+ let DEFAULT_MINIMUM_TOKENS = 10000;
12
+ if (process.env.DEFAULT_MINIMUM_TOKENS) {
13
+ const parsedValue = parseInt(process.env.DEFAULT_MINIMUM_TOKENS, 10);
14
+ if (!isNaN(parsedValue) && parsedValue > 0) {
15
+ DEFAULT_MINIMUM_TOKENS = parsedValue;
16
+ }
17
+ else {
18
+ console.warn(`Warning: Invalid DEFAULT_MINIMUM_TOKENS value provided in environment variable. Using default value of 10000`);
19
+ }
20
+ }
8
21
  // Create server instance
9
22
  const server = new McpServer({
10
23
  name: "Context7",
11
24
  description: "Retrieves up-to-date documentation and code examples for any library.",
12
- version: "1.0.6",
25
+ version: "v1.0.8",
13
26
  capabilities: {
14
27
  resources: {},
15
28
  tools: {},
16
29
  },
17
30
  });
18
31
  // Register Context7 tools
19
- server.tool("resolve-library-id", "Required first step: Resolves a general package name into a Context7-compatible library ID. Must be called before using 'get-library-docs' to retrieve a valid Context7-compatible library ID.", {
32
+ server.tool("resolve-library-id", `Resolves a package name to a Context7-compatible library ID and returns a list of matching libraries.
33
+
34
+ You MUST call this function before 'get-library-docs' to obtain a valid Context7-compatible library ID.
35
+
36
+ When selecting the best match, consider:
37
+ - Name similarity to the query
38
+ - Description relevance
39
+ - Code Snippet count (documentation coverage)
40
+ - GitHub Stars (popularity)
41
+
42
+ Return the selected library ID and explain your choice. If there are multiple good matches, mention this but proceed with the most relevant one.`, {
20
43
  libraryName: z
21
44
  .string()
22
45
  .describe("Library name to search for and retrieve a Context7-compatible library ID."),
@@ -47,7 +70,20 @@ server.tool("resolve-library-id", "Required first step: Resolves a general packa
47
70
  content: [
48
71
  {
49
72
  type: "text",
50
- text: "Available libraries and their Context7-compatible library IDs:\n\n" + resultsText,
73
+ text: `Available Libraries (top matches):
74
+
75
+ Each result includes:
76
+ - Library ID: Context7-compatible identifier (format: /org/repo)
77
+ - Name: Library or package name
78
+ - Description: Short summary
79
+ - Code Snippets: Number of available code examples
80
+ - GitHub Stars: Popularity indicator
81
+
82
+ For best results, select libraries based on name match, popularity (stars), snippet coverage, and relevance to your use case.
83
+
84
+ ---
85
+
86
+ ${resultsText}`,
51
87
  },
52
88
  ],
53
89
  };
package/dist/lib/utils.js CHANGED
@@ -1,20 +1,39 @@
1
1
  /**
2
- * Format a search result into a string representation
3
- * @param result SearchResult to format
4
- * @returns Formatted search result string
2
+ * Formats a search result into a human-readable string representation.
3
+ * Only shows code snippet count and GitHub stars when available (not equal to -1).
4
+ *
5
+ * @param result The SearchResult object to format
6
+ * @returns A formatted string with library information
5
7
  */
6
8
  export function formatSearchResult(result) {
7
- return `Title: ${result.title}\n\nContext7-compatible library ID: ${result.id}\n\nDescription: ${result.description}`;
9
+ // Always include these basic details
10
+ const formattedResult = [
11
+ `- Title: ${result.title}`,
12
+ `- Context7-compatible library ID: ${result.id}`,
13
+ `- Description: ${result.description}`,
14
+ ];
15
+ // Only add code snippets count if it's a valid value
16
+ if (result.totalSnippets !== -1 && result.totalSnippets !== undefined) {
17
+ formattedResult.push(`- Code Snippets: ${result.totalSnippets}`);
18
+ }
19
+ // Only add GitHub stars if it's a valid value
20
+ if (result.stars !== -1 && result.stars !== undefined) {
21
+ formattedResult.push(`- GitHub Stars: ${result.stars}`);
22
+ }
23
+ // Join all parts with newlines
24
+ return formattedResult.join("\n");
8
25
  }
9
26
  /**
10
- * Format search results into a string representation
11
- * @param searchResponse The search response to format
12
- * @returns Formatted search results string
27
+ * Formats a search response into a human-readable string representation.
28
+ * Each result is formatted using formatSearchResult.
29
+ *
30
+ * @param searchResponse The SearchResponse object to format
31
+ * @returns A formatted string with search results
13
32
  */
14
33
  export function formatSearchResults(searchResponse) {
15
34
  if (!searchResponse.results || searchResponse.results.length === 0) {
16
35
  return "No documentation libraries found matching your query.";
17
36
  }
18
37
  const formattedResults = searchResponse.results.map(formatSearchResult);
19
- return formattedResults.join("\n\n--------------------\n");
38
+ return formattedResults.join("\n---\n");
20
39
  }
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@upstash/context7-mcp","version":"v1.0.6","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"},"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.8.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.8","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"},"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.8.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"}}