@upstash/context7-mcp 1.0.4 → 1.0.6

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,4 +1,8 @@
1
- # Context7 MCP - Up-to-date Docs For Any Cursor Prompt
1
+ # Context7 MCP - Up-to-date Docs For Any Prompt
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)
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)
2
6
 
3
7
  ## ❌ Without Context7
4
8
 
@@ -12,23 +16,19 @@ LLMs rely on outdated or generic information about the libraries you use. You ge
12
16
 
13
17
  Context7 MCP pulls up-to-date, version-specific documentation and code examples straight from the source — and places them directly into your prompt.
14
18
 
15
- Add `use context7` to your question in Cursor:
16
-
17
- ```txt
18
- How do I use the new Next.js `after` function? use context7
19
- ```
19
+ Add `use context7` to your prompt in Cursor:
20
20
 
21
21
  ```txt
22
- How do I invalidate a query in React Query? use context7
22
+ Create a basic Next.js project with app router. use context7
23
23
  ```
24
24
 
25
25
  ```txt
26
- How do I protect a route with NextAuth? use context7
26
+ Create a script to delete the rows where the city is "" given PostgreSQL credentials. use context7
27
27
  ```
28
28
 
29
- Context7 fetches up-to-date documentation and working code examples right into your LLMs context.
29
+ Context7 fetches up-to-date code examples and documentation right into your LLM's context.
30
30
 
31
- - 1️⃣ Ask your question naturally
31
+ - 1️⃣ Write your prompt naturally
32
32
  - 2️⃣ Tell the LLM to `use context7`
33
33
  - 3️⃣ Get working code answers
34
34
 
@@ -41,11 +41,19 @@ No tab-switching, no hallucinated APIs that don't exist, no outdated code genera
41
41
  - Node.js >= v18.0.0
42
42
  - Cursor, Windsurf, Claude Desktop or another MCP Client
43
43
 
44
+ ### Installing via Smithery
45
+
46
+ To install Context7 MCP Server for Claude Desktop automatically via [Smithery](https://smithery.ai/server/@upstash/context7-mcp):
47
+
48
+ ```bash
49
+ npx -y @smithery/cli install @upstash/context7-mcp --client claude
50
+ ```
51
+
44
52
  ### Install in Cursor
45
53
 
46
54
  Go to: `Settings` -> `Cursor Settings` -> `MCP` -> `Add new global MCP server`
47
55
 
48
- Paste this into your Cursor `~/.cursor/mcp.json` file. See [Cursor MCP docs](https://docs.cursor.com/context/model-context-protocol) for more info.
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.
49
57
 
50
58
  ```json
51
59
  {
@@ -58,6 +66,38 @@ Paste this into your Cursor `~/.cursor/mcp.json` file. See [Cursor MCP docs](htt
58
66
  }
59
67
  ```
60
68
 
69
+ <details>
70
+ <summary>Alternative: Use Bun</summary>
71
+
72
+ ```json
73
+ {
74
+ "mcpServers": {
75
+ "context7": {
76
+ "command": "bunx",
77
+ "args": ["-y", "@upstash/context7-mcp@latest"]
78
+ }
79
+ }
80
+ }
81
+ ```
82
+
83
+ </details>
84
+
85
+ <details>
86
+ <summary>Alternative: Use Deno</summary>
87
+
88
+ ```json
89
+ {
90
+ "mcpServers": {
91
+ "context7": {
92
+ "command": "deno",
93
+ "args": ["run", "--allow-net", "npm:@upstash/context7-mcp"]
94
+ }
95
+ }
96
+ }
97
+ ```
98
+
99
+ </details>
100
+
61
101
  ### Install in Windsurf
62
102
 
63
103
  Add this to your Windsurf MCP config file. See [Windsurf MCP docs](https://docs.windsurf.com/windsurf/mcp) for more info.
@@ -73,9 +113,12 @@ Add this to your Windsurf MCP config file. See [Windsurf MCP docs](https://docs.
73
113
  }
74
114
  ```
75
115
 
76
- ### Install in VSCode
116
+ ### Install in VS Code
77
117
 
78
- Add this to your VSCode MCP config file. See [VSCode MCP docs](https://code.visualstudio.com/docs/copilot/chat/mcp-servers) for more info.
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)
120
+
121
+ 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.
79
122
 
80
123
  ```json
81
124
  {
@@ -89,14 +132,37 @@ Add this to your VSCode MCP config file. See [VSCode MCP docs](https://code.visu
89
132
  }
90
133
  ```
91
134
 
135
+ ### Install in Claude Code
136
+
137
+ 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.
138
+
139
+ ```sh
140
+ claude mcp add context7 -- npx -y @upstash/context7-mcp@latest
141
+ ```
142
+
143
+ ### Install in Claude Desktop
144
+
145
+ Add this to your Claude Desktop `claude_desktop_config.json` file. See [Claude Desktop MCP docs](https://modelcontextprotocol.io/quickstart/user) for more info.
146
+
147
+ ```json
148
+ {
149
+ "mcpServers": {
150
+ "Context7": {
151
+ "command": "npx",
152
+ "args": ["-y", "@upstash/context7-mcp@latest"]
153
+ }
154
+ }
155
+ }
156
+ ```
157
+
92
158
  ### Available Tools
93
159
 
94
160
  - `resolve-library-id`: Resolves a general library name into a Context7-compatible library ID.
95
- - `libraryName` (optional): Search and rerank results
161
+ - `libraryName` (required)
96
162
  - `get-library-docs`: Fetches documentation for a library using a Context7-compatible library ID.
97
163
  - `context7CompatibleLibraryID` (required)
98
164
  - `topic` (optional): Focus the docs on a specific topic (e.g., "routing", "hooks")
99
- - `tokens` (optional, default 5000): Max number of tokens to return
165
+ - `tokens` (optional, default 5000): Max number of tokens to return. Values less than 5000 are automatically increased to 5000.
100
166
 
101
167
  ## Development
102
168
 
@@ -131,6 +197,46 @@ bun run build
131
197
  npx -y @modelcontextprotocol/inspector npx @upstash/context7-mcp@latest
132
198
  ```
133
199
 
200
+ ## Troubleshooting
201
+
202
+ ### ERR_MODULE_NOT_FOUND
203
+
204
+ If you see this error, try using `bunx` instead of `npx`.
205
+
206
+ ```json
207
+ {
208
+ "mcpServers": {
209
+ "context7": {
210
+ "command": "bunx",
211
+ "args": ["-y", "@upstash/context7-mcp@latest"]
212
+ }
213
+ }
214
+ }
215
+ ```
216
+
217
+ This often resolves module resolution issues, especially in environments where `npx` does not properly install or resolve packages.
218
+
219
+ ### MCP Client Errors
220
+
221
+ 1. Try removing `@latest` from the package name.
222
+
223
+ 2. Try using `bunx` as an alternative.
224
+
225
+ 3. Try using `deno` as an alternative.
226
+
227
+ ## Context7 In Media
228
+
229
+ - [Better Stack: "Free Tool Makes Cursor 10x Smarter"](https://youtu.be/52FC3qObp9E)
230
+ - [Cole Medin: "This is Hands Down the BEST MCP Server for AI Coding Assistants"](https://www.youtube.com/watch?v=G7gK8H6u7Rs)
231
+ - [Income stream surfers: "Context7 + SequentialThinking MCPs: Is This AGI?"](https://www.youtube.com/watch?v=-ggvzyLpK6o)
232
+ - [Julian Goldie SEO: "Context7: New MCP AI Agent Update"](https://www.youtube.com/watch?v=CTZm6fBYisc)
233
+ - [JeredBlu: "Context 7 MCP: Get Documentation Instantly + VS Code Setup"](https://www.youtube.com/watch?v=-ls0D-rtET4)
234
+ - [Income stream surfers: "Context7: The New MCP Server That Will CHANGE AI Coding"](https://www.youtube.com/watch?v=PS-2Azb-C3M)
235
+
236
+ ## Star History
237
+
238
+ [![Star History Chart](https://api.star-history.com/svg?repos=upstash/context7&type=Date)](https://www.star-history.com/#upstash/context7&Date)
239
+
134
240
  ## License
135
241
 
136
242
  MIT
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ const DEFAULT_MINIMUM_TOKENS = 5000;
9
9
  const server = new McpServer({
10
10
  name: "Context7",
11
11
  description: "Retrieves up-to-date documentation and code examples for any library.",
12
- version: "1.0.4",
12
+ version: "1.0.6",
13
13
  capabilities: {
14
14
  resources: {},
15
15
  tools: {},
@@ -19,10 +19,9 @@ const server = new McpServer({
19
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.", {
20
20
  libraryName: z
21
21
  .string()
22
- .optional()
23
- .describe("Optional library name to search for and rerank results based on."),
22
+ .describe("Library name to search for and retrieve a Context7-compatible library ID."),
24
23
  }, async ({ libraryName }) => {
25
- const searchResponse = await searchLibraries(libraryName || "");
24
+ const searchResponse = await searchLibraries(libraryName);
26
25
  if (!searchResponse || !searchResponse.results) {
27
26
  return {
28
27
  content: [
@@ -62,8 +61,8 @@ server.tool("get-library-docs", "Fetches up-to-date documentation for a library.
62
61
  .optional()
63
62
  .describe("Topic to focus documentation on (e.g., 'hooks', 'routing')."),
64
63
  tokens: z
65
- .number()
66
- .min(DEFAULT_MINIMUM_TOKENS)
64
+ .preprocess((val) => (typeof val === "string" ? Number(val) : val), z.number())
65
+ .transform((val) => (val < DEFAULT_MINIMUM_TOKENS ? DEFAULT_MINIMUM_TOKENS : val))
67
66
  .optional()
68
67
  .describe(`Maximum number of tokens of documentation to retrieve (default: ${DEFAULT_MINIMUM_TOKENS}). Higher values provide more context but consume more tokens.`),
69
68
  }, async ({ context7CompatibleLibraryID, tokens = DEFAULT_MINIMUM_TOKENS, topic = "" }) => {
package/dist/lib/utils.js CHANGED
@@ -4,7 +4,7 @@
4
4
  * @returns Formatted search result string
5
5
  */
6
6
  export function formatSearchResult(result) {
7
- return `Title: ${result.title}\n\nContext7-compatible library ID: ${result.id}`;
7
+ return `Title: ${result.title}\n\nContext7-compatible library ID: ${result.id}\n\nDescription: ${result.description}`;
8
8
  }
9
9
  /**
10
10
  * Format search results into a string representation
@@ -16,5 +16,5 @@ export function formatSearchResults(searchResponse) {
16
16
  return "No documentation libraries found matching your query.";
17
17
  }
18
18
  const formattedResults = searchResponse.results.map(formatSearchResult);
19
- return formattedResults.join("\n\n");
19
+ return formattedResults.join("\n\n--------------------\n");
20
20
  }
package/package.json CHANGED
@@ -1,44 +1 @@
1
- {
2
- "name": "@upstash/context7-mcp",
3
- "version": "1.0.4",
4
- "description": "MCP server for Context7",
5
- "scripts": {
6
- "test": "echo \"Error: no test specified\" && exit 1",
7
- "build": "tsc && chmod 755 dist/index.js",
8
- "format": "prettier --write .",
9
- "lint": "eslint \"**/*.{js,ts,tsx}\" --fix"
10
- },
11
- "repository": {
12
- "type": "git",
13
- "url": "git+https://github.com/upstash/context7-mcp.git"
14
- },
15
- "keywords": [],
16
- "author": "",
17
- "license": "MIT",
18
- "type": "module",
19
- "bin": {
20
- "context7-mcp": "dist/index.js"
21
- },
22
- "files": [
23
- "dist"
24
- ],
25
- "bugs": {
26
- "url": "https://github.com/upstash/context7-mcp/issues"
27
- },
28
- "homepage": "https://github.com/upstash/context7-mcp#readme",
29
- "dependencies": {
30
- "@modelcontextprotocol/sdk": "^1.8.0",
31
- "zod": "^3.24.2"
32
- },
33
- "devDependencies": {
34
- "@types/node": "^22.13.14",
35
- "@typescript-eslint/eslint-plugin": "^8.28.0",
36
- "@typescript-eslint/parser": "^8.28.0",
37
- "eslint": "^9.23.0",
38
- "eslint-config-prettier": "^10.1.1",
39
- "eslint-plugin-prettier": "^5.2.5",
40
- "prettier": "^3.5.3",
41
- "typescript": "^5.8.2",
42
- "typescript-eslint": "^8.28.0"
43
- }
44
- }
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"}}