@codacy/codacy-mcp 0.6.21 → 0.6.23

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.
package/dist/index.js CHANGED
@@ -5,6 +5,9 @@ import { OpenAPI } from './src/api/client/index.js';
5
5
  import * as Tools from './src/tools/index.js';
6
6
  import * as Handlers from './src/handlers/index.js';
7
7
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
8
+ import { applyProxyConfig } from './src/proxy.js';
9
+ // Apply proxy / SSL configuration before any outbound requests are made.
10
+ applyProxyConfig();
8
11
  // Check for API key
9
12
  const CODACY_ACCOUNT_TOKEN = process.env.CODACY_ACCOUNT_TOKEN;
10
13
  OpenAPI.BASE = 'https://app.codacy.com/api/v3';
@@ -0,0 +1,74 @@
1
+ import { Agent, ProxyAgent, setGlobalDispatcher } from 'undici';
2
+ // Matches a request hostname against the NO_PROXY / no_proxy list.
3
+ // Handles exact matches and suffix matches (e.g. "example.com" also covers "sub.example.com").
4
+ function matchesNoProxy(hostname) {
5
+ const noProxy = process.env.NO_PROXY ?? process.env.no_proxy;
6
+ if (!noProxy)
7
+ return false;
8
+ const lower = hostname.toLowerCase();
9
+ return noProxy
10
+ .split(',')
11
+ .map(h => h.trim().toLowerCase().replace(/^\./, ''))
12
+ .filter(Boolean)
13
+ .some(entry => entry === '*' || lower === entry || lower.endsWith('.' + entry));
14
+ }
15
+ // Ensures a proxy URL has a protocol prefix. A bare host:port (e.g. "localhost:8080")
16
+ // is treated as HTTP, matching the convention used by curl and most proxy tools.
17
+ function normalizeProxyUrl(url) {
18
+ return /^https?:\/\//i.test(url) ? url : `http://${url}`;
19
+ }
20
+ // Routes each fetch() call through HTTPS_PROXY or HTTP_PROXY based on the request
21
+ // protocol, bypassing the proxy for any host that matches NO_PROXY.
22
+ // Extends Agent so all Dispatcher methods are already implemented.
23
+ class ProxyRoutingDispatcher extends Agent {
24
+ _httpsProxy;
25
+ _httpProxy;
26
+ constructor(httpProxy, httpsProxy, disableSSL) {
27
+ super();
28
+ // requestTls — TLS to the target server through the CONNECT tunnel.
29
+ // proxyTls — TLS to the proxy itself (relevant when proxy URL is HTTPS).
30
+ const tlsOpts = disableSSL ? { rejectUnauthorized: false } : undefined;
31
+ const proxyOpts = tlsOpts ? { requestTls: tlsOpts, proxyTls: tlsOpts } : {};
32
+ this._httpsProxy = httpsProxy
33
+ ? new ProxyAgent({ uri: normalizeProxyUrl(httpsProxy), ...proxyOpts })
34
+ : undefined;
35
+ this._httpProxy = httpProxy
36
+ ? new ProxyAgent({ uri: normalizeProxyUrl(httpProxy), ...proxyOpts })
37
+ : undefined;
38
+ }
39
+ dispatch(options, handler) {
40
+ const origin = options.origin instanceof URL ? options.origin : new URL(String(options.origin));
41
+ if (!matchesNoProxy(origin.hostname)) {
42
+ const proxy = origin.protocol === 'https:'
43
+ ? (this._httpsProxy ?? this._httpProxy)
44
+ : (this._httpProxy ?? this._httpsProxy);
45
+ if (proxy)
46
+ return proxy.dispatch(options, handler);
47
+ }
48
+ return super.dispatch(options, handler);
49
+ }
50
+ }
51
+ /**
52
+ * Reads proxy configuration from environment variables and patches the global
53
+ * fetch dispatcher used by Node.js native fetch.
54
+ *
55
+ * Supported env vars:
56
+ * HTTPS_PROXY / https_proxy — proxy for HTTPS requests
57
+ * HTTP_PROXY / http_proxy — proxy for HTTP requests
58
+ * NO_PROXY / no_proxy — comma-separated list of hosts to bypass
59
+ * NODE_TLS_REJECT_UNAUTHORIZED=0 — disable TLS certificate verification
60
+ *
61
+ * For corporate environments that use SSL inspection (MITM proxies), prefer adding the
62
+ * corporate CA certificate to Node's trust store rather than disabling verification:
63
+ * NODE_EXTRA_CA_CERTS=/path/to/corporate-ca.pem
64
+ * Node reads this at startup and it applies to all TLS connections, including
65
+ * the inner tunnel established through a CONNECT proxy.
66
+ */
67
+ export function applyProxyConfig() {
68
+ const httpsProxy = process.env.HTTPS_PROXY ?? process.env.https_proxy;
69
+ const httpProxy = process.env.HTTP_PROXY ?? process.env.http_proxy;
70
+ if (!httpsProxy && !httpProxy)
71
+ return;
72
+ const disableSSL = process.env.NODE_TLS_REJECT_UNAUTHORIZED === '0';
73
+ setGlobalDispatcher(new ProxyRoutingDispatcher(httpProxy, httpsProxy, disableSSL));
74
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codacy/codacy-mcp",
3
- "version": "0.6.21",
3
+ "version": "0.6.23",
4
4
  "mcpName": "io.github.codacy/codacy-mcp-server",
5
5
  "description": "Codacy MCP server",
6
6
  "license": "MIT",
@@ -32,11 +32,10 @@
32
32
  "inspect": "npm run build && npx @modelcontextprotocol/inspector -e CODACY_ACCOUNT_TOKEN=$CODACY_ACCOUNT_TOKEN node dist/index.js"
33
33
  },
34
34
  "dependencies": {
35
- "@modelcontextprotocol/sdk": "1.25.2",
35
+ "@modelcontextprotocol/sdk": "1.29.0",
36
36
  "@types/node": "^22",
37
- "@types/node-fetch": "^2.6.12",
38
37
  "@types/sarif": "2.1.7",
39
- "node-fetch": "^3.3.2",
38
+ "undici": "^6.0.0",
40
39
  "universal-user-agent": "^7.0.2"
41
40
  },
42
41
  "devDependencies": {