Context7 Platform -- Up-to-date docs for AI agents
CTX7-2965: Remove low-value tests (#3256)
Enes Gules83e972e8b0fa
diff --git a/packages/cli/src/__tests__/auth-commands.test.ts b/packages/cli/src/__tests__/auth-commands.test.tsindex dddcd162..bd1a57fc 100644--- a/packages/cli/src/__tests__/auth-commands.test.ts+++ b/packages/cli/src/__tests__/auth-commands.test.ts@@ -84,11 +84,6 @@ describe("login command", () => {mockGetValidAccessToken.mockResolvedValue("existing-token");await runCommand("login");expect(logOutput.some((l) => l.includes("already logged in"))).toBe(true);- });-- test("tracks login event", async () => {- mockGetValidAccessToken.mockResolvedValue("existing-token");- await runCommand("login");expect(trackEvent).toHaveBeenCalledWith("command", { name: "login" });});@@ -113,11 +108,6 @@ describe("logout command", () => {mockClearTokens.mockReturnValue(false);await runCommand("logout");expect(logOutput.some((l) => l.includes("You are not logged in"))).toBe(true);- });-- test("tracks logout event", async () => {- mockClearTokens.mockReturnValue(false);- await runCommand("logout");expect(trackEvent).toHaveBeenCalledWith("command", { name: "logout" });});});@@ -127,6 +117,7 @@ describe("whoami command", () => {mockGetValidAccessToken.mockResolvedValue(undefined);await runCommand("whoami");expect(logOutput.some((l) => l.includes("Not logged in"))).toBe(true);+ expect(trackEvent).toHaveBeenCalledWith("command", { name: "whoami" });});test("fetches and displays user info when logged in", async () => {@@ -208,12 +199,6 @@ describe("whoami command", () => {expect(logOutput.join("\n")).toContain("Could not verify your session");expect(logOutput.join("\n")).not.toMatch(/ctx7 logout|ctx7 login/);});-- test("tracks whoami event", async () => {- mockGetValidAccessToken.mockResolvedValue(undefined);- await runCommand("whoami");- expect(trackEvent).toHaveBeenCalledWith("command", { name: "whoami" });- });});describe("performLogin", () => {diff --git a/packages/cli/src/__tests__/auth-utils.test.ts b/packages/cli/src/__tests__/auth-utils.test.tsindex bf92cdb2..cbb0fd99 100644--- a/packages/cli/src/__tests__/auth-utils.test.ts+++ b/packages/cli/src/__tests__/auth-utils.test.ts@@ -22,7 +22,6 @@ import {loadTokens,clearTokens,isTokenExpired,- isContext7ApiKey,getValidAccessToken,startDeviceAuthorization,pollDeviceToken,@@ -190,22 +189,6 @@ describe("isTokenExpired", () => {expect(isTokenExpired({ access_token: "tok", token_type: "bearer" })).toBe(false);});- test("returns false when well before expiry", () => {- expect(- isTokenExpired({- access_token: "tok",- token_type: "bearer",- expires_at: Date.now() + 120_000,- })- ).toBe(false);- });-- test("returns true when past expiry", () => {- expect(- isTokenExpired({ access_token: "tok", token_type: "bearer", expires_at: Date.now() - 1000 })- ).toBe(true);- });-test("returns true within 60s buffer window", () => {expect(isTokenExpired({ access_token: "tok", token_type: "bearer", expires_at: Date.now() + 30_000 })@@ -221,16 +204,6 @@ describe("isTokenExpired", () => {});});-describe("isContext7ApiKey", () => {- test("recognizes Context7 API keys", () => {- expect(isContext7ApiKey("ctx7sk-example")).toBe(true);- });-- test("rejects OAuth access tokens", () => {- expect(isContext7ApiKey("legacy-oauth-token")).toBe(false);- });-});-describe("getValidAccessToken", () => {test("returns undefined when no tokens stored", async () => {mfs.existsSync.mockReturnValue(false);diff --git a/packages/cli/src/__tests__/setup-on-prem.test.ts b/packages/cli/src/__tests__/setup-on-prem.test.tsindex 36eaa638..6d249aac 100644--- a/packages/cli/src/__tests__/setup-on-prem.test.ts+++ b/packages/cli/src/__tests__/setup-on-prem.test.ts@@ -1,5 +1,5 @@import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";-import { mkdir, readFile, rm } from "fs/promises";+import { mkdir, readFile, rm, writeFile } from "fs/promises";import { tmpdir } from "os";import { join } from "path";import { Command } from "commander";@@ -96,6 +96,40 @@ describe("on-premise setup network boundary", () => {expect(await readFile(join(tempDir, "AGENTS.md"), "utf-8")).toContain("query-docs");});+ test("re-running setup replaces the AGENTS.md section without touching user content", async () => {+ const agentsPath = join(tempDir, "AGENTS.md");+ await writeFile(+ agentsPath,+ "# Before\n\n<!-- context7 -->\nstale rule\n<!-- context7 -->\n\n# After\n",+ "utf-8"+ );++ const runSetup = async () => {+ const program = new Command();+ program.exitOverride();+ registerSetupCommand(program);+ await program.parseAsync([+ "node",+ "ctx7",+ "setup",+ "--mcp",+ "--base-url",+ "https://context7.internal.example",+ "--codex",+ "--project",+ "--yes",+ ]);+ return readFile(agentsPath, "utf-8");+ };++ const first = await runSetup();+ expect(first.startsWith("# Before\n\n<!-- context7 -->\n")).toBe(true);+ expect(first.endsWith("<!-- context7 -->\n\n# After\n")).toBe(true);+ expect(first).not.toContain("stale rule");+ expect(first).toContain("query-docs");+ expect(await runSetup()).toBe(first);+ });+test("selects MCP mode automatically for a custom deployment", async () => {const program = new Command();program.exitOverride();diff --git a/packages/cli/src/__tests__/setup.test.ts b/packages/cli/src/__tests__/setup.test.tsindex 7ef6acb2..a5641981 100644--- a/packages/cli/src/__tests__/setup.test.ts+++ b/packages/cli/src/__tests__/setup.test.ts@@ -19,11 +19,7 @@ vi.stubGlobal(}));-import {- getBundledMcpSkillFiles,- getBundledRuleContent,- getRuleContent,-} from "../setup/templates.js";+import { getRuleContent } from "../setup/templates.js";import {getMcpUrl,getOnPremMcpAuthStatus,@@ -88,15 +84,6 @@ describe("getRuleContent", () => {}));});-- test("provides bundled MCP rule and skill content for offline setup", () => {- expect(getBundledRuleContent("mcp", "claude")).toContain("resolve-library-id");- const files = getBundledMcpSkillFiles();- expect(files).toHaveLength(1);- expect(files[0].path).toBe("SKILL.md");- expect(files[0].content).toContain("name: context7-mcp");- expect(files[0].content).toContain("query-docs");- });});describe("custom Context7 deployments", () => {@@ -125,26 +112,6 @@ describe("custom Context7 deployments", () => {expect(getMcpUrl(custom, { mode: "none" })).toBe("https://context7.internal.example/mcp");});- test("discovers whether an on-premise deployment requires MCP authentication", async () => {- vi.mocked(fetch).mockResolvedValueOnce({- ok: true,- json: () => Promise.resolve({ enabled: true }),- } as Response);-- const deployment = resolveSetupDeployment("https://context7.internal.example/");- expect(deployment.kind).toBe("custom");- if (deployment.kind !== "custom") throw new Error("expected custom deployment");-- await expect(getOnPremMcpAuthStatus(deployment)).resolves.toBe(true);- expect(fetch).toHaveBeenLastCalledWith(- "https://context7.internal.example/api/auth/mcp",- expect.objectContaining({- headers: { Accept: "application/json" },- redirect: "manual",- })- );- });-test("explains that authentication discovery redirects require the final URL", async () => {vi.mocked(fetch).mockResolvedValueOnce({ok: false,@@ -195,17 +162,6 @@ describe("mergeServerEntry", () => {expect(servers.other).toEqual({ url: "https://other.com" });});- test("overwrites existing server and flags alreadyExists", () => {- const existing = { mcpServers: { context7: { url: "https://old.com" } } };- const { config, alreadyExists } = mergeServerEntry(existing, "mcpServers", "context7", {- url: "https://new.com",- });- expect(alreadyExists).toBe(true);- expect((config.mcpServers as Record<string, unknown>).context7).toEqual({- url: "https://new.com",- });- });-test("overwrites existing server entry with new url", () => {const existing = {mcpServers: {@@ -240,40 +196,9 @@ describe("mergeServerEntry", () => {url: "https://mcp.context7.com/mcp",});});-- test("works with opencode configKey 'mcp'", () => {- const { config } = mergeServerEntry({}, "mcp", "context7", {- type: "remote",- url: "https://mcp.context7.com/mcp",- });- expect((config.mcp as Record<string, unknown>).context7).toEqual({- type: "remote",- url: "https://mcp.context7.com/mcp",- });- });});describe("removeServerEntry", () => {- test("removes server from config section", () => {- const { config, removed } = removeServerEntry(- {- mcpServers: {- context7: { url: "https://mcp.context7.com/mcp" },- other: { url: "https://other.com" },- },- },- "mcpServers",- "context7"- );-- expect(removed).toBe(true);- expect(config).toEqual({- mcpServers: {- other: { url: "https://other.com" },- },- });- });-test("removes empty config section when context7 is the only server", () => {const { config, removed } = removeServerEntry({@@ -297,32 +222,6 @@ describe("removeServerEntry", () => {expect(removed).toBe(false);expect(config).toEqual(existing);});-- test("preserves unrelated top-level fields and sibling MCP servers", () => {- const existing = {- version: 2,- theme: "dark",- mcpServers: {- alpha: { url: "https://alpha.com" },- context7: { url: "https://mcp.context7.com/mcp", headers: { key: "secret" } },- omega: { url: "https://omega.com" },- },- telemetry: { enabled: true },- };-- const { config, removed } = removeServerEntry(existing, "mcpServers", "context7");-- expect(removed).toBe(true);- expect(config).toEqual({- version: 2,- theme: "dark",- mcpServers: {- alpha: { url: "https://alpha.com" },- omega: { url: "https://omega.com" },- },- telemetry: { enabled: true },- });- });});describe("readJsonConfig / writeJsonConfig", () => {@@ -404,12 +303,6 @@ describe("JSONC support", () => {const resolved = await resolveMcpPath([jsonPath]);expect(resolved).toBe(jsonPath);});-- test("resolveMcpPath returns single candidate unchanged", async () => {- const tomlPath = join(tempDir, "config.toml");- const resolved = await resolveMcpPath([tomlPath]);- expect(resolved).toBe(tomlPath);- });});describe("TOML config", () => {@@ -424,14 +317,6 @@ describe("TOML config", () => {await rm(tempDir, { recursive: true, force: true });});- test("buildTomlServerBlock generates correct TOML", () => {- const block = buildTomlServerBlock("context7", {- url: "https://mcp.context7.com/mcp",- });- expect(block).toContain("[mcp_servers.context7]");- expect(block).toContain('url = "https://mcp.context7.com/mcp"');- });-test("buildTomlServerBlock includes http_headers", () => {const block = buildTomlServerBlock("context7", {url: "https://mcp.context7.com/mcp",@@ -475,17 +360,6 @@ describe("TOML config", () => {expect(content).toContain("[mcp_servers.context7]");});- test("appendTomlServer is idempotent", async () => {- const path = join(tempDir, "config.toml");- await appendTomlServer(path, "context7", { url: "https://mcp.context7.com/mcp" });- const { alreadyExists } = await appendTomlServer(path, "context7", {- url: "https://mcp.context7.com/mcp",- });- expect(alreadyExists).toBe(true);- const content = await readFile(path, "utf-8");- expect(content.match(/\[mcp_servers\.context7\]/g)?.length).toBe(1);- });-test("appendTomlServer overwrites existing server with new url", async () => {const path = join(tempDir, "config.toml");await appendTomlServer(path, "context7", { url: "https://old.com" });@@ -583,24 +457,6 @@ describe("TOML config", () => {expect(content).not.toContain("[mcp_servers.context7]");});- test("removeTomlServer removes nested subsections too", async () => {- const path = join(tempDir, "config.toml");- await writeFile(- path,- '[mcp_servers.context7]\nurl = "https://mcp.context7.com/mcp"\n\n[mcp_servers.context7.http_headers]\nCONTEXT7_API_KEY = "sk-test"\n\n[settings]\nmodel = "gpt-5"\n',- "utf-8"- );-- const { removed } = await removeTomlServer(path, "context7");- expect(removed).toBe(true);-- const content = await readFile(path, "utf-8");- expect(content).toContain("[settings]");- expect(content).toContain('model = "gpt-5"');- expect(content).not.toContain("[mcp_servers.context7]");- expect(content).not.toContain("CONTEXT7_API_KEY");- });-test("removeTomlServer preserves other MCP servers and their subsections", async () => {const path = join(tempDir, "config.toml");await writeFile(@@ -631,81 +487,6 @@ describe("TOML config", () => {});});-describe("AGENTS.md append", () => {- let tempDir: string;-- beforeEach(async () => {- tempDir = join(tmpdir(), `ctx7-test-${Date.now()}`);- await mkdir(tempDir, { recursive: true });- });-- afterEach(async () => {- await rm(tempDir, { recursive: true, force: true });- });-- const marker = "<!-- context7 -->";- const ruleContent = "Use ctx7 CLI for docs.\n";-- async function appendRule(filePath: string, existing?: string): Promise<string> {- if (existing !== undefined) {- await writeFile(filePath, existing, "utf-8");- }-- const escapedMarker = marker.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");- const section = `${marker}\n${ruleContent}${marker}`;-- let content = "";- try {- content = await readFile(filePath, "utf-8");- } catch {}-- if (content.includes(marker)) {- const regex = new RegExp(`${escapedMarker}\\n[\\s\\S]*?${escapedMarker}`);- await writeFile(filePath, content.replace(regex, section), "utf-8");- } else {- const separator =- content.length > 0 && !content.endsWith("\n") ? "\n\n" : content.length > 0 ? "\n" : "";- await mkdir(join(filePath, ".."), { recursive: true });- await writeFile(filePath, content + separator + section + "\n", "utf-8");- }-- return readFile(filePath, "utf-8");- }-- test("creates new file cleanly", async () => {- const result = await appendRule(join(tempDir, "AGENTS.md"));- expect(result).toBe(`${marker}\n${ruleContent}${marker}\n`);- expect(result[0]).not.toBe("\n");- });-- test("appends to existing content with proper spacing", async () => {- const withNewline = await appendRule(join(tempDir, "a.md"), "# Rules\n");- expect(withNewline).toContain("# Rules\n\n<!-- context7 -->");-- const withoutNewline = await appendRule(join(tempDir, "b.md"), "No trailing newline");- expect(withoutNewline).toContain("No trailing newline\n\n<!-- context7 -->");- });-- test("is idempotent on re-run", async () => {- const filePath = join(tempDir, "AGENTS.md");- const first = await appendRule(filePath);- const second = await appendRule(filePath);- expect(second).toBe(first);- expect(second.match(/<!-- context7 -->/g)?.length).toBe(2);- });-- test("replaces section without affecting surrounding content", async () => {- const filePath = join(tempDir, "AGENTS.md");- await writeFile(filePath, `# Before\n\n${marker}\nold content\n${marker}\n\n# After\n`);-- const result = await appendRule(filePath);- expect(result).toContain("# Before");- expect(result).toContain("# After");- expect(result).not.toContain("old content");- expect(result).toContain(ruleContent);- });-});-describe("agent config integration", () => {let tempDir: string;@@ -802,30 +583,6 @@ describe("agent config integration", () => {headers: { Authorization: "Bearer sk-test-123" },});});-- test("overwrites existing config in JSON", async () => {- const path = join(tempDir, ".claude.json");- await writeJsonConfig(path, {- mcpServers: { context7: { type: "http", url: "https://old.com" } },- });-- const existing = await readJsonConfig(path);- const { config, alreadyExists } = mergeServerEntry(- existing,- agent.mcp.configKey,- "context7",- buildEntry(agent, apiKeyAuth, "http")- );- expect(alreadyExists).toBe(true);- await writeJsonConfig(path, config);-- const result = await readJsonConfig(path);- expect((result.mcpServers as Record<string, unknown>).context7).toEqual({- type: "http",- url: "https://mcp.context7.com/mcp",- headers: { Authorization: "Bearer sk-test-123" },- });- });});describe("cursor", () => {@@ -846,48 +603,6 @@ describe("agent config integration", () => {url: "https://mcp.context7.com/mcp/oauth",});});-- test("merges into JSON config with configKey mcpServers", async () => {- const path = join(tempDir, "mcp.json");- const existing = await readJsonConfig(path);- const { config } = mergeServerEntry(- existing,- agent.mcp.configKey,- "context7",- buildEntry(agent, oauthAuth, "http")- );- await writeJsonConfig(path, config);-- const result = await readJsonConfig(path);- expect((result.mcpServers as Record<string, unknown>).context7).toEqual({- url: "https://mcp.context7.com/mcp/oauth",- });- });-- test("overwrites existing config in JSON", async () => {- const path = join(tempDir, "mcp.json");- await writeJsonConfig(path, {- mcpServers: { context7: { url: "https://old.com" }, other: { url: "https://other.com" } },- });-- const existing = await readJsonConfig(path);- const { config, alreadyExists } = mergeServerEntry(- existing,- agent.mcp.configKey,- "context7",- buildEntry(agent, apiKeyAuth, "http")- );- expect(alreadyExists).toBe(true);- await writeJsonConfig(path, config);-- const result = await readJsonConfig(path);- const servers = result.mcpServers as Record<string, unknown>;- expect(servers.context7).toEqual({- url: "https://mcp.context7.com/mcp",- headers: { Authorization: "Bearer sk-test-123" },- });- expect(servers.other).toEqual({ url: "https://other.com" });- });});describe("vscode", () => {@@ -908,10 +623,6 @@ describe("agent config integration", () => {});});- test("uses the VS Code project MCP path", () => {- expect(agent.mcp.projectPaths).toEqual([join(".vscode", "mcp.json")]);- });-test.each([["darwin", "/home/test", {}, "/home/test/Library/Application Support/Code/User"],[@@ -933,30 +644,6 @@ describe("agent config integration", () => {expect(agent.rule.contentPrefix).toBe('---\napplyTo: "**"\n---\n\n');}});-- test("merges into the VS Code servers section", async () => {- const path = join(tempDir, "mcp.json");- await writeJsonConfig(path, { servers: { other: { url: "https://other.com" } } });-- const existing = await readJsonConfig(path);- const { config } = mergeServerEntry(- existing,- agent.mcp.configKey,- "context7",- buildEntry(agent, apiKeyAuth, "http")- );- await writeJsonConfig(path, config);-- const result = await readJsonConfig(path);- expect((result.servers as Record<string, unknown>).context7).toEqual({- type: "http",- url: "https://mcp.context7.com/mcp",- headers: { Authorization: "Bearer sk-test-123" },- });- expect((result.servers as Record<string, unknown>).other).toEqual({- url: "https://other.com",- });- });});describe("devin", () => {@@ -995,32 +682,6 @@ describe("agent config integration", () => {] as const)("resolves the %s Devin config directory", (platform, home, env, expected) => {expect(resolveDevinConfigDir(platform, home, env)).toBe(expected);});-- test("merges into Devin config without replacing other settings", async () => {- const path = join(tempDir, "mcp_config.json");- await writeJsonConfig(path, {- permissions: { allow: ["git status"] },- mcpServers: { other: { command: "other" } },- });-- const existing = await readJsonConfig(path);- const { config } = mergeServerEntry(- existing,- agent.mcp.configKey,- "context7",- buildEntry(agent, apiKeyAuth, "http")- );- await writeJsonConfig(path, config);-- const result = await readJsonConfig(path);- expect(result.permissions).toEqual({ allow: ["git status"] });- expect((result.mcpServers as Record<string, unknown>).context7).toEqual({- transport: "http",- url: "https://mcp.context7.com/mcp",- headers: { Authorization: "Bearer sk-test-123" },- });- expect((result.mcpServers as Record<string, unknown>).other).toEqual({ command: "other" });- });});describe("copilot", () => {@@ -1035,10 +696,6 @@ describe("agent config integration", () => {});});- test("uses the Copilot CLI mcpServers config section", () => {- expect(agent.mcp.configKey).toBe("mcpServers");- });-test("does not claim Claude's shared project .mcp.json during auto-detection", async () => {const previousCwd = process.cwd();await writeFile(join(tempDir, ".mcp.json"), JSON.stringify({ mcpServers: {} }));@@ -1051,32 +708,6 @@ describe("agent config integration", () => {process.chdir(previousCwd);}});-- test("merges an entry without replacing other Copilot configuration", async () => {- const path = join(tempDir, "mcp-config.json");- await writeJsonConfig(path, {- telemetry: { enabled: false },- mcpServers: { other: { type: "local", command: "other" } },- });-- const existing = await readJsonConfig(path);- const { config } = mergeServerEntry(- existing,- agent.mcp.configKey,- "context7",- buildEntry(agent, apiKeyAuth, "http")- );- await writeJsonConfig(path, config);-- const result = await readJsonConfig(path);- expect(result.telemetry).toEqual({ enabled: false });- expect((result.mcpServers as Record<string, unknown>).context7).toEqual({- type: "http",- url: "https://mcp.context7.com/mcp",- tools: ["*"],- headers: { Authorization: "Bearer sk-test-123" },- });- });});describe("opencode", () => {@@ -1100,83 +731,6 @@ describe("agent config integration", () => {enabled: true,});});-- test("uses configKey 'mcp' instead of 'mcpServers'", () => {- expect(agent.mcp.configKey).toBe("mcp");- });-- test("merges into JSON config with configKey mcp", async () => {- const path = join(tempDir, "opencode.json");- await writeJsonConfig(path, { $schema: "https://opencode.ai/config.json" });-- const existing = await readJsonConfig(path);- const { config } = mergeServerEntry(- existing,- agent.mcp.configKey,- "context7",- buildEntry(agent, apiKeyAuth, "http")- );- await writeJsonConfig(path, config);-- const result = await readJsonConfig(path);- expect(result.$schema).toBe("https://opencode.ai/config.json");- expect((result.mcp as Record<string, unknown>).context7).toEqual({- type: "remote",- url: "https://mcp.context7.com/mcp",- enabled: true,- headers: { Authorization: "Bearer sk-test-123" },- });- });-- test("overwrites existing config in JSON", async () => {- const path = join(tempDir, "opencode.json");- await writeJsonConfig(path, {- mcp: { context7: { type: "remote", url: "https://old.com", enabled: true } },- });-- const existing = await readJsonConfig(path);- const { config, alreadyExists } = mergeServerEntry(- existing,- agent.mcp.configKey,- "context7",- buildEntry(agent, oauthAuth, "http")- );- expect(alreadyExists).toBe(true);- await writeJsonConfig(path, config);-- const result = await readJsonConfig(path);- expect((result.mcp as Record<string, unknown>).context7).toEqual({- type: "remote",- url: "https://mcp.context7.com/mcp/oauth",- enabled: true,- });- });-- test("works with JSONC files containing comments", async () => {- const path = join(tempDir, "opencode.jsonc");- await writeFile(- path,- `{- // OpenCode config- "$schema": "https://opencode.ai/config.json",- "mcp": {}-}`,- "utf-8"- );-- const existing = await readJsonConfig(path);- const { config } = mergeServerEntry(- existing,- agent.mcp.configKey,- "context7",- buildEntry(agent, apiKeyAuth, "http")- );- await writeJsonConfig(path, config);-- const result = await readJsonConfig(path);- expect(result.$schema).toBe("https://opencode.ai/config.json");- expect((result.mcp as Record<string, unknown>).context7).toBeTruthy();- });});describe("codex", () => {@@ -1215,48 +769,6 @@ describe("agent config integration", () => {expect(content).toContain("[mcp_servers.context7.http_headers]");expect(content).toContain('Authorization = "Bearer sk-test-123"');});-- test("appends oauth entry to TOML without headers", async () => {- const path = join(tempDir, "config.toml");- await appendTomlServer(path, "context7", buildEntry(agent, oauthAuth, "http"));-- const content = await readFile(path, "utf-8");- expect(content).toContain("[mcp_servers.context7]");- expect(content).toContain('url = "https://mcp.context7.com/mcp/oauth"');- expect(content).not.toContain("http_headers");- });-- test("overwrites existing TOML config", async () => {- const path = join(tempDir, "config.toml");- await appendTomlServer(path, "context7", buildEntry(agent, oauthAuth, "http"));- const { alreadyExists } = await appendTomlServer(- path,- "context7",- buildEntry(agent, apiKeyAuth, "http")- );-- expect(alreadyExists).toBe(true);- const content = await readFile(path, "utf-8");- 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('Authorization = "Bearer sk-test-123"');- });-- test("overwrites TOML config preserving other servers", async () => {- const path = join(tempDir, "config.toml");- await writeFile(- path,- '[mcp_servers.other]\nurl = "https://other.com"\n\n[mcp_servers.context7]\ntype = "http"\nurl = "https://old.com"\n'- );- await appendTomlServer(path, "context7", buildEntry(agent, apiKeyAuth, "http"));-- const content = await readFile(path, "utf-8");- expect(content).toContain("[mcp_servers.other]");- expect(content).toContain('url = "https://other.com"');- expect(content).toContain('url = "https://mcp.context7.com/mcp"');- expect(content).not.toContain("https://old.com");- });});describe("gemini", () => {@@ -1278,10 +790,6 @@ describe("agent config integration", () => {});});- test("uses configKey mcpServers", () => {- expect(agent.mcp.configKey).toBe("mcpServers");- });-test("merges into settings.json with mcpServers key", async () => {const path = join(tempDir, "settings.json");await writeJsonConfig(path, { theme: "dark" });@@ -1302,29 +810,6 @@ describe("agent config integration", () => {headers: { Authorization: "Bearer sk-test-123" },});});-- test("overwrites existing config in JSON", async () => {- const path = join(tempDir, "settings.json");- await writeJsonConfig(path, {- mcpServers: { context7: { httpUrl: "https://old.com" } },- });-- const existing = await readJsonConfig(path);- const { config, alreadyExists } = mergeServerEntry(- existing,- agent.mcp.configKey,- "context7",- buildEntry(agent, apiKeyAuth, "http")- );- expect(alreadyExists).toBe(true);- await writeJsonConfig(path, config);-- const result = await readJsonConfig(path);- expect((result.mcpServers as Record<string, unknown>).context7).toEqual({- httpUrl: "https://mcp.context7.com/mcp",- headers: { Authorization: "Bearer sk-test-123" },- });- });});describe("all agents have consistent config", () => {@@ -1337,36 +822,21 @@ describe("agent config integration", () => {expect(apiEntry[urlKey]).toBe("https://mcp.context7.com/mcp");expect(oauthEntry[urlKey]).toBe("https://mcp.context7.com/mcp/oauth");});-- test.each(ALL_AGENT_NAMES)("%s buildEntry includes headers only for api-key auth", (name) => {- const agent = getAgent(name);- const apiEntry = buildEntry(agent, apiKeyAuth, "http");- const oauthEntry = buildEntry(agent, oauthAuth, "http");-- expect(apiEntry.headers).toEqual({ Authorization: "Bearer sk-test-123" });- expect(oauthEntry).not.toHaveProperty("headers");- });});describe("stdio buildEntry", () => {const apiKeyAuth: AuthOptions = { mode: "api-key", apiKey: "sk-test-stdio" };const oauthAuth: AuthOptions = { mode: "oauth" };- test("claude stdio entry uses npx command with --api-key in args", () => {- const entry = buildEntry(getAgent("claude"), apiKeyAuth, "stdio");- expect(entry).toEqual({- command: "npx",- args: ["-y", "@upstash/context7-mcp", "--api-key", "sk-test-stdio"],- });- });-- test("cursor stdio entry uses npx command with --api-key in args", () => {- const entry = buildEntry(getAgent("cursor"), apiKeyAuth, "stdio");- expect(entry).toEqual({- command: "npx",- args: ["-y", "@upstash/context7-mcp", "--api-key", "sk-test-stdio"],- });- });+ test.each(["claude", "cursor", "devin", "codex", "gemini"] as const)(+ "%s stdio entry uses npx command with --api-key in args",+ (name) => {+ expect(buildEntry(getAgent(name), apiKeyAuth, "stdio")).toEqual({+ command: "npx",+ args: ["-y", "@upstash/context7-mcp", "--api-key", "sk-test-stdio"],+ });+ }+ );test("vscode stdio entry includes the stdio transport discriminator", () => {const entry = buildEntry(getAgent("vscode"), apiKeyAuth, "stdio");@@ -1377,14 +847,6 @@ describe("agent config integration", () => {});});- test("devin stdio entry uses npx command with --api-key in args", () => {- const entry = buildEntry(getAgent("devin"), apiKeyAuth, "stdio");- expect(entry).toEqual({- command: "npx",- args: ["-y", "@upstash/context7-mcp", "--api-key", "sk-test-stdio"],- });- });-test("copilot stdio entry includes all tools", () => {const entry = buildEntry(getAgent("copilot"), apiKeyAuth, "stdio");expect(entry).toEqual({@@ -1404,22 +866,6 @@ describe("agent config integration", () => {});});- test("codex stdio entry uses npx command with --api-key in args", () => {- const entry = buildEntry(getAgent("codex"), apiKeyAuth, "stdio");- expect(entry).toEqual({- command: "npx",- args: ["-y", "@upstash/context7-mcp", "--api-key", "sk-test-stdio"],- });- });-- test("gemini stdio entry uses npx command with --api-key in args", () => {- const entry = buildEntry(getAgent("gemini"), apiKeyAuth, "stdio");- expect(entry).toEqual({- command: "npx",- args: ["-y", "@upstash/context7-mcp", "--api-key", "sk-test-stdio"],- });- });-test.each(ALL_AGENT_NAMES)("%s stdio entry omits --api-key for oauth mode", (name) => {const entry = buildEntry(getAgent(name), oauthAuth, "stdio");const args = (entry.args ?? entry.command) as string[];diff --git a/packages/cli/src/__tests__/toml-editor.test.ts b/packages/cli/src/__tests__/toml-editor.test.tsindex 74d729c3..ed8125c8 100644--- a/packages/cli/src/__tests__/toml-editor.test.ts+++ b/packages/cli/src/__tests__/toml-editor.test.ts@@ -265,16 +265,7 @@ const invalidArgs = [{ name: "missing args", value: null },] as const;-const CONFIG_COUNT =- rotations.length +- mutations.length +- preservationVariants.length +- absentTargets.length +- unsafeTargets.length +- invalidArgs.length;-if (CONFIG_COUNT !== 62) throw new Error(`Expected 62 TOML fixtures, received ${CONFIG_COUNT}`);--describe("patchTomlStdioApiKey 62-config compatibility matrix", () => {+describe("patchTomlStdioApiKey compatibility matrix", () => {let tempDir: string;let configPath: string;diff --git a/packages/cli/src/__tests__/update-check.test.ts b/packages/cli/src/__tests__/update-check.test.tsindex 1cedb615..4f18b62b 100644--- a/packages/cli/src/__tests__/update-check.test.ts+++ b/packages/cli/src/__tests__/update-check.test.ts@@ -111,25 +111,6 @@ describe("getUpgradePlan", () => {});describe("checkForUpdates", () => {- test("fetches and caches the latest version", async () => {- vi.stubGlobal(- "fetch",- vi.fn().mockResolvedValue({- ok: true,- json: () => Promise.resolve({ version: "9.9.9" }),- })- );-- const info = await checkForUpdates({- force: true,- stateFile,- now: 123456,- });-- expect(info?.latestVersion).toBe("9.9.9");- expect(info?.updateAvailable).toBe(true);- });-test("uses cached latest version when the cache is fresh", async () => {vi.stubGlobal("fetch",@@ -139,7 +120,8 @@ describe("checkForUpdates", () => {}));- await checkForUpdates({ force: true, stateFile, now: 1000 });+ const fetched = await checkForUpdates({ force: true, stateFile, now: 1000 });+ expect(fetched?.updateAvailable).toBe(true);const fetchMock = vi.mocked(fetch);fetchMock.mockClear();diff --git a/packages/cli/src/__tests__/upgrade-command.test.ts b/packages/cli/src/__tests__/upgrade-command.test.tsindex 62c17cc3..7f7a19f2 100644--- a/packages/cli/src/__tests__/upgrade-command.test.ts+++ b/packages/cli/src/__tests__/upgrade-command.test.ts@@ -191,13 +191,7 @@ describe("upgrade command", () => {expect(plainLogOutput().some((line) => line.includes("permissions"))).toBe(true);});- test("shows permissions guidance when install method is unknown but command is global npm", async () => {- spawn.mockReturnValue({- on: (event: string, handler: (value?: number) => void) => {- if (event === "close") handler(243);- return undefined;- },- });+ test("prints the manual command without running it for unknown installs", async () => {checkForUpdates.mockResolvedValue({currentVersion: "0.3.13",latestVersion: "0.3.99",diff --git a/packages/mcp/test/encryption.test.ts b/packages/mcp/test/encryption.test.tsindex 67888e1d..7531cbe0 100644--- a/packages/mcp/test/encryption.test.ts+++ b/packages/mcp/test/encryption.test.ts@@ -22,13 +22,6 @@ describe("client IP assertions", () => {);});- test("emits only the authenticated assertion header", () => {- const headers = generateHeaders({ clientIp: "203.0.113.99" });-- expect(headers["mcp-client-ip-assertion"]).toMatch(/^v1:/);- expect(headers["mcp-client-ip"]).toBeUndefined();- });-test("fails closed instead of sending plaintext when the key is absent or invalid", () => {delete process.env.MCP_CLIENT_IP_ASSERTION_KEY;expect(diff --git a/packages/sdk/src/client.integration.test.ts b/packages/sdk/src/client.integration.test.tsindex d31656d4..97b7240c 100644--- a/packages/sdk/src/client.integration.test.ts+++ b/packages/sdk/src/client.integration.test.ts@@ -28,15 +28,6 @@ describe("Context7 Client integration", () => {expect(library).toHaveProperty("trustScore");expect(library).toHaveProperty("benchmarkScore");});-- test("should search with different queries", async () => {- const queries = ["vue", "express", "next"];-- for (const query of queries) {- const result = await client.searchLibrary(`I want to use ${query}`, query);- expect(result.length).toBeGreaterThan(0);- }- }, 15000);});describe("getContext - JSON format (default)", () => {@@ -50,16 +41,6 @@ describe("Context7 Client integration", () => {expect(result.length).toBeGreaterThan(0);});- test("should get context with explicit json type", async () => {- const result = await client.getContext("How to use hooks", "/react/react", {- type: "json",- });-- expect(result).toBeDefined();- expect(Array.isArray(result)).toBe(true);- expect(result.length).toBeGreaterThan(0);- });-test("should have correct Documentation structure", async () => {const result = await client.getContext("How to use hooks", "/react/react", {type: "json",@@ -90,26 +71,6 @@ describe("Context7 Client integration", () => {});});- describe("getContext - different libraries", () => {- const client = new Context7({ apiKey });-- test("should get context for Vue", async () => {- const result = await client.getContext("How to create components", "/vuejs/core");-- expect(result).toBeDefined();- expect(Array.isArray(result)).toBe(true);- expect(result.length).toBeGreaterThan(0);- });-- test("should get context for Express", async () => {- const result = await client.getContext("How to create routes", "/expressjs/express");-- expect(result).toBeDefined();- expect(Array.isArray(result)).toBe(true);- expect(result.length).toBeGreaterThan(0);- });- });-describe("live error handling", () => {const client = new Context7({ apiKey });diff --git a/packages/sdk/src/client.test.ts b/packages/sdk/src/client.test.tsindex 73533c19..3bca2dae 100644--- a/packages/sdk/src/client.test.ts+++ b/packages/sdk/src/client.test.ts@@ -9,10 +9,6 @@ describe("Context7 Client", () => {vi.restoreAllMocks();});- test("creates a client with an explicit API key", () => {- expect(new Context7({ apiKey: "ctx7sk-config" })).toBeDefined();- });-test("creates a client from the environment", () => {vi.stubEnv("CONTEXT7_API_KEY", "ctx7sk-environment");diff --git a/packages/sdk/src/commands/search/index.test.ts b/packages/sdk/src/commands/search/index.test.tsindex 1a60c050..95721508 100644--- a/packages/sdk/src/commands/search/index.test.ts+++ b/packages/sdk/src/commands/search/index.test.ts@@ -3,26 +3,6 @@ import { SearchCommand } from "./index";import { requesterWith } from "@utils/test-utils";describe("SearchCommand", () => {- test("builds a request with repeated library hints and preferences", () => {- const command = new SearchCommand("How do I store vectors?", {- libraries: ["Upstash Vector", "/upstash/vector-js"],- version: "v1.2.0",- language: "TypeScript",- type: "json",- });-- expect(command.request).toEqual({- method: "GET",- query: {- query: "How do I store vectors?",- type: "json",- library: ["Upstash Vector", "/upstash/vector-js"],- version: "v1.2.0",- language: "TypeScript",- },- });- });-test("preserves JSON snippets and rules without a lossy conversion", async () => {const command = new SearchCommand("How do I use hooks?", { type: "json" });const response = {@@ -60,10 +40,4 @@ describe("SearchCommand", () => {"documentation text");});-- test("defaults to a structured JSON response", () => {- expect(new SearchCommand("How do I use hooks?").request.query).toMatchObject({- type: "json",- });- });});diff --git a/packages/sdk/src/http/index.test.ts b/packages/sdk/src/http/index.test.tsindex 1f51552d..8869226d 100644--- a/packages/sdk/src/http/index.test.ts+++ b/packages/sdk/src/http/index.test.ts@@ -400,23 +400,6 @@ describe("HttpClient error handling", () => {expect(() => new HttpClient({ baseUrl: "https://example.com\n" })).toThrow(Context7UrlError);});- test("allows keepalive to be disabled", async () => {- const fetchMock = vi.fn().mockResolvedValue(new Response("ok"));- const client = new HttpClient({- baseUrl: "https://example.com",- fetch: fetchMock,- retry: false,- keepAlive: false,- });-- await client.request({ path: ["search"] });-- expect(fetchMock).toHaveBeenCalledWith(- "https://example.com/search",- expect.objectContaining({ keepalive: false })- );- });-test("falls back to statusText on empty error body", async () => {mockFetch(new Response("", { status: 503, statusText: "Service Unavailable" }));diff --git a/packages/tools-ai-sdk/src/index.test.ts b/packages/tools-ai-sdk/src/index.test.tsindex b51353d0..5901e286 100644--- a/packages/tools-ai-sdk/src/index.test.ts+++ b/packages/tools-ai-sdk/src/index.test.ts@@ -38,19 +38,6 @@ describe("@upstash/context7-tools-ai-sdk", () => {expect(tool).toHaveProperty("description");expect(tool.description).toContain("documentation");});-- test("tools should accept custom config", () => {- const resolveTool = resolveLibraryId({- apiKey: "ctx7sk-test-key",- });-- const docsTool = queryDocs({- apiKey: "ctx7sk-test-key",- });-- expect(resolveTool).toHaveProperty("execute");- expect(docsTool).toHaveProperty("execute");- });});describe("Tool usage with generateText", () => {@@ -112,43 +99,6 @@ describe("@upstash/context7-tools-ai-sdk", () => {});describe("Context7Agent class", () => {- test("should create an agent instance with model", () => {- const agent = new Context7Agent({- model,- });-- expect(agent).toBeDefined();- expect(agent).toHaveProperty("generate");- expect(agent).toHaveProperty("stream");- });-- test("should accept custom stopWhen condition", () => {- const agent = new Context7Agent({- model,- stopWhen: stepCountIs(3),- });-- expect(agent).toBeDefined();- });-- test("should accept custom instructions", () => {- const agent = new Context7Agent({- model,- instructions: "Custom instructions for testing",- });-- expect(agent).toBeDefined();- });-- test("should accept Context7 config options", () => {- const agent = new Context7Agent({- model,- apiKey: "ctx7sk-test-key",- });-- expect(agent).toBeDefined();- });-test("should accept additional tools alongside Context7 tools", () => {const customTool = tool({description: "A custom test tool",@@ -165,27 +115,13 @@ describe("@upstash/context7-tools-ai-sdk", () => {},});- expect(agent).toBeDefined();+ expect(Object.keys(agent.tools).sort()).toEqual([+ "customTool",+ "queryDocs",+ "resolveLibraryId",+ ]);});- test("should generate response using agent workflow", async () => {- const agent = new Context7Agent({- model,- stopWhen: stepCountIs(5),- });-- const result = await agent.generate({- prompt: "Find the React library and get documentation about hooks",- });-- expect(result).toBeDefined();- expect(result.steps.length).toBeGreaterThan(0);-- const allToolCalls = result.steps.flatMap((step) => step.toolCalls);- const toolNames = allToolCalls.map((call) => call.toolName);- expect(toolNames).toContain("resolveLibraryId");- }, 60000);-test("should include Context7 tools in generate result", async () => {const agent = new Context7Agent({model,