How to pass the Context7 API key when installed as a Claude Code plugin?
Context7 1.0.0 installed as a Claude Code plugin from the upstash/context7 marketplace ignores CONTEXT7_API_KEY set in ~/.zshrc, and the Context7 dashboard shows no token usage. On macOS, how do I authenticate Context7 when using it as a plugin, or is there a supported alternative?
Originally asked on GitHub: https://github.com/upstash/context7/issues/1713
5 answers
Status: explained. A Context7 maintainer confirmed that Claude Code plugins currently do not allow users to pass API keys for MCP servers during plugin installation, so the official Context7 plugin's default config uses the anonymous access tier. The plugin therefore does not authenticate with a personal API key, which is why the dashboard shows no token usage. The maintainer says this is known friction and is being prioritized, with possible future fixes being OAuth in the plugin or supporting dynamic header values.
Until that is resolved, the maintainer's recommended workaround is to skip the plugin and add Context7 directly as an MCP server:
claude mcp add --header "CONTEXT7_API_KEY: YOUR_API_KEY" --transport http context7 https://mcp.context7.com/mcp (opens external site)
One commenter tried editing the installed plugin cache at ~/.claude/plugins/cache/every-marketplace/compound-engineering//.claude-plugin/plugin.json to add "headers": { "CONTEXT7_API_KEY": "your-key" } to the context7 MCP server and restarted Claude Code, but later reported that this workaround did not hold up. Another commenter pointed to Claude Code's documentation saying the "env" syntax should work for plugin-provided MCP servers, but that was not confirmed or tested in this thread.
As general advice, avoid putting your API key in committed configuration files, and note that passing it on the command line can leave it in shell history.
Did this work for you?What a GitHub user tried on GitHub (Didn't work)
Installed Context7 as a Claude Code plugin and set CONTEXT7_API_KEY in ~/.zshrc; the Context7 dashboard still showed no token usage, so the environment variable was not picked up by the plugin.
Source: https://github.com/upstash/context7/issues/1713 (opens external site)
Did this work for you?What @mattsilv tried on GitHub (Didn't work)
Manually edited the plugin cache file at ~/.claude/plugins/cache/every-marketplace/compound-engineering//.claude-plugin/plugin.json to add a CONTEXT7_API_KEY header to the context7 MCP server config and restarted Claude Code; the commenter later reported this workaround does not work.
Source: https://github.com/upstash/context7/issues/1713#issuecomment-3860922081 (opens external site)
Did this work for you?What @fahreddinozcan tried on GitHub (Outcome unclear)
A maintainer suggested adding Context7 directly with claude mcp add --header "CONTEXT7_API_KEY: YOUR_API_KEY" --transport http context7 https://mcp.context7.com/mcp (opens external site) instead of using the plugin; the thread does not say whether this was tried.
Source: https://github.com/upstash/context7/issues/1713#issuecomment-3864889024 (opens external site)
Did this work for you?What @alexander-m-loris tried on GitHub (Outcome unclear)
A commenter suggested that Claude Code's documentation supports the "env" syntax for plugin-provided MCP servers, which might let plugins receive environment variables; this was not tested in the thread.
Source: https://github.com/upstash/context7/issues/1713#issuecomment-3865582628 (opens external site)
Did this work for you?
Related questions
- How do I add a library's generated llms.txt / llms-full.txt file to Context7?
- Does Context7 support documentation versioning like Next.js 13 vs 14?
- Does the context7 MCP server support SSE or Streamable HTTP transport?
- Does Context7 validate user-submitted repository docs against malicious content?
- Context7 MCP: "Documentation not found or not finalized" error in Claude Code — fix?