8000 Context7 MCP server fails to retrieve library documentation in Claude Desktop · Issue #71 · upstash/context7 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Context7 MCP server fails to retrieve library documentation in Claude Desktop #71

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
egoes opened this issue Apr 23, 2025 · 13 comments
Closed
Labels
mcp Related to mcp server

Comments

@egoes
Copy link
egoes commented Apr 23, 2025

Image
Image

Description

I'm encountering an issue with the Context7 MCP server integration in Claude Desktop. While the server connection appears to be working, it consistently fails to retrieve library documentation, despite successful configuration and operation in Claude Code.

Environment

  • Application: Claude Desktop (Version 0.9.2 on macOS Sequoia 15.4.1)
  • MCP Server: Context7 (@upstash/context7-mcp@latest)
  • Configuration: Added via config file

Steps to Reproduce

  1. Added Context7 MCP server to Claude Desktop configuration:
"Context7": {
  "command": "npx",
  "args": ["-y", "@upstash/context7-mcp@latest"]
}
  1. Also tried with lowercase "context7" name
  2. Restarted Claude Desktop
  3. Attempted to resolve library IDs and fetch documentation using various approaches

What Happened

When attempting to resolve library IDs or retrieve documentation:

  • The server responds, indicating connection is successful
  • All library resolving and documentation retrieval attempts fail with errors
  • Error messages suggest that the library ID format might be incorrect
  • Even when using a specifically provided Context7-compatible library ID, retrieval fails

Typical error:

Failed to retrieve library documentation data from Context7

Or when trying direct document retrieval:

Documentation not found or not finalized for this library. This might have happened because you used an invalid Context7-compatible library ID.

What Was Expected

Successful resolution of library IDs and retrieval of documentation, as experienced in Claude Code environment.

Additional Context

  • The same integration works perfectly in Claude Code with the command:
    claude mcp add context7 -- npx -y @upstash/context7-mcp@latest
  • Tried multiple library names including "react", "nextjs", "mongodb/docs", and a specific Kirby library ID
  • Also attempted with different runners as suggested in the README:
    • Tried with bunx instead of npx
    • Tried with deno
    • Tried without the @latest tag
  • Other MCP servers (filesystem, memory, ddg-search) appear to be working correctly

Thank you for your help resolving this issue!

@enesgules
Copy link
Collaborator

Could you please check Claude's logs for errors? You can use the following command:
tail -n 20 -f ~/Library/Logs/Claude/mcp*.log

Also just for safe measure could you try telling Claude to use " (double quote) instead of ' (single quote) for the tool parameter :D

@enesgules enesgules added the mcp Related to mcp server label Apr 23, 2025
@jasondsmith72
Copy link

2025-04-23T11:56:05.606Z [Runner] WebSocket error: Unexpected server response: 524
Error: MCP error -32001: Request timed out

Here is what I"m seeing in claude desktop, I also can't get this working in vscode with cline or roocode.

@egoes
Copy link
Author
egoes commented Apr 23, 2025

Could you please check Claude's logs for errors?

Oh yes, the log, sorry.
I just went and freshly configure the server, then relaunch Claude Desktop app.
Before any request, the log shows errors.

Then I made a request and it resulted in the errors you see from line 127.
Hope this helps.

The double quote request didn’t work either.

mcp-server-Context7.log

@enesgules
Copy link
Collaborator

I see ReferenceError: fetch is not defined in your logs. This error occurs because the fetch API is being used in a Node.js environment without a global fetch implementation. Older versions of Node.js (prior to v18) do not have fetch available globally by default.

It means your Node.js version is < 18. Just upgrading Node.js should solve the problem. @egoes Check your version with node -v please.

Also, both Bun and Deno support fetch natively. So if you’re using bunx or deno, this error shouldn’t occur.

@enesgules
Copy link
Collaborator

2025-04-23T11:56:05.606Z [Runner] WebSocket error: Unexpected server response: 524 Error: MCP error -32001: Request timed out

Here is what I"m seeing in claude desktop, I also can't get this working in vscode with cline or roocode.

Could you provide your claude desktop logs please. You can use tail -n 20 -f ~/Library/Logs/Claude/mcp*.log

@egoes
Copy link
Author
egoes commented Apr 24, 2025

Check your version with node -v please.

After verifying on two machines, I'm equally running on both: Node v23.11.0 :/

Also, both Bun and Deno support fetch natively. So if you’re using bunx or deno, this error shouldn’t occur.

As noted in my initial post, bunx and deno (freshly installed) gave me the same errors.
The common denominator is that I install these via Homebrew. Therefore, I also tried setting the full path to /opt/homebrew/bin/npx, bunx or deno, but still without success.

@JayceeB1
Copy link
JayceeB1 commented Apr 24, 2025

Here's a simplified explanation of the issue and fix I've worked out with Claude 3.7 :-) :

Issue Found

When trying to use Context7 MCP server with DataTables, the API calls to context7.com fail due to SSL certificate verification issues. Specifically, the error is:

schannel: next InitializeSecurityContext failed: CRYPT_E_NO_REVOCATION_CHECK (0x80092012)

This prevents the MCP server from retrieving library documentation, even though the documentation exists on the Context7 website.

Note

configuration:

   "context7": {
     "command": "node",
     "args": [
       "C:/Users/xxxx/Documents/MCP Context7/dist/index.js"
     ]
   },

Solution

I implemented a multi-layered approach to fix this:

- const response = await fetch(url);
+ // Options to improve connection reliability
+ const fetchOptions = { 
+   headers: {
+     "User-Agent": "Context7-MCP/1.0",
+     "Accept": "application/json",
+     "X-Context7-Source": "mcp-server"
+   }
+ };
+
+ // Attempt direct API fetch with timeout
+ async function safeApiFetch(url: URL, options = {}) {
+   try {
+     const controller = new AbortController();
+     const timeout = setTimeout(() => controller.abort(), 5000);
+     
+     const response = await fetch(url, {
+       ...fetchOptions,
+       ...options,
+       signal: controller.signal
+     });
+     
+     clearTimeout(timeout);
+     return response;
+   } catch (error) {
+     console.error(`Error fetching ${url}: ${error}`);
+     return null;
+   }
+ }
+
+ // Fallback to CORS proxies when direct access fails
+ async function proxyApiFetch(url: URL) {
+   try {
+     const proxyUrls = [
+       `https://api.allorigins.win/raw?url=${encodeURIComponent(url.toString())}`,
+       `https://corsproxy.io/?${encodeURIComponent(url.toString())}`,
+       `https://proxy.cors.sh/${url.toString()}`
+     ];
+     
+     for (const proxyUrl of proxyUrls) {
+       try {
+         const response = await fetch(proxyUrl);
+         if (response.ok) return response;
+       } catch (e) {
+         console.error(`Proxy ${proxyUrl} failed: ${e}`);
+       }
+     }
+     return null;
+   } catch (error) {
+     console.error(`All proxies failed: ${error}`);
+     return null;
+   }
+ }
+
+ // Try multiple fetch methods
+ let response = await safeApiFetch(url);
+ 
+ // If direct fetch fails, try proxy
+ if (!response || !response.ok) {
+   console.error("Direct fetch failed, trying proxy");
+   response = await proxyApiFetch(url);
+ }

Additionally, I added a local cache for common libraries to ensure functionality even when all network methods fail:

+ // Local documentation cache for common libraries 
+ const hardcodedDocs: Record<string, string> = {
+   "datatables/datatables": `TITLE: Initializing DataTables with jQuery
+     // Documentation content here
+   `
+ };
+ 
+ // Check cache first
+ if (hardcodedDocs[libraryId]) {
+   console.error(`Using hardcoded docs for ${libraryId}`);
+   return hardcodedDocs[libraryId];
+ }

This solution ensures the Context7 MCP server remains functional even when facing SSL/networking issues, with graceful degradation to cached content when needed.

@jacobzweig
Copy link

@egoes – I was running into this same issue in Cursor and wanted to share what finally worked for me, along with some things I tried that didn’t.

The problem:

I was seeing runtime errors like fetch is not defined, even though I had a recent version of Node installed via Homebrew. To investigate, I added a small shim using NODE_OPTIONS=--require=./debug-fetch.js to log the runtime Node version and check for fetch availability.

To my surprise, it was defaulting to an older system-level Node installation (v16.x) from /usr/local/bin/node, which doesn’t include fetch globally.

Things I tried (unsuccessfully)

  • Explicitly setting the Node path in the MCP config using both Homebrew and nvm versions.
  • Preloading a debug script via NODE_OPTIONS to confirm that the correct version was being picked up — which worked in the terminal, but failed in Cursor.
  • Hardcoding node and npx paths to newer versions.
  • Wrapping the working terminal command in a shell script and using that as the MCP command.

Despite all this, Cursor still seemed to fall back to the outdated system Node version when launching the MCP. Perplexing.

What finally worked

I downloaded and installed the latest Node version directly from the official installer: https://nodejs.org/en

After doing that, Cursor began correctly using the updated runtime and the issue went away.

Hope this helps anyone else running into the same thing. Would love to understand why Cursor doesn’t consistently respect the system’s shell environment or nvm setup.

@enesgules
Copy link
Collaborator

Hey @egoes were you able to solve it with @jacobzweig 's solution?

@egoes
Copy link
Author
egoes commented Apr 28, 2025

Hey, I missed it, sorry. Will give that a go!

@jacobzweig did you uninstall the homebrew version first?

@egoes
Copy link
Author
egoes commented Apr 29, 2025

@enesgules As I prefer sticking with homebrew installs and thanks to @jacobzweig 's hints, I went digging in my Mac for older installed files.

I first poked around to search for potential other node installs and didn't find any. Then, I found an old .nvm directory in my home folder. It contained subdirectories with node 16 and 18 files. I deleted them all as I don't use nvm (I apparently once tried). Then, I reconfigured context7 in Claude Desktop and ace, it can now access the repos. Phew! 😅

The other route I was about to try, but didn't have to, was to eventually install the node fetch package globally npm install -g node-fetch but I don't know it that would have been a good idea.

Thanks all for your kind help.

@enesgules
Copy link
Collaborator

Great! Let us know if you encounter other errors.

@spencerkordecki
Copy link

@enesgules As I prefer sticking with homebrew installs and thanks to @jacobzweig 's hints, I went digging in my Mac for older installed files.

I first poked around to search for potential other node installs and didn't find any. Then, I found an old .nvm directory in my home folder. It contained subdirectories with node 16 and 18 files. I deleted them all as I don't use nvm (I apparently once tried). Then, I reconfigured context7 in Claude Desktop and ace, it can now access the repos. Phew! 😅

The other route I was about to try, but didn't have to, was to eventually install the node fetch package globally npm install -g node-fetch but I don't know it that would have been a good idea.

Thanks all for your kind help.

just wanted to +1 this that fix also worked for me! not sure what exactly what was conflicting, but deleting old, unused versions of node in .nvm fixed the fetching of docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mcp Related to mcp server
Projects
None yet
Development

No branches or pull requests

6 participants
0