@globalfishingwatch/mcp 0.0.1 → 0.0.3

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/cli/auth.js CHANGED
@@ -43,7 +43,7 @@ function resolveToken() {
43
43
  async function authLogin() {
44
44
  const rl = readline_1.default.createInterface({ input: process.stdin, output: process.stdout });
45
45
  const token = await new Promise((resolve) => {
46
- rl.question('Enter your GFW API token: ', (answer) => {
46
+ rl.question('Get your token at: https://globalfishingwatch.org/our-apis/tokens\nEnter your GFW API token: ', (answer) => {
47
47
  rl.close();
48
48
  resolve(answer.trim());
49
49
  });
package/dist/cli/index.js CHANGED
@@ -17,18 +17,25 @@ function fail(message) {
17
17
  console.error(`Error: ${message}`);
18
18
  process.exit(1);
19
19
  }
20
+ const TOKEN_URL = 'https://globalfishingwatch.org/our-apis/tokens';
21
+ const TOKEN_HINT = `\n You need a GFW API token. Generate one at: ${TOKEN_URL}\n Then run: gfw auth login`;
22
+ function isAuthError(message) {
23
+ return /401|403|unauthorized|forbidden|no gfw api token/i.test(message);
24
+ }
20
25
  async function run(fn) {
21
26
  try {
22
27
  // Inject token into env so gfwFetch picks it up
23
28
  process.env.API_KEY = (0, auth_js_1.resolveToken)();
24
29
  const result = await fn();
25
30
  if (result && typeof result === 'object' && 'isError' in result && result.isError) {
26
- fail(result.content?.[0]?.text ?? 'Unknown error');
31
+ const message = result.content?.[0]?.text ?? 'Unknown error';
32
+ fail(isAuthError(message) ? message + TOKEN_HINT : message);
27
33
  }
28
34
  print(result);
29
35
  }
30
36
  catch (err) {
31
- fail(err instanceof Error ? err.message : String(err));
37
+ const message = err instanceof Error ? err.message : String(err);
38
+ fail(isAuthError(message) ? message + TOKEN_HINT : message);
32
39
  }
33
40
  }
34
41
  const program = new commander_1.Command();
package/dist/lib/api.js CHANGED
@@ -1,10 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.gfwFetch = gfwFetch;
4
+ const undici_1 = require("undici");
4
5
  const GFW_BASE = 'https://gateway.api.globalfishingwatch.org';
6
+ const proxyUrl = process.env.HTTPS_PROXY || process.env.HTTP_PROXY;
7
+ const dispatcher = proxyUrl ? new undici_1.ProxyAgent(proxyUrl) : undefined;
5
8
  /**
6
9
  * Fetch wrapper for the GFW API.
7
10
  * Automatically injects the Bearer token from API_KEY env var when present.
11
+ * Respects HTTPS_PROXY / HTTP_PROXY environment variables.
8
12
  * Throws an Error if the response is not OK.
9
13
  */
10
14
  async function gfwFetch(path, params) {
@@ -14,11 +18,12 @@ async function gfwFetch(path, params) {
14
18
  }
15
19
  const apiKey = process.env.API_KEY;
16
20
  console.error(`Making GFW API request to ${url}`);
17
- const response = await fetch(url.toString(), {
21
+ const response = await (0, undici_1.fetch)(url.toString(), {
18
22
  headers: {
19
23
  ...(apiKey && { Authorization: `Bearer ${apiKey}` }),
20
24
  Referer: 'gfw-mcp-js',
21
25
  },
26
+ dispatcher,
22
27
  });
23
28
  if (!response.ok) {
24
29
  throw new Error(`GFW API error ${response.status}: ${response.statusText}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@globalfishingwatch/mcp",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "MCP server for Global Fishing Watch data — vessel search, events, fishing hours, and region lookups",
5
5
  "author": "Global Fishing Watch",
6
6
  "license": "Apache-2.0",
@@ -35,6 +35,7 @@
35
35
  "commander": "^14.0.3",
36
36
  "express": "^5.1.0",
37
37
  "qs": "^6.15.1",
38
+ "undici": "^7.25.0",
38
39
  "zod": "^3.25.76"
39
40
  },
40
41
  "devDependencies": {