Context7 Platform -- Up-to-date docs for AI agents
fix(cli): write the API key as an Authorization header (#2957)
Fahreddin Özcanb89a04e620d9
diff --git a/.changeset/codex-authorization-header.md b/.changeset/codex-authorization-header.mdnew file mode 100644index 00000000..83ee05be--- /dev/null+++ b/.changeset/codex-authorization-header.md@@ -0,0 +1,5 @@+---+"ctx7": patch+---++`ctx7 setup` now writes the API key as a standard `Authorization: Bearer <key>` header instead of a custom `CONTEXT7_API_KEY` header. Codex resolves a server's auth mode from `bearer_token_env_var` or a header literally named `Authorization`, so a custom name read as "no credential configured": Codex fell through to an OAuth credential stored against the same server name and URL, refreshed it during startup, and when that refresh token was dead the server failed with `invalid_grant` before the API key was ever sent. The hosted endpoint accepts both header forms, so existing configs keep working.diff --git a/README.md b/README.mdindex 8a01c353..0b225b06 100644--- a/README.md+++ b/README.md@@ -56,7 +56,7 @@ Authenticates via OAuth, generates an API key, and installs the appropriate skilTo remove the generated setup later, run `npx ctx7 remove`. If you globally installed the CLI with `npm install -g ctx7`, remove that package separately with `npm uninstall -g ctx7`.-To configure manually, use the Context7 server URL `https://mcp.context7.com/mcp` with your MCP client and pass your API key via the `CONTEXT7_API_KEY` header. See the link below for client-specific setup instructions.+To configure manually, use the Context7 server URL `https://mcp.context7.com/mcp` with your MCP client and pass your API key via the `Authorization: Bearer YOUR_API_KEY` header. See the link below for client-specific setup instructions.**[Manual Installation / Other Clients →](https://context7.com/docs/resources/all-clients)**diff --git a/docs/clients/codex.mdx b/docs/clients/codex.mdxindex 58383db9..a71050ec 100644--- a/docs/clients/codex.mdx+++ b/docs/clients/codex.mdx@@ -68,7 +68,7 @@ Prefer the hosted server? Use the remote connection instead:```toml[mcp_servers.context7]url = "https://mcp.context7.com/mcp"-http_headers = { "CONTEXT7_API_KEY" = "YOUR_API_KEY" }+http_headers = { "Authorization" = "Bearer YOUR_API_KEY" }```### Codex Desktopdiff --git a/docs/integrations/code-rabbit.mdx b/docs/integrations/code-rabbit.mdxindex bb893c40..66a3742f 100644--- a/docs/integrations/code-rabbit.mdx+++ b/docs/integrations/code-rabbit.mdx@@ -25,7 +25,7 @@ description: AI-powered code review tool```json{- "CONTEXT7_API_KEY": "YOUR_API_KEY"+ "Authorization": "Bearer YOUR_API_KEY"}```diff --git a/docs/integrations/factory-ai.mdx b/docs/integrations/factory-ai.mdxindex 4d34370f..54e339dc 100644--- a/docs/integrations/factory-ai.mdx+++ b/docs/integrations/factory-ai.mdx@@ -15,7 +15,7 @@ There are multiple ways to add Context7 as an MCP server in Factory AI. Replace### Using the CLI```bash-droid mcp add context7 https://mcp.context7.com/mcp --type http --header "CONTEXT7_API_KEY: YOUR_API_KEY"+droid mcp add context7 https://mcp.context7.com/mcp --type http --header "Authorization: Bearer YOUR_API_KEY"```### Using the MCP Manager@@ -33,7 +33,7 @@ Add Context7 directly to your `.factory/mcp.json` (project-level) or `~/.factory"type": "http","url": "https://mcp.context7.com/mcp","headers": {- "CONTEXT7_API_KEY": "YOUR_API_KEY"+ "Authorization": "Bearer YOUR_API_KEY"}}}diff --git a/docs/integrations/mastra.mdx b/docs/integrations/mastra.mdxindex afba5868..f6138a97 100644--- a/docs/integrations/mastra.mdx+++ b/docs/integrations/mastra.mdx@@ -31,7 +31,7 @@ For more details on how Mastra handles MCP, see the [Mastra MCP documentation](hurl: new URL("https://mcp.context7.com/mcp"),requestInit: {headers: {- CONTEXT7_API_KEY: process.env.CONTEXT7_API_KEY!,+ Authorization: `Bearer ${process.env.CONTEXT7_API_KEY}`,},},},diff --git a/docs/resources/all-clients.mdx b/docs/resources/all-clients.mdxindex ba3ce73f..1a2713cd 100644--- a/docs/resources/all-clients.mdx+++ b/docs/resources/all-clients.mdx@@ -3,7 +3,7 @@ title: MCP Clientsdescription: Installation examples for MCP clients----Context7 supports all MCP clients. Below are configuration examples for popular clients. If your client isn't listed, check its documentation for MCP server installation. To configure manually, use the Context7 server URL `https://mcp.context7.com/mcp` with your MCP client and pass your API key via the `CONTEXT7_API_KEY` header.+Context7 supports all MCP clients. Below are configuration examples for popular clients. If your client isn't listed, check its documentation for MCP server installation. To configure manually, use the Context7 server URL `https://mcp.context7.com/mcp` with your MCP client and pass your API key via the `Authorization: Bearer YOUR_API_KEY` header.<Tip>Looking for the easiest way to get started? Use `npx ctx7 setup` to configure Context7@@ -45,7 +45,7 @@ claude mcp add --scope user context7 -- npx -y @upstash/context7-mcp --api-key Y#### Remote Server Connection```sh-claude mcp add --scope user --header "CONTEXT7_API_KEY: YOUR_API_KEY" --transport http context7 https://mcp.context7.com/mcp+claude mcp add --scope user --header "Authorization: Bearer YOUR_API_KEY" --transport http context7 https://mcp.context7.com/mcp```</Accordion>@@ -68,7 +68,7 @@ Since Cursor 1.0, you can click the install button below for instant one-click i"context7": {"url": "https://mcp.context7.com/mcp","headers": {- "CONTEXT7_API_KEY": "YOUR_API_KEY"+ "Authorization": "Bearer YOUR_API_KEY"}}}@@ -104,7 +104,7 @@ Add this to your Opencode configuration file. See [Opencode MCP docs](https://op"type": "remote","url": "https://mcp.context7.com/mcp","headers": {- "CONTEXT7_API_KEY": "YOUR_API_KEY"+ "Authorization": "Bearer YOUR_API_KEY"},"enabled": true}@@ -164,7 +164,7 @@ startup_timeout_ms = 20_000```toml[mcp_servers.context7]url = "https://mcp.context7.com/mcp"-http_headers = { "CONTEXT7_API_KEY" = "YOUR_API_KEY" }+http_headers = { "Authorization" = "Bearer YOUR_API_KEY" }```<Note>If you see startup timeout errors, try increasing `startup_timeout_ms` to `40_000`.</Note>@@ -183,7 +183,7 @@ Add this to your Antigravity MCP config file. See [Antigravity MCP docs](https:/"context7": {"serverUrl": "https://mcp.context7.com/mcp","headers": {- "CONTEXT7_API_KEY": "YOUR_API_KEY"+ "Authorization": "Bearer YOUR_API_KEY"}}}@@ -223,7 +223,7 @@ Add this to your VS Code MCP config file (`.vscode/mcp.json`). See [VS Code MCP"type": "http","url": "https://mcp.context7.com/mcp","headers": {- "CONTEXT7_API_KEY": "YOUR_API_KEY"+ "Authorization": "Bearer YOUR_API_KEY"}}}@@ -272,7 +272,7 @@ To use an API key in Kiro, add:```json"headers": {- "CONTEXT7_API_KEY": "YOUR_API_KEY"+ "Authorization": "Bearer YOUR_API_KEY"}```@@ -325,7 +325,7 @@ Add Context7 under the `mcp` key in your `kilo.jsonc`."type": "remote","url": "https://mcp.context7.com/mcp","headers": {- "CONTEXT7_API_KEY": "YOUR_API_KEY"+ "Authorization": "Bearer YOUR_API_KEY"},"enabled": true}@@ -362,7 +362,7 @@ Add this to your Roo Code MCP configuration file. See [Roo Code MCP docs](https:"type": "streamable-http","url": "https://mcp.context7.com/mcp","headers": {- "CONTEXT7_API_KEY": "YOUR_API_KEY"+ "Authorization": "Bearer YOUR_API_KEY"}}}@@ -396,7 +396,7 @@ Add this to your Devin Desktop MCP config file. See [Devin Desktop MCP docs](htt"context7": {"serverUrl": "https://mcp.context7.com/mcp","headers": {- "CONTEXT7_API_KEY": "YOUR_API_KEY"+ "Authorization": "Bearer YOUR_API_KEY"}}}@@ -517,7 +517,7 @@ Use the Add manually feature and fill in the JSON configuration. See [Trae docum"context7": {"url": "https://mcp.context7.com/mcp","headers": {- "CONTEXT7_API_KEY": "YOUR_API_KEY"+ "Authorization": "Bearer YOUR_API_KEY"}}}@@ -617,7 +617,7 @@ See [Gemini CLI Configuration](https://google-gemini.github.io/gemini-cli/docs/t"context7": {"httpUrl": "https://mcp.context7.com/mcp","headers": {- "CONTEXT7_API_KEY": "YOUR_API_KEY",+ "Authorization": "Bearer YOUR_API_KEY","Accept": "application/json, text/event-stream"}}@@ -734,7 +734,7 @@ Add the following configuration to `Repository` -> `Settings` -> `Code & automat"type": "http","url": "https://mcp.context7.com/mcp","headers": {- "CONTEXT7_API_KEY": "$COPILOT_MCP_CONTEXT7_API_KEY"+ "Authorization": "Bearer $COPILOT_MCP_CONTEXT7_API_KEY"},"tools": ["query-docs", "resolve-library-id"]}@@ -757,7 +757,7 @@ The easiest way is the Context7 plugin, which bundles the MCP server with a skil"type": "http","url": "https://mcp.context7.com/mcp","headers": {- "CONTEXT7_API_KEY": "YOUR_API_KEY"+ "Authorization": "Bearer YOUR_API_KEY"},"tools": ["query-docs", "resolve-library-id"]}@@ -836,7 +836,7 @@ amp mcp add context7 https://mcp.context7.com/mcp#### With API Key (Higher Rate Limits & Private Repos)```sh-amp mcp add context7 --header "CONTEXT7_API_KEY=YOUR_API_KEY" https://mcp.context7.com/mcp+amp mcp add context7 --header "Authorization=Bearer YOUR_API_KEY" https://mcp.context7.com/mcp```</Accordion>@@ -919,7 +919,7 @@ By default, configurations are saved to the project scope (`.qwen/settings.json````shqwen mcp add --transport http context7 https://mcp.context7.com/mcp \- --header "CONTEXT7_API_KEY: YOUR_API_KEY" \+ --header "Authorization: Bearer YOUR_API_KEY" \--header "Accept: application/json, text/event-stream"```@@ -942,7 +942,7 @@ qwen mcp add context7 -- npx -y @upstash/context7-mcp --api-key YOUR_API_KEY"context7": {"httpUrl": "https://mcp.context7.com/mcp","headers": {- "CONTEXT7_API_KEY": "YOUR_API_KEY",+ "Authorization": "Bearer YOUR_API_KEY","Accept": "application/json, text/event-stream"}}@@ -1081,7 +1081,7 @@ See [Visual Studio MCP Servers documentation](https://learn.microsoft.com/visual"type": "http","url": "https://mcp.context7.com/mcp","headers": {- "CONTEXT7_API_KEY": "YOUR_API_KEY"+ "Authorization": "Bearer YOUR_API_KEY"}}}@@ -1118,7 +1118,7 @@ Add this to your Crush configuration file. See [Crush MCP docs](https://github.c"type": "http","url": "https://mcp.context7.com/mcp","headers": {- "CONTEXT7_API_KEY": "YOUR_API_KEY"+ "Authorization": "Bearer YOUR_API_KEY"}}}@@ -1312,7 +1312,7 @@ Factory's droid supports MCP servers through its CLI. See [Factory MCP docs](htt#### Remote Server Connection```sh-droid mcp add context7 https://mcp.context7.com/mcp --type http --header "CONTEXT7_API_KEY: YOUR_API_KEY"+droid mcp add context7 https://mcp.context7.com/mcp --type http --header "Authorization: Bearer YOUR_API_KEY"```#### Local Server Connection@@ -1357,7 +1357,7 @@ AnythingLLM supports MCP Servers through GUI."type": "streamable","url": "https://mcp.context7.com/mcp","headers": {- "CONTEXT7_API_KEY": "YOUR_API_KEY"+ "Authorization": "Bearer YOUR_API_KEY"}}}diff --git a/docs/resources/troubleshooting.mdx b/docs/resources/troubleshooting.mdxindex a82db88b..003b9033 100644--- a/docs/resources/troubleshooting.mdx+++ b/docs/resources/troubleshooting.mdx@@ -175,7 +175,7 @@ If you encounter rate limit errors:"context7": {"url": "https://mcp.context7.com/mcp","headers": {- "CONTEXT7_API_KEY": "YOUR_API_KEY"+ "Authorization": "Bearer YOUR_API_KEY"}}}@@ -194,7 +194,7 @@ For HTTP transport:```json{"headers": {- "CONTEXT7_API_KEY": "YOUR_API_KEY"+ "Authorization": "Bearer YOUR_API_KEY"}}```diff --git a/i18n/README.de.md b/i18n/README.de.mdindex bb800b1e..65bbeca2 100644--- a/i18n/README.de.md+++ b/i18n/README.de.md@@ -178,7 +178,7 @@ Weitere Informationen findest du in der [offiziellen GitHub-Dokumentation](https"type": "http","url": "https://mcp.context7.com/mcp","headers": {- "CONTEXT7_API_KEY": "YOUR_API_KEY"+ "Authorization": "Bearer YOUR_API_KEY"},"tools": ["query-docs", "resolve-library-id"]}diff --git a/i18n/README.es.md b/i18n/README.es.mdindex 5a71509e..9834cbbc 100644--- a/i18n/README.es.md+++ b/i18n/README.es.md@@ -164,7 +164,7 @@ Para más información, consulta la [documentación oficial de GitHub](https://d"type": "http","url": "https://mcp.context7.com/mcp","headers": {- "CONTEXT7_API_KEY": "YOUR_API_KEY"+ "Authorization": "Bearer YOUR_API_KEY"},"tools": ["query-docs", "resolve-library-id"]}diff --git a/i18n/README.fr.md b/i18n/README.fr.mdindex 009bb5ba..b40e8266 100644--- a/i18n/README.fr.md+++ b/i18n/README.fr.md@@ -192,7 +192,7 @@ Pour plus d'informations, consultez la [documentation officielle GitHub](https:/"type": "http","url": "https://mcp.context7.com/mcp","headers": {- "CONTEXT7_API_KEY": "YOUR_API_KEY"+ "Authorization": "Bearer YOUR_API_KEY"},"tools": ["query-docs", "resolve-library-id"]}diff --git a/i18n/README.id-ID.md b/i18n/README.id-ID.mdindex f25819a8..496fba24 100644--- a/i18n/README.id-ID.md+++ b/i18n/README.id-ID.md@@ -660,7 +660,7 @@ Untuk informasi lebih lanjut, lihat [dokumentasi resmi GitHub](https://docs.gith"type": "http","url": "https://mcp.context7.com/mcp","headers": {- "CONTEXT7_API_KEY": "YOUR_API_KEY"+ "Authorization": "Bearer YOUR_API_KEY"},"tools": ["query-docs", "resolve-library-id"]}@@ -728,7 +728,7 @@ command = "npx"```toml[mcp_servers.context7]url = "https://mcp.context7.com/mcp"-http_headers = { "CONTEXT7_API_KEY" = "YOUR_API_KEY" }+http_headers = { "Authorization" = "Bearer YOUR_API_KEY" }```</details>diff --git a/i18n/README.it.md b/i18n/README.it.mdindex f716f106..e0a5e9a2 100644--- a/i18n/README.it.md+++ b/i18n/README.it.md@@ -179,7 +179,7 @@ Per maggiori informazioni, consulta la [documentazione ufficiale GitHub](https:/"type": "http","url": "https://mcp.context7.com/mcp","headers": {- "CONTEXT7_API_KEY": "YOUR_API_KEY"+ "Authorization": "Bearer YOUR_API_KEY"},"tools": ["query-docs", "resolve-library-id"]}diff --git a/i18n/README.ja.md b/i18n/README.ja.mdindex 0848965b..b95078cb 100644--- a/i18n/README.ja.md+++ b/i18n/README.ja.md@@ -347,7 +347,7 @@ claude mcp add --scope user --transport http context7 https://mcp.context7.com/m"type": "http","url": "https://mcp.context7.com/mcp","headers": {- "CONTEXT7_API_KEY": "YOUR_API_KEY"+ "Authorization": "Bearer YOUR_API_KEY"},"tools": ["query-docs", "resolve-library-id"]}diff --git a/i18n/README.ko.md b/i18n/README.ko.mdindex 006719ec..9adb9760 100644--- a/i18n/README.ko.md+++ b/i18n/README.ko.md@@ -56,7 +56,7 @@ Cursor의 `~/.cursor/mcp.json` 파일에 다음 설정을 붙여넣는 것이"context7": {"url": "https://mcp.context7.com/mcp","headers": {- "CONTEXT7_API_KEY": "YOUR_API_KEY"+ "Authorization": "Bearer YOUR_API_KEY"}}}@@ -94,7 +94,7 @@ claude mcp add --scope user context7 -- npx -y @upstash/context7-mcp --api-key Y#### Claude Code 원격 서버 연결```sh-claude mcp add --scope user --header "CONTEXT7_API_KEY: YOUR_API_KEY" --transport http context7 https://mcp.context7.com/mcp+claude mcp add --scope user --header "Authorization: Bearer YOUR_API_KEY" --transport http context7 https://mcp.context7.com/mcp```</details>@@ -112,7 +112,7 @@ Opencode 설정 파일에 이것을 추가하세요. 자세한 내용은 [Openco"type": "remote","url": "https://mcp.context7.com/mcp","headers": {- "CONTEXT7_API_KEY": "YOUR_API_KEY"+ "Authorization": "Bearer YOUR_API_KEY"},"enabled": true}diff --git a/i18n/README.pt-BR.md b/i18n/README.pt-BR.mdindex c589582c..5b566684 100644--- a/i18n/README.pt-BR.md+++ b/i18n/README.pt-BR.md@@ -371,7 +371,7 @@ command = "npx"```toml[mcp_servers.context7]url = "https://mcp.context7.com/mcp"-http_headers = { "CONTEXT7_API_KEY" = "YOUR_API_KEY" }+http_headers = { "Authorization" = "Bearer YOUR_API_KEY" }```</details>@@ -626,7 +626,7 @@ Para mais informações, veja a [documentação oficial do GitHub](https://docs."type": "http","url": "https://mcp.context7.com/mcp","headers": {- "CONTEXT7_API_KEY": "YOUR_API_KEY"+ "Authorization": "Bearer YOUR_API_KEY"},"tools": ["query-docs", "resolve-library-id"]}diff --git a/i18n/README.ru.md b/i18n/README.ru.mdindex d879f4e9..df7ddc1e 100644--- a/i18n/README.ru.md+++ b/i18n/README.ru.md@@ -191,7 +191,7 @@ claude mcp add --scope user context7 -- npx -y @upstash/context7-mcp"type": "http","url": "https://mcp.context7.com/mcp","headers": {- "CONTEXT7_API_KEY": "YOUR_API_KEY"+ "Authorization": "Bearer YOUR_API_KEY"},"tools": ["query-docs", "resolve-library-id"]}diff --git a/i18n/README.uk.md b/i18n/README.uk.mdindex 38b266a5..829783dc 100644--- a/i18n/README.uk.md+++ b/i18n/README.uk.md@@ -284,7 +284,7 @@ npx -y @smithery/cli@latest install @upstash/context7-mcp --client <CLIENT_NAME>"type": "http","url": "https://mcp.context7.com/mcp","headers": {- "CONTEXT7_API_KEY": "YOUR_API_KEY"+ "Authorization": "Bearer YOUR_API_KEY"},"tools": ["query-docs", "resolve-library-id"]}@@ -306,7 +306,7 @@ npx -y @smithery/cli@latest install @upstash/context7-mcp --client <CLIENT_NAME>"type": "http","url": "https://mcp.context7.com/mcp","headers": {- "CONTEXT7_API_KEY": "YOUR_API_KEY"+ "Authorization": "Bearer YOUR_API_KEY"},"tools": ["query-docs", "resolve-library-id"]}diff --git a/i18n/README.vi.md b/i18n/README.vi.mdindex 83013a06..ce92c12e 100644--- a/i18n/README.vi.md+++ b/i18n/README.vi.md@@ -654,7 +654,7 @@ Thêm cấu hình sau vào phần `mcp` trong file cấu hình Copilot Coding Ag"type": "http","url": "https://mcp.context7.com/mcp","headers": {- "CONTEXT7_API_KEY": "YOUR_API_KEY"+ "Authorization": "Bearer YOUR_API_KEY"},"tools": ["query-docs", "resolve-library-id"]}@@ -719,7 +719,7 @@ command = "npx"```toml[mcp_servers.context7]url = "https://mcp.context7.com/mcp"-http_headers = { "CONTEXT7_API_KEY" = "YOUR_API_KEY" }+http_headers = { "Authorization" = "Bearer YOUR_API_KEY" }```</details>diff --git a/i18n/README.zh-TW.md b/i18n/README.zh-TW.mdindex dd20fec5..d078604b 100644--- a/i18n/README.zh-TW.md+++ b/i18n/README.zh-TW.md@@ -58,7 +58,7 @@ Context7 將最新的程式碼範例與文件直接取得到你的 LLM 上下文"context7": {"url": "https://mcp.context7.com/mcp","headers": {- "CONTEXT7_API_KEY": "YOUR_API_KEY"+ "Authorization": "Bearer YOUR_API_KEY"}}}@@ -96,7 +96,7 @@ claude mcp add --scope user context7 -- npx -y @upstash/context7-mcp --api-key Y#### Claude Code 遠端伺服器連線```sh-claude mcp add --scope user --header "CONTEXT7_API_KEY: YOUR_API_KEY" --transport http context7 https://mcp.context7.com/mcp+claude mcp add --scope user --header "Authorization: Bearer YOUR_API_KEY" --transport http context7 https://mcp.context7.com/mcp```</details>@@ -114,7 +114,7 @@ claude mcp add --scope user --header "CONTEXT7_API_KEY: YOUR_API_KEY" --transpor"type": "remote","url": "https://mcp.context7.com/mcp","headers": {- "CONTEXT7_API_KEY": "YOUR_API_KEY"+ "Authorization": "Bearer YOUR_API_KEY"},"enabled": true}diff --git a/packages/cli/src/__tests__/plugin-manifests.test.ts b/packages/cli/src/__tests__/plugin-manifests.test.tsnew file mode 100644index 00000000..60b80fc1--- /dev/null+++ b/packages/cli/src/__tests__/plugin-manifests.test.ts@@ -0,0 +1,24 @@+import { describe, test, expect } from "vitest";+import { readFile } from "fs/promises";+import { join } from "path";++const REPO_ROOT = join(import.meta.dirname, "..", "..", "..", "..");++describe("plugin MCP manifests", () => {+ // Deliberately the raw key, not `Bearer <key>` as the CLI writes. Both plugins+ // document that an unset key still works over the anonymous tier, and this is+ // the only form that survives both states: the server rejects `Bearer` with an+ // empty token but treats an empty Authorization as anonymous.+ test.each(["plugins/claude/context7/.mcp.json", "plugins/copilot/context7/.mcp.json"])(+ "%s passes the raw key via Authorization",+ async (relPath) => {+ const raw = await readFile(join(REPO_ROOT, relPath), "utf-8");+ const config = JSON.parse(raw) as {+ mcpServers: { context7: { headers: Record<string, string> } };+ };+ expect(config.mcpServers.context7.headers).toEqual({+ Authorization: "${CONTEXT7_API_KEY:-}",+ });+ }+ );+});diff --git a/packages/cli/src/__tests__/setup.test.ts b/packages/cli/src/__tests__/setup.test.tsindex dd77ea11..2889cf5e 100644--- a/packages/cli/src/__tests__/setup.test.ts+++ b/packages/cli/src/__tests__/setup.test.ts@@ -632,7 +632,7 @@ describe("agent config integration", () => {expect(entry).toEqual({type: "http",url: "https://mcp.context7.com/mcp",- headers: { CONTEXT7_API_KEY: "sk-test-123" },+ headers: { Authorization: "Bearer sk-test-123" },});});@@ -681,7 +681,7 @@ describe("agent config integration", () => {expect(servers.context7).toEqual({type: "http",url: "https://mcp.context7.com/mcp",- headers: { CONTEXT7_API_KEY: "sk-test-123" },+ headers: { Authorization: "Bearer sk-test-123" },});});@@ -705,7 +705,7 @@ describe("agent config integration", () => {expect((result.mcpServers as Record<string, unknown>).context7).toEqual({type: "http",url: "https://mcp.context7.com/mcp",- headers: { CONTEXT7_API_KEY: "sk-test-123" },+ headers: { Authorization: "Bearer sk-test-123" },});});});@@ -717,7 +717,7 @@ describe("agent config integration", () => {const entry = agent.mcp.buildEntry(apiKeyAuth, "http");expect(entry).toEqual({url: "https://mcp.context7.com/mcp",- headers: { CONTEXT7_API_KEY: "sk-test-123" },+ headers: { Authorization: "Bearer sk-test-123" },});expect(entry).not.toHaveProperty("type");});@@ -766,7 +766,7 @@ describe("agent config integration", () => {const servers = result.mcpServers as Record<string, unknown>;expect(servers.context7).toEqual({url: "https://mcp.context7.com/mcp",- headers: { CONTEXT7_API_KEY: "sk-test-123" },+ headers: { Authorization: "Bearer sk-test-123" },});expect(servers.other).toEqual({ url: "https://other.com" });});@@ -781,7 +781,7 @@ describe("agent config integration", () => {type: "remote",url: "https://mcp.context7.com/mcp",enabled: true,- headers: { CONTEXT7_API_KEY: "sk-test-123" },+ headers: { Authorization: "Bearer sk-test-123" },});});@@ -817,7 +817,7 @@ describe("agent config integration", () => {type: "remote",url: "https://mcp.context7.com/mcp",enabled: true,- headers: { CONTEXT7_API_KEY: "sk-test-123" },+ headers: { Authorization: "Bearer sk-test-123" },});});@@ -875,12 +875,12 @@ describe("agent config integration", () => {describe("codex", () => {const agent = getAgent("codex");- test("buildEntry with api-key produces correct shape", () => {+ test("buildEntry with api-key uses an Authorization header", () => {const entry = agent.mcp.buildEntry(apiKeyAuth, "http");expect(entry).toEqual({type: "http",url: "https://mcp.context7.com/mcp",- headers: { CONTEXT7_API_KEY: "sk-test-123" },+ headers: { Authorization: "Bearer sk-test-123" },});});@@ -906,7 +906,7 @@ describe("agent config integration", () => {expect(content).toContain('type = "http"');expect(content).toContain('url = "https://mcp.context7.com/mcp"');expect(content).toContain("[mcp_servers.context7.http_headers]");- expect(content).toContain('CONTEXT7_API_KEY = "sk-test-123"');+ expect(content).toContain('Authorization = "Bearer sk-test-123"');});test("appends oauth entry to TOML without headers", async () => {@@ -933,7 +933,7 @@ describe("agent config integration", () => {expect(content.match(/\[mcp_servers\.context7\]/g)?.length).toBe(1);expect(content).toContain('url = "https://mcp.context7.com/mcp"');expect(content).not.toContain("mcp/oauth");- expect(content).toContain('CONTEXT7_API_KEY = "sk-test-123"');+ expect(content).toContain('Authorization = "Bearer sk-test-123"');});test("overwrites TOML config preserving other servers", async () => {@@ -959,7 +959,7 @@ describe("agent config integration", () => {const entry = agent.mcp.buildEntry(apiKeyAuth, "http");expect(entry).toEqual({httpUrl: "https://mcp.context7.com/mcp",- headers: { CONTEXT7_API_KEY: "sk-test-123" },+ headers: { Authorization: "Bearer sk-test-123" },});expect(entry).not.toHaveProperty("url");});@@ -992,7 +992,7 @@ describe("agent config integration", () => {expect(result.theme).toBe("dark");expect((result.mcpServers as Record<string, unknown>).context7).toEqual({httpUrl: "https://mcp.context7.com/mcp",- headers: { CONTEXT7_API_KEY: "sk-test-123" },+ headers: { Authorization: "Bearer sk-test-123" },});});@@ -1015,7 +1015,7 @@ describe("agent config integration", () => {const result = await readJsonConfig(path);expect((result.mcpServers as Record<string, unknown>).context7).toEqual({httpUrl: "https://mcp.context7.com/mcp",- headers: { CONTEXT7_API_KEY: "sk-test-123" },+ headers: { Authorization: "Bearer sk-test-123" },});});});@@ -1047,7 +1047,7 @@ describe("agent config integration", () => {const apiEntry = agent.mcp.buildEntry(apiKeyAuth, "http");const oauthEntry = agent.mcp.buildEntry(oauthAuth, "http");- expect(apiEntry.headers).toEqual({ CONTEXT7_API_KEY: "sk-test-123" });+ expect(apiEntry.headers).toEqual({ Authorization: "Bearer sk-test-123" });expect(oauthEntry).not.toHaveProperty("headers");});diff --git a/packages/cli/src/setup/agents.ts b/packages/cli/src/setup/agents.tsindex e5cd1bc5..2a33a493 100644--- a/packages/cli/src/setup/agents.ts+++ b/packages/cli/src/setup/agents.ts@@ -83,9 +83,24 @@ function mcpUrl(auth: AuthOptions): string {return auth.mode === "oauth" ? `${MCP_BASE_URL}/mcp/oauth` : `${MCP_BASE_URL}/mcp`;}+/**+ * Attaches the API key as a standard `Authorization: Bearer` header.+ *+ * The name must stay `Authorization`. Codex resolves a server's auth mode from+ * `bearer_token_env_var` or a header literally named `Authorization`+ * (`auth_status_before_discovery` in codex-rs/rmcp-client/src/auth_status.rs);+ * any other name reads as "no credential configured", so it falls through to an+ * OAuth credential stored against the same server name and URL and refreshes it+ * at startup. A dead refresh token then fails the server before the key is ever+ * sent. The server accepts the legacy `CONTEXT7_API_KEY` header too, so existing+ * configs keep working.+ *+ * Guarded on a non-empty key because the server rejects an empty bearer, while+ * omitting the header falls back to anonymous access.+ */function withHeaders(base: Record<string, unknown>, auth: AuthOptions): Record<string, unknown> {if (auth.mode === "api-key" && auth.apiKey) {- return { ...base, headers: { CONTEXT7_API_KEY: auth.apiKey } };+ return { ...base, headers: { Authorization: `Bearer ${auth.apiKey}` } };}return base;}diff --git a/packages/mcp/README.md b/packages/mcp/README.mdindex cfd766c4..ec0c6cae 100644--- a/packages/mcp/README.md+++ b/packages/mcp/README.md@@ -107,7 +107,7 @@ Pasting the following configuration into your Cursor `~/.cursor/mcp.json` file i"context7": {"url": "https://mcp.context7.com/mcp","headers": {- "CONTEXT7_API_KEY": "YOUR_API_KEY"+ "Authorization": "Bearer YOUR_API_KEY"}}}@@ -145,7 +145,7 @@ claude mcp add --scope user context7 -- npx -y @upstash/context7-mcp --api-key Y#### Claude Code Remote Server Connection```sh-claude mcp add --scope user --header "CONTEXT7_API_KEY: YOUR_API_KEY" --transport http context7 https://mcp.context7.com/mcp+claude mcp add --scope user --header "Authorization: Bearer YOUR_API_KEY" --transport http context7 https://mcp.context7.com/mcp```> Remove `--scope user` to install for the current project only.@@ -166,7 +166,7 @@ amp mcp add context7 https://mcp.context7.com/mcp#### With API Key (Higher Rate Limits & Private Repos)```sh-amp mcp add context7 --header "CONTEXT7_API_KEY=YOUR_API_KEY" https://mcp.context7.com/mcp+amp mcp add context7 --header "Authorization=Bearer YOUR_API_KEY" https://mcp.context7.com/mcp```</details>@@ -184,7 +184,7 @@ Add this to your Devin Desktop MCP config file. See [Devin Desktop MCP docs](htt"context7": {"serverUrl": "https://mcp.context7.com/mcp","headers": {- "CONTEXT7_API_KEY": "YOUR_API_KEY"+ "Authorization": "Bearer YOUR_API_KEY"}}}@@ -223,7 +223,7 @@ Add this to your VS Code MCP config file. See [VS Code MCP docs](https://code.vi"type": "http","url": "https://mcp.context7.com/mcp","headers": {- "CONTEXT7_API_KEY": "YOUR_API_KEY"+ "Authorization": "Bearer YOUR_API_KEY"}}}@@ -432,7 +432,7 @@ Add this to your Antigravity MCP config file. See [Antigravity MCP docs](https:/"context7": {"serverUrl": "https://mcp.context7.com/mcp","headers": {- "CONTEXT7_API_KEY": "YOUR_API_KEY"+ "Authorization": "Bearer YOUR_API_KEY"}}}@@ -468,7 +468,7 @@ Add this to your Roo Code MCP configuration file. See [Roo Code MCP docs](https:"type": "streamable-http","url": "https://mcp.context7.com/mcp","headers": {- "CONTEXT7_API_KEY": "YOUR_API_KEY"+ "Authorization": "Bearer YOUR_API_KEY"}}}@@ -504,7 +504,7 @@ See [Gemini CLI Configuration](https://google-gemini.github.io/gemini-cli/docs/t"context7": {"httpUrl": "https://mcp.context7.com/mcp","headers": {- "CONTEXT7_API_KEY": "YOUR_API_KEY",+ "Authorization": "Bearer YOUR_API_KEY","Accept": "application/json, text/event-stream"}}@@ -543,7 +543,7 @@ See [Qwen Coder MCP Configuration](https://qwenlm.github.io/qwen-code-docs/en/to"context7": {"httpUrl": "https://mcp.context7.com/mcp","headers": {- "CONTEXT7_API_KEY": "YOUR_API_KEY",+ "Authorization": "Bearer YOUR_API_KEY","Accept": "application/json, text/event-stream"}}@@ -605,7 +605,7 @@ Add this to your Opencode configuration file. See [Opencode MCP docs](https://op"type": "remote","url": "https://mcp.context7.com/mcp","headers": {- "CONTEXT7_API_KEY": "YOUR_API_KEY"+ "Authorization": "Bearer YOUR_API_KEY"},"enabled": true}@@ -649,7 +649,7 @@ startup_timeout_ms = 20_000```toml[mcp_servers.context7]url = "https://mcp.context7.com/mcp"-http_headers = { "CONTEXT7_API_KEY" = "YOUR_API_KEY" }+http_headers = { "Authorization" = "Bearer YOUR_API_KEY" }```> Optional troubleshooting — only if you see startup "request timed out" or "not found program". Most users can ignore this.@@ -742,7 +742,7 @@ To use an API key in Kiro, add:```json"headers": {- "CONTEXT7_API_KEY": "YOUR_API_KEY"+ "Authorization": "Bearer YOUR_API_KEY"}```@@ -1015,7 +1015,7 @@ Add the following configuration to the `mcp` section of your Copilot Coding Agen"type": "http","url": "https://mcp.context7.com/mcp","headers": {- "CONTEXT7_API_KEY": "YOUR_API_KEY"+ "Authorization": "Bearer YOUR_API_KEY"},"tools": ["get-library-docs", "resolve-library-id"]}@@ -1040,7 +1040,7 @@ For more information, see the [official GitHub documentation](https://docs.githu"type": "http","url": "https://mcp.context7.com/mcp","headers": {- "CONTEXT7_API_KEY": "YOUR_API_KEY"+ "Authorization": "Bearer YOUR_API_KEY"},"tools": ["get-library-docs", "resolve-library-id"]}@@ -1112,7 +1112,7 @@ Add this to your Visual Studio MCP config file (see the [Visual Studio docs](htt"type": "http","url": "https://mcp.context7.com/mcp","headers": {- "CONTEXT7_API_KEY": "YOUR_API_KEY"+ "Authorization": "Bearer YOUR_API_KEY"}}}@@ -1154,7 +1154,7 @@ Add this to your Crush configuration file. See [Crush MCP docs](https://github.c"type": "http","url": "https://mcp.context7.com/mcp","headers": {- "CONTEXT7_API_KEY": "YOUR_API_KEY"+ "Authorization": "Bearer YOUR_API_KEY"}}}@@ -1327,7 +1327,7 @@ Factory's droid supports MCP servers through its CLI. See [Factory MCP docs](httRun this command in your terminal:```sh-droid mcp add context7 https://mcp.context7.com/mcp --type http --header "CONTEXT7_API_KEY: YOUR_API_KEY"+droid mcp add context7 https://mcp.context7.com/mcp --type http --header "Authorization: Bearer YOUR_API_KEY"```Or without an API key (basic usage with rate limits):diff --git a/plugins/claude/context7/.mcp.json b/plugins/claude/context7/.mcp.jsonindex 38df3178..7fda704c 100644--- a/plugins/claude/context7/.mcp.json+++ b/plugins/claude/context7/.mcp.json@@ -4,7 +4,7 @@"type": "http","url": "https://mcp.context7.com/mcp","headers": {- "CONTEXT7_API_KEY": "${CONTEXT7_API_KEY:-}"+ "Authorization": "${CONTEXT7_API_KEY:-}"}}}diff --git a/plugins/copilot/context7/.mcp.json b/plugins/copilot/context7/.mcp.jsonindex 38df3178..7fda704c 100644--- a/plugins/copilot/context7/.mcp.json+++ b/plugins/copilot/context7/.mcp.json@@ -4,7 +4,7 @@"type": "http","url": "https://mcp.context7.com/mcp","headers": {- "CONTEXT7_API_KEY": "${CONTEXT7_API_KEY:-}"+ "Authorization": "${CONTEXT7_API_KEY:-}"}}}diff --git a/server.json b/server.jsonindex 6b471c56..75b79240 100644--- a/server.json+++ b/server.json@@ -56,8 +56,8 @@"url": "https://mcp.context7.com/mcp","headers": [{- "name": "CONTEXT7_API_KEY",- "description": "API key for authentication",+ "name": "Authorization",+ "description": "API key for authentication. Accepts \"Bearer <key>\" or the raw key.","isRequired": false,"isSecret": true}