context7 icon indicating copy to clipboard operation
context7 copied to clipboard

“Unauthorized. Please check your API key.” regardless of API key validity

Open evanjcosgrove opened this issue 3 months ago • 21 comments

Summary

Repeated resolve-library-id calls to the Context7 MCP server return “Unauthorized. Please check your API key.” even after multiple fresh integrations (Cursor one-click, Claude Code remote, Claude Code local) and regenerating API keys each time.

Steps to Reproduce

  1. Install the Context7 MCP server via any supported method (Cursor one-click, Claude Code remote server, or Claude Code local server).
  2. Configure a newly generated Context7 API key for the code block.
  3. Connect the MCP client (Cursor/Claude Code) to the Context7 server.
  4. Invoke the resolve-library-id tool with any library name, e.g. {"libraryName": "expo 54"}.

Expected Behavior

The call should return a valid library ID (or a not-found response) when a correct API key is provided.

Actual Behavior

Every call fails with Unauthorized. Please check your API key. despite the API key being freshly generated, live, and recognized by the install steps.

Error Log Excerpt (from mcp.log)

[Context7] Message from server: {"result":{"protocolVersion":"2025-06-18","capabilities":{"tools":{"listChanged":true}},"serverInfo":{"name":"Context7","version":"1.0.13"},"instructions":"Use this server to retrieve up-to-date documentation and code examples for any library."},"jsonrpc":"2.0","id":0}
2025-09-25T02:50:30.285Z [info] [Context7] Message from client: {"method":"notifications/initialized","jsonrpc":"2.0"}
2025-09-25T02:50:30.285Z [info] [Context7] Message from client: {"method":"tools/list","params":{},"jsonrpc":"2.0","id":1}
2025-09-25T02:50:30.285Z [info] [Context7] Message from client: {"method":"prompts/list","params":{},"jsonrpc":"2.0","id":2}
2025-09-25T02:50:30.285Z [info] [Context7] Message from client: {"method":"resources/list","params":{},"jsonrpc":"2.0","id":3}
2025-09-25T02:50:30.287Z [info] [Context7] Message from server: {"result":{"tools":[{"name":"resolve-library-id", ... }]}}
2025-09-25T02:50:30.287Z [info] [Context7] Message from server: {"jsonrpc":"2.0","id":2,"error":{"code":-32601,"message":"Method not found"}}
2025-09-25T02:50:30.287Z [info] [Context7] Message from server: {"jsonrpc":"2.0","id":3,"error":{"code":-32601,"message":"Method not found"}}

Environment

  • Context7 MCP server v1.0.13
  • MCP clients tried: Cursor one-click install, Claude Code remote server, Claude Code local server
  • OS: Linux (Docker Desktop environment), but same issue occurs locally (macOS Tahoe 26.0).
  • API key: newly generated for each attempt (confirmed saved in client config)

Workarounds Attempted

  • Deleted old keys and generated new ones before each install.
  • Reinstalled the MCP server via each method listed above.
  • Restarted clients and reloaded configurations.
  • Verified the API key was being read by each client.
    None of these resolved the authorization failure.

Additional Notes

This issue blocks access to get-library-docs because resolve-library-id must succeed first. Any guidance or a fix would be greatly appreciated!

evanjcosgrove avatar Sep 25 '25 04:09 evanjcosgrove

Thanks for reporting, we are investigating the issue

enesgules avatar Sep 26 '25 07:09 enesgules

what is the point of api keys? traffic for your website?

coolcardproject avatar Sep 26 '25 10:09 coolcardproject

To provide higher rate limits, and configure the mcp responses if you want to limit your search to certain organizations or repos

enesgules avatar Sep 26 '25 12:09 enesgules

Btw they are completely optional @coolcardproject

enesgules avatar Sep 26 '25 12:09 enesgules

Any update @evanjcosgrove what is the log you see now? Still can't authorize?

enesgules avatar Oct 07 '25 11:10 enesgules

???

guillaumebadin avatar Oct 30 '25 15:10 guillaumebadin

Hey guys, if you could please fix this issue by managing the pull request, seriously, it's too... It's a shame that we have this type of issue on ClaudeCode which is the best, which is very, very used by developers. @enesgules

guillaumebadin avatar Oct 30 '25 15:10 guillaumebadin

Hey @guillaumebadin what are the logs you are seeing? Can you use the api key in the dashboard?

enesgules avatar Oct 30 '25 15:10 enesgules

Do you have any logs that you can share with us?

enesgules avatar Oct 30 '25 15:10 enesgules

@enesgules For what it's worth, I'm seeing this in Claude Code as well.

Let's pull up the documentation for Claude Code using the context7 mcp

⏺ I'll use the Context7 MCP to pull up the Claude Code documentation.

⏺ context7 - resolve-library-id (MCP)(libraryName: "claude code") ⎿  Unauthorized. Please check your API key. The API key you provided (possibly incorrect) is: ctx7sk-########-####-####-####-################. API keys should start with 'ctx7sk'

Using # to redact the key, but I am using a valid API key as far as I can tell.

jesse-dot-id avatar Oct 30 '25 18:10 jesse-dot-id

I fixed this by regenerating my Context 7 API key, editing /Users/jesse/.claude.json, replacing the context7 API key, saving, and restarting Claude. My old key must have been invalidated or something, which is strange because it wasn't old.

jesse-dot-id avatar Oct 30 '25 18:10 jesse-dot-id

The same problem occurred in VS Code.

{
  "servers": {
    "context7": {
      "type": "http",
      "url": "https://mcp.context7.com/mcp",
      "headers": {
        "CONTEXT7_API_KEY": "ctx7sk-..."
      }
    }
  }
}
Unauthorized. Please check your API key. The API key you provided (possibly incorrect) is: ctx7sk-... API keys should start with 'ctx7sk'

API Key is correct(starting with 'ctx7sk') but error have occurred.

bldev2473 avatar Nov 04 '25 10:11 bldev2473

Hey @bldev2473 does it match with the api key that is displayed in your user dashboard?

enesgules avatar Nov 04 '25 11:11 enesgules

@enesgules I entered the dashboard key correctly. The problem is that after closing VS Code and restarting it later (exact timing unclear), this error appears when using the MCP server. Regenerating the API key and re-entering it in the MCP configuration works fine. The issue is that I have to regenerate it every time :(

I store the API key locally for use, and it shouldn't change, but I should check it out.

bldev2473 avatar Nov 04 '25 11:11 bldev2473

This is super weird let me try to reproduce thanks

enesgules avatar Nov 04 '25 12:11 enesgules

I had a very similar issue just now in Warp: the key was rejected as unauthorized. I had to delete the MCP from the Warp config, add it again and now the requests work just fine (with the same key).

thekarel avatar Nov 06 '25 14:11 thekarel

I've just realised that the API key saved in my local settings file has been automatically changed back to the old one. That's why I was experiencing authentication issues. Why on earth was the local settings file modified? It's really strange. I'm using VSCode, but seeing that others have reported similar problems makes me wonder if it's an IDE issue. Could it be related to the Context7 MCP server?

bldev2473 avatar Nov 06 '25 15:11 bldev2473

I ran into this issue as well. My guess is that I was updating only a project-level API key but the MCP was pulling from a more global user setting. What worked: claude mcp remove context7 in terminal Then claude mcp add context7 -- npx -y @upstash/context7-mcp --api-key MY_NEW_CONTEXT7_KEY

mefrem avatar Nov 07 '25 19:11 mefrem

same problem now

pietrondo avatar Nov 08 '25 16:11 pietrondo

Same problem

bayraak avatar Dec 01 '25 13:12 bayraak

Hey @bayraak Could you please chare your config and client and any error logs you see and confirm its the same api key you see in the dashboard and could you try creating a new api key too

enesgules avatar Dec 01 '25 14:12 enesgules

I've been having the same issue in Claude Desktop. Claude Code has no issue, and I imported the mcp servers from desktop.

Claude says:

Claude Desktop is using Node.js v16.20.2, but the @upstash/context7-mcp package requires Node 18+.

  The error ReferenceError: ReadableStream is not defined occurs because:
  - ReadableStream became a global in Node 18
  - The undici library (used for HTTP fetch) expects it to exist
  - Node 16 doesn't have ReadableStream as a global

It suggested adding this to claude_desktop_config.json which fixed the issue:

"env": {
       "PATH": "/Users/channing/.nvm/versions/node/v20.19.6/bin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/"
}

Here is the log which shows two different errors. context7.log

channingwalton avatar Dec 12 '25 11:12 channingwalton

I think this issue is unrelated to the unauthorized api key issue @channingwalton and maybe specific to your local setup where claude desktop uses an older version of node. Let me close this issue since it's been stale for a while and lets see if other users experience anything similar in the future.

enesgules avatar Dec 12 '25 12:12 enesgules

I think this issue is unrelated to the unauthorized api key issue

You're quite right, apologies.

channingwalton avatar Dec 12 '25 15:12 channingwalton