@upstash/context7-mcp 2.1.7 → 2.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/lib/api.js +16 -5
  2. package/package.json +4 -3
package/dist/lib/api.js CHANGED
@@ -2,6 +2,7 @@ import { generateHeaders } from "./encryption.js";
2
2
  import { Agent, ProxyAgent, setGlobalDispatcher } from "undici";
3
3
  import { CONTEXT7_API_BASE_URL } from "./constants.js";
4
4
  import { readFileSync } from "fs";
5
+ import tls from "tls";
5
6
  /**
6
7
  * Parses error response from the Context7 API
7
8
  * Extracts the server's error message, falling back to status-based messages if parsing fails
@@ -39,21 +40,31 @@ const PROXY_URL = process.env.HTTPS_PROXY ??
39
40
  process.env.http_proxy ??
40
41
  null;
41
42
  const CUSTOM_CA_CERTS = process.env.NODE_EXTRA_CA_CERTS;
42
- function loadCustomCACerts() {
43
- if (!CUSTOM_CA_CERTS)
43
+ export function getDefaultCACertificates() {
44
+ if (typeof tls.getCACertificates === "function") {
45
+ return tls.getCACertificates("default");
46
+ }
47
+ return [...tls.rootCertificates];
48
+ }
49
+ export function loadCustomCACerts(customCACertsPath = CUSTOM_CA_CERTS) {
50
+ if (!customCACertsPath)
44
51
  return undefined;
45
52
  try {
46
- return readFileSync(CUSTOM_CA_CERTS);
53
+ const customCa = readFileSync(customCACertsPath, "utf-8");
54
+ return [...getDefaultCACertificates(), customCa];
47
55
  }
48
56
  catch (error) {
49
- console.error(`[Context7] Failed to load custom CA certificates from ${CUSTOM_CA_CERTS}:`, error);
57
+ console.error(`[Context7] Failed to load custom CA certificates from ${customCACertsPath}:`, error);
50
58
  return undefined;
51
59
  }
52
60
  }
53
61
  if (PROXY_URL && !PROXY_URL.startsWith("$") && /^(http|https):\/\//i.test(PROXY_URL)) {
54
62
  try {
55
63
  const ca = loadCustomCACerts();
56
- setGlobalDispatcher(new ProxyAgent({ uri: PROXY_URL, ...(ca ? { connect: { ca } } : {}) }));
64
+ setGlobalDispatcher(new ProxyAgent({
65
+ uri: PROXY_URL,
66
+ ...(ca ? { requestTls: { ca }, proxyTls: { ca } } : {}),
67
+ }));
57
68
  }
58
69
  catch (error) {
59
70
  console.error(`[Context7] Failed to configure proxy agent for provided proxy URL: ${PROXY_URL}:`, error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@upstash/context7-mcp",
3
- "version": "2.1.7",
3
+ "version": "2.1.8",
4
4
  "mcpName": "io.github.upstash/context7",
5
5
  "description": "MCP server for Context7",
6
6
  "repository": {
@@ -43,11 +43,12 @@
43
43
  },
44
44
  "devDependencies": {
45
45
  "@types/node": "^25.0.3",
46
- "typescript": "^5.8.2"
46
+ "typescript": "^5.8.2",
47
+ "vitest": "^4.0.13"
47
48
  },
48
49
  "scripts": {
49
50
  "build": "tsc && chmod 755 dist/index.js",
50
- "test": "echo \"No tests yet\"",
51
+ "test": "pnpm exec vitest run",
51
52
  "typecheck": "tsc --noEmit",
52
53
  "lint": "eslint .",
53
54
  "lint:check": "eslint .",