Skip to content

Upgrade Node.js to 20+ to fix MCP server undici compatibility#25

Closed
Copilot wants to merge 2 commits intomainfrom
copilot/upgrade-nodejs-version
Closed

Upgrade Node.js to 20+ to fix MCP server undici compatibility#25
Copilot wants to merge 2 commits intomainfrom
copilot/upgrade-nodejs-version

Conversation

Copy link
Contributor

Copilot AI commented Jan 12, 2026

MCP servers fail in Lambda with ReferenceError: File is not defined because the base image ships Node.js 18 via dnf, but undici (used by mcp-remote) requires Node.js 20+ for the File API.

Changes

  • Node.js installation: Replace dnf package (v18) with NodeSource repository setup to install v20+
  • npm cache: Configure /tmp/.npm cache directory for Lambda's read-only filesystem constraints
# Before
RUN dnf install -y nodejs npm && \
    dnf clean all && \
    npm install -g @anthropic-ai/claude-code

# After  
RUN curl -fsSL https://rpm.nodesource.com/setup_20.x | bash - && \
    dnf install -y nodejs && \
    dnf clean all && \
    npm install -g @anthropic-ai/claude-code

RUN mkdir -p /tmp/.npm && chmod -R 777 /tmp/.npm
ENV npm_config_cache=/tmp/.npm

Affects all command-based MCP servers (e.g., AWS documentation server via uvx).

Original prompt

This section details on the original issue you should resolve

<issue_title>MCP connection fails: Node.js 18 incompatible with undici (requires 20+)</issue_title>
<issue_description>## Problem
MCP servers fail to connect in Lambda environment with error:

ReferenceError: File is not defined
    at Object.<anonymous> (/tmp/.npm/_npx/.../node_modules/undici/lib/web/webidl/index.js:533:48)
Node.js v18.12.1

Root Cause

The Lambda base image (public.ecr.aws/lambda/python:3.12-arm64) ships with Node.js 18 via dnf install nodejs. The undici library (used by mcp-remote) requires Node.js 20+ for the File API.

Solution

Upgrade Node.js in Dockerfile from dnf package to NodeSource repository:

# Install Node.js 20+ (required for MCP's undici dependency)
RUN curl -fsSL https://rpm.nodesource.com/setup_20.x | bash - && \
    dnf install -y nodejs && \
    dnf clean all && \
    npm install -g @anthropic-ai/claude-code

# Fix npm cache permissions for Lambda
RUN mkdir -p /tmp/.npm && chmod -R 777 /tmp/.npm
ENV npm_config_cache=/tmp/.npm

Environment

  • Lambda base image: public.ecr.aws/lambda/python:3.12-arm64
  • Node.js version: 18.12.1 (from dnf)
  • MCP server: cloudflare-radar (uses npx mcp-remote)</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…atibility

Co-authored-by: BukeLy <19304666+BukeLy@users.noreply.github.com>
Copilot AI changed the title [WIP] Upgrade Node.js in Dockerfile for undici compatibility Upgrade Node.js to 20+ to fix MCP server undici compatibility Jan 12, 2026
Copilot AI requested a review from BukeLy January 12, 2026 02:25
@BukeLy BukeLy closed this Feb 4, 2026
@BukeLy BukeLy deleted the copilot/upgrade-nodejs-version branch February 4, 2026 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP connection fails: Node.js 18 incompatible with undici (requires 20+)

2 participants