Skip to content

Commit 80d66f3

Browse files
jirispilkaclaude
andauthored
fix: Drop Node.js requirement from 22 to 18 and remove cheerio dependency (#572)
* fix: Drop Node.js requirement from 22 to 18 and remove cheerio dependency Sentry telemetry showed ~20K crash events from users on older Node.js versions (File is not defined, ReadableStream is not defined) and ~115K events from corrupted npx caches. This change improves compatibility by lowering the minimum Node.js version to 18 (matching @modelcontextprotocol/sdk). - Remove cheerio dependency (required Node >=20.18.1) and the unused get-html-skeleton tool, its cache, constants, and tests - Lower engines.node to >=18 in package.json, manifest.json, docs - Add Node.js version guard in stdio.ts with a clear error message - Add Node.js version policy documentation in DEVELOPMENT.md - Expand README troubleshooting section (npx cache, old Node, log paths) - CI now tests against Node.js 18, 20, 22, and 24 via matrix strategy Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: Simplify MCP URL assignment and improve README clarity --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a74ca78 commit 80d66f3

16 files changed

Lines changed: 84 additions & 426 deletions

.actor/ACTOR.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ You can run the Apify MCP Server on your local machine by configuring it with Cl
166166

167167
- MacOS or Windows
168168
- The latest version of Claude Desktop must be installed (or another MCP client)
169-
- [Node.js](https://nodejs.org/en) (v22 or higher)
169+
- [Node.js](https://nodejs.org/en) (v18 or higher)
170170
- [Apify API Token](https://docs.apify.com/platform/integrations/api#api-token) (`APIFY_TOKEN`)
171171

172172
Make sure you have the `node` and `npx` installed properly:
@@ -308,7 +308,7 @@ npx @modelcontextprotocol/inspector npx -y @apify/actors-mcp-server
308308

309309
## Prerequisites
310310

311-
- [Node.js](https://nodejs.org/en) (v22 or higher)
311+
- [Node.js](https://nodejs.org/en) (v18 or higher)
312312
- Python 3.9 or higher
313313

314314
Create an environment file `.env` with the following content:

.github/workflows/_check_code.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,19 @@ jobs:
4949
run: npm run build
5050

5151
test:
52-
name: Test
52+
name: Test (Node.js ${{ matrix.node-version }})
53+
strategy:
54+
matrix:
55+
node-version: [18, 20, 22, 24]
56+
fail-fast: false
5357
runs-on: ubuntu-latest
5458

5559
steps:
5660
- uses: actions/checkout@v6
57-
- name: Use Node.js
61+
- name: Use Node.js ${{ matrix.node-version }}
5862
uses: actions/setup-node@v6
5963
with:
60-
node-version-file: '.nvmrc'
64+
node-version: ${{ matrix.node-version }}
6165
cache: 'npm'
6266
cache-dependency-path: 'package-lock.json'
6367
- name: Install Dependencies

DEVELOPMENT.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,19 @@ Key entry points:
3434
- `src/main.ts` - Actor entry point (standby server / debugging)
3535
- `src/input.ts` - Input processing and validation
3636

37+
## Node.js version policy
38+
39+
The minimum supported Node.js version is **18** (`engines.node >= 18` in `package.json`).
40+
41+
**Why Node.js 18 (not higher):**
42+
The MCP server is installed by end-users via `npx` and must work on the widest reasonable range of Node.js versions. Our key dependency, `@modelcontextprotocol/sdk`, requires Node.js >= 18, and our own source code uses no APIs beyond what Node.js 18 provides. Sentry telemetry showed ~20K crash events from users on older Node versions (`File is not defined`, `ReadableStream is not defined`), confirming that many users run older runtimes.
43+
44+
**Rules for maintaining compatibility:**
45+
- Do not use Node.js APIs introduced after v18 (e.g., `import.meta.resolve`, `Array.fromAsync`, `Set.union()`).
46+
- Do not add dependencies that require Node.js > 18 at runtime. Check `engines` field of new dependencies before adding them.
47+
- CI runs unit tests against Node.js 18, 20, 22, and 24 to catch compatibility regressions.
48+
- The `.nvmrc` file pins the latest Node.js version for development tooling (lint, type-check, build) — this is intentionally higher than the minimum supported version.
49+
3750
## How to contribute
3851

3952
Refer to the [CONTRIBUTING.md](./CONTRIBUTING.md) file.

README.md

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,19 +235,19 @@ All tools include metadata annotations to help MCP clients and LLMs understand t
235235

236236
- **`title`**: Short display name for the tool (e.g., "Search Actors", "Call Actor", "apify/rag-web-browser")
237237
- **`readOnlyHint`**: `true` for tools that only read data without modifying state (e.g., `get-dataset`, `fetch-actor-details`)
238-
- **`openWorldHint`**: `true` for tools that access external resources outside the Apify platform (e.g., `call-actor` executes external Actors, `get-html-skeleton` scrapes external websites). Tools that interact only with the Apify platform (like `search-actors` or `fetch-apify-docs`) do not have this hint.
238+
- **`openWorldHint`**: `true` for tools that access external resources outside the Apify platform (e.g., `call-actor` executes external Actors). Tools that interact only with the Apify platform (like `search-actors` or `fetch-apify-docs`) do not have this hint.
239239

240240
### Tools configuration
241241

242-
The `tools` configuration parameter is used to specify loaded tools - either categories or specific tools directly, and Apify Actors. For example, `tools=storage,runs` loads two categories; `tools=add-actor` loads just one tool.
242+
The `tools` configuration parameter is used to specify loaded tools either categories or specific tools directly, and Apify Actors. For example, `tools=storage,runs` loads two categories; `tools=add-actor` loads just one tool.
243243

244244
When no query parameters are provided, the MCP server loads the following `tools` by default:
245245

246246
- `actors`
247247
- `docs`
248248
- `apify/rag-web-browser`
249249

250-
If the tools parameter is specified, only the listed tools or categories will be enabled - no default tools will be included.
250+
If the tools parameter is specified, only the listed tools or categories will be enabled no default tools will be included.
251251

252252
> **Easy configuration:**
253253
>
@@ -390,7 +390,7 @@ For detailed development setup, project structure, and local testing instruction
390390

391391
## Prerequisites
392392

393-
- [Node.js](https://nodejs.org/en) (v22 or higher)
393+
- [Node.js](https://nodejs.org/en) (v18 or higher)
394394

395395
Create an environment file, `.env`, with the following content:
396396
```text
@@ -446,10 +446,50 @@ The Apify MCP Server is also available on [Docker Hub](https://hub.docker.com/mc
446446

447447
# 🐛 Troubleshooting (local MCP server)
448448

449-
- Make sure you have `node` installed by running `node -v`.
449+
- Make sure you have `node` (v18 or higher) installed by running `node -v`.
450450
- Make sure the `APIFY_TOKEN` environment variable is set.
451451
- Always use the latest version of the MCP server by using `@apify/actors-mcp-server@latest`.
452452

453+
### Common issues
454+
455+
#### "Unable to connect to extension server" or tools not loading
456+
457+
This is most commonly caused by a **corrupted npx cache**. Fix it by clearing the cache and retrying:
458+
459+
```bash
460+
# Clear the npx cache
461+
rm -rf ~/.npm/_npx
462+
463+
# Retry
464+
npx -y @apify/actors-mcp-server@latest
465+
```
466+
467+
#### Errors like "File is not defined" or "ReadableStream is not defined"
468+
469+
You are running an **outdated version of Node.js**. The Apify MCP server requires Node.js 18 or higher:
470+
471+
```bash
472+
node -v # Check your version
473+
```
474+
475+
If your version is below 18, update Node.js from [nodejs.org](https://nodejs.org).
476+
477+
#### "Cannot find module" errors
478+
479+
This usually indicates a corrupted `npx` cache (see above). Clear it with `rm -rf ~/.npm/_npx` and retry.
480+
481+
#### Server works in Claude Desktop chat but not in cowork mode
482+
483+
This is a known issue we are investigating. As a workaround, try using the hosted server at [mcp.apify.com](https://mcp.apify.com) instead of the local stdio server.
484+
485+
### Checking logs
486+
487+
If you encounter issues, check the Claude Desktop logs for error details:
488+
489+
- **macOS**: `~/Library/Logs/Claude/`
490+
- **Windows**: `%APPDATA%\Claude\logs\`
491+
- **Linux**: `~/.config/Claude/logs/`
492+
453493
### Debugging the NPM package
454494

455495
To debug the server, use the [MCP Inspector](https://github.com/modelcontextprotocol/inspector) tool:

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
"linux"
8989
],
9090
"runtimes": {
91-
"node": ">=22.0.0"
91+
"node": ">=18.0.0"
9292
}
9393
}
9494
}

package-lock.json

Lines changed: 1 addition & 126 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"description": "Apify MCP Server",
66
"mcpName": "com.apify/apify-mcp-server",
77
"engines": {
8-
"node": ">=22.0.0"
8+
"node": ">=18.0.0"
99
},
1010
"main": "dist/index.js",
1111
"exports": {
@@ -47,13 +47,11 @@
4747
"@modelcontextprotocol/sdk": "^1.25.2",
4848
"@segment/analytics-node": "^2.3.0",
4949
"@sentry/node": "^10.38.0",
50-
"@types/cheerio": "^0.22.35",
5150
"@types/turndown": "^5.0.5",
5251
"ajv": "^8.17.1",
5352
"algoliasearch": "^5.31.0",
5453
"apify": "^3.4.2",
5554
"apify-client": "^2.22.1",
56-
"cheerio": "^1.1.2",
5755
"dotenv": "^16.4.7",
5856
"express": "^4.21.2",
5957
"mcp-client-capabilities": "^0.0.5",

src/const.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ export enum HelperTools {
4646
STORE_SEARCH_INTERNAL = 'search-actors-internal',
4747
DOCS_SEARCH = 'search-apify-docs',
4848
DOCS_FETCH = 'fetch-apify-docs',
49-
GET_HTML_SKELETON = 'get-html-skeleton',
5049
}
5150

5251
export const RAG_WEB_BROWSER = 'apify/rag-web-browser';
@@ -101,8 +100,6 @@ export const ACTOR_CACHE_MAX_SIZE = 500;
101100
export const ACTOR_CACHE_TTL_SECS = 30 * 60; // 30 minutes
102101
export const APIFY_DOCS_CACHE_MAX_SIZE = 500;
103102
export const APIFY_DOCS_CACHE_TTL_SECS = 60 * 60; // 1 hour
104-
export const GET_HTML_SKELETON_CACHE_TTL_SECS = 5 * 60; // 5 minutes
105-
export const GET_HTML_SKELETON_CACHE_MAX_SIZE = 200;
106103
export const MCP_SERVER_CACHE_MAX_SIZE = 500;
107104
export const MCP_SERVER_CACHE_TTL_SECS = 30 * 60; // 30 minutes
108105
export const USER_CACHE_MAX_SIZE = 200;

0 commit comments

Comments
 (0)