Guide · AWS Elastic Beanstalk · MCP Server Deployment
Deploying an MCP Server on AWS Elastic Beanstalk — Node.js Platform, Procfile, and eb CLI Workflow
AWS Elastic Beanstalk is the fastest path to a production-grade MCP server deployment on AWS: upload your application bundle, and EB handles EC2 provisioning, Auto Scaling group configuration, load balancer attachment, CloudWatch log streaming, and rolling deployments — all without requiring you to write a single CloudFormation template. This guide covers the full eb CLI workflow from eb init to eb deploy, Procfile configuration for the MCP process, .ebextensions for port and health check settings, enhanced health reporting, and the IAM instance profile your MCP server needs at runtime. For containerized MCP deployments on the Docker platform, see Elastic Beanstalk Docker Platform. For scaling configuration, see Elastic Beanstalk Auto-Scaling for MCP Servers. For .ebextensions deep-dive and blue/green deployment, see Elastic Beanstalk Environment Configuration.
TL;DR
Run eb init to select the Node.js 20 on Amazon Linux 2023 platform, create a Procfile with web: node server.js, create an .ebextensions/mcp.config to set environment variables and health check path, then run eb create and eb deploy. Your MCP server must listen on process.env.PORT (EB injects PORT=8080) and expose a /health endpoint returning HTTP 200. The EB instance profile needs the AWSElasticBeanstalkWebTier managed policy for CloudWatch Logs, S3 artifact access, and X-Ray tracing.
What Elastic Beanstalk is and why MCP server authors choose it
Elastic Beanstalk is AWS's managed PaaS layer: you give it an application bundle (a zip of your source code or a Docker image reference), specify a platform (Node.js, Python, Java, Docker, etc.), and EB orchestrates the underlying infrastructure. Unlike ECS or EKS, EB does not require you to define task definitions, service files, or Kubernetes manifests. Unlike Lambda, it supports long-lived HTTP connections, which matters for MCP servers using the SSE (Server-Sent Events) transport.
MCP server authors typically choose EB over raw EC2 because EB eliminates the operational work of patching instances, rotating deployment artifacts through S3, draining connections before termination, and wiring up CloudWatch Log groups. At the same time, EB does not remove the ability to customize: every EB environment accepts .ebextensions YAML files that can install OS packages, write files to the instance, run shell commands, and override any environment option. This positions EB between the simplicity of App Runner and the control of ECS Fargate — a good fit for teams shipping MCP servers that need reliable uptime without a dedicated DevOps function.
The key EB concepts an MCP server author needs to understand: an application is a logical container for one or more environments (staging, production). Each environment runs on a specific platform (e.g., 64bit Amazon Linux 2023 v6.x.x running Node.js 20) and has a configuration composed of namespace/option pairs that control the EC2 fleet, load balancer, Auto Scaling group, and application settings.
The eb CLI workflow: init, create, deploy
Install the EB CLI with pip install awsebcli. Then, from your MCP server project root:
# Step 1: Initialize the EB application in the current directory
eb init mcp-server-app \
--platform "Node.js 20 running on 64bit Amazon Linux 2023" \
--region us-east-1
# eb init creates .elasticbeanstalk/config.yml:
# branch-defaults:
# main:
# environment: mcp-server-prod
# global:
# application_name: mcp-server-app
# default_platform: Node.js 20 running on 64bit Amazon Linux 2023
# default_region: us-east-1
# Step 2: Create the environment (single instance for dev, ALB for prod)
# --single: single t3.small with no load balancer (not for production)
eb create mcp-server-dev --single --instance-type t3.small
# Production environment with ALB
eb create mcp-server-prod \
--elb-type application \
--instance-type t3.medium \
--min-instances 2 \
--max-instances 10 \
--tags Environment=production,Service=mcp-server
# Step 3: Deploy the current working directory
eb deploy mcp-server-prod
# Check environment status
eb status mcp-server-prod
# Stream recent application logs
eb logs mcp-server-prod
# Retrieve all logs (application + nginx + eb-engine + eb-hooks)
eb logs mcp-server-prod --all
# SSH onto a running instance (requires key pair configured in eb init)
eb ssh mcp-server-prod
When you run eb deploy, the CLI packages your project directory into a zip (excluding files listed in .ebignore), uploads it to the EB application's S3 artifacts bucket, creates a new application version record, and triggers a rolling deployment to your environment's EC2 fleet. The first deployment to a fresh environment also provisions the Auto Scaling group, the ALB (if chosen), the target group, and the security groups — a process that takes roughly 4–6 minutes. Subsequent deployments to running environments are faster, typically 1–3 minutes depending on the deployment policy.
Platform selection and version pinning
The platform string controls the AMI, the Node.js version, and the nginx proxy configuration that EB installs on each instance. The Amazon Linux 2023 platform family replaces the older Amazon Linux 2 family — prefer AL2023 for new deployments:
# List all available Node.js platform versions
eb platform list --region us-east-1 | grep "Node.js"
# 64bit Amazon Linux 2023 v6.3.1 running Node.js 20
# 64bit Amazon Linux 2023 v6.3.1 running Node.js 18
# 64bit Amazon Linux 2 v5.9.5 running Node.js 18 (legacy)
# Pin to a specific platform ARN in .elasticbeanstalk/config.yml
eb platform select
# or set directly:
# global:
# default_platform: arn:aws:elasticbeanstalk:us-east-1::platform/Node.js 20 running on 64bit Amazon Linux 2023/6.3.1
Pinning to a specific platform ARN prevents automatic platform updates from changing your runtime between deployments. Use aws:elasticbeanstalk:managedactions in .ebextensions to control when EB applies minor platform patches — covered in Environment Configuration.
Procfile: controlling the MCP server process
Without a Procfile, EB's Node.js platform runs your application by executing npm start, which invokes whatever script is in package.json's scripts.start. A Procfile gives you explicit control over the process command and allows you to define additional process types. Place the Procfile in your project root:
# Procfile
web: node server.js
# Optional: background worker process for async tool processing
worker: node worker.js
# Optional: metrics exporter sidecar
metrics: node metrics-exporter.js
The web: process type is the HTTP-serving process that EB wires up to the nginx reverse proxy and the ALB health checker. Only one process type can be web:. The other process types (worker:, metrics:) are started as separate OS processes by EB's Procfile supervisor (Foreman-compatible) but do not receive HTTP traffic — they are useful for MCP server architectures that separate the HTTP handler from the tool execution worker.
Key benefit of Procfile over npm start: you can reference environment variables inline and avoid shell quoting issues:
# Procfile with explicit Node options for production
web: node --max-old-space-size=512 --enable-source-maps server.js
EB runs the Procfile via /opt/elasticbeanstalk/bin/eb_start, which sources the application environment variables (including those set via .ebextensions) before invoking the process command.
PORT environment variable: binding to the right port
This is the most common cause of health check failures on first EB deployment. EB's Node.js platform runs nginx as a reverse proxy on port 80 and proxies traffic to your application on port 8080. EB injects PORT=8080 into the application environment. If your MCP server hardcodes 3000 or 4000, nginx cannot reach it and the ALB health check fails, leaving the environment in a degraded state.
// server.js — always read PORT from environment
import { createServer } from 'http';
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js';
const PORT = parseInt(process.env.PORT ?? '3000', 10);
const server = new McpServer({
name: 'my-mcp-server',
version: '1.0.0',
});
// Register tools...
server.tool('ping', {}, async () => ({
content: [{ type: 'text', text: 'pong' }],
}));
const httpServer = createServer(async (req, res) => {
// Health check endpoint — returns 200 for EB health checks
if (req.method === 'GET' && req.url === '/health') {
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ status: 'ok', uptime: process.uptime() }));
return;
}
if (req.method === 'GET' && req.url === '/sse') {
const transport = new SSEServerTransport('/message', res);
await server.connect(transport);
return;
}
if (req.method === 'POST' && req.url === '/message') {
// handle message...
return;
}
res.writeHead(404);
res.end();
});
httpServer.listen(PORT, () => {
console.log(`MCP server listening on port ${PORT}`);
});
The fallback to 3000 in process.env.PORT ?? '3000' is intentional — it allows local development without setting environment variables while ensuring EB's injected PORT=8080 takes precedence in production.
.ebextensions/mcp.config: environment variables and health check
The .ebextensions/ directory contains YAML config files that EB processes in alphabetical order during each deployment. Create .ebextensions/mcp.config to set environment variables and configure the health check path:
# .ebextensions/mcp.config
option_settings:
# Application environment variables (available to Node.js process via process.env)
aws:elasticbeanstalk:application:environment:
NODE_ENV: production
MCP_LOG_LEVEL: info
MCP_SERVER_NAME: my-mcp-server
# PORT is injected automatically by EB — do not set it here
# Point EB health checks at /health instead of /
aws:elasticbeanstalk:application:
Application Healthcheck URL: /health
# Enhanced health reporting (requires enhanced health agent)
aws:elasticbeanstalk:healthreporting:system:
SystemType: enhanced
HealthStreamingEnabled: true
HealthCheckSuccessThreshold: Ok
# Enable CloudWatch Logs streaming
aws:elasticbeanstalk:cloudwatch:logs:
StreamLogs: true
RetentionInDays: 30
DeleteOnTerminate: false
# nginx proxy settings
aws:elasticbeanstalk:environment:proxy:
ProxyServer: nginx
GzipCompression: true
The Application Healthcheck URL option tells both the load balancer target group and EB's internal health agent to send HTTP GET requests to /health. If you leave this at the default /, your MCP server must return 200 on GET requests to the root path — which many MCP servers do not implement, causing persistent health check failures and unwanted instance replacements.
Serving /health without Node.js overhead
For high-traffic environments where the health check frequency (every 5–10 seconds from each ALB availability zone) adds measurable load to the Node.js event loop, you can configure nginx to serve a static health response directly:
# .ebextensions/nginx-health.config
files:
"/etc/nginx/conf.d/health.conf":
mode: "000644"
owner: root
group: root
content: |
location /health {
access_log off;
return 200 '{"status":"ok"}';
add_header Content-Type application/json;
}
This nginx snippet returns 200 without proxying to your Node.js process, which also makes the health check immune to Node.js event loop lag or garbage collection pauses that might otherwise cause spurious health check failures.
Enhanced health reporting for MCP servers
EB supports two health reporting modes. Basic health uses the load balancer's view of instance health (did the last HTTP request to the health check path return 2xx/3xx?). Enhanced health installs a health agent on each EC2 instance that reports CPU utilization, load average, process status, and application request metrics to EB every 10 seconds.
Enhanced health surfaces information that matters for MCP server operations: if the Node.js process crashes and is restarted by the EB process manager, enhanced health will report the restart count and flag the instance as degraded even if the ALB health check has not yet detected the outage (which can take up to 30 seconds with default ALB settings).
option_settings:
aws:elasticbeanstalk:healthreporting:system:
# enhanced = health agent + CloudWatch metrics; basic = ALB-only
SystemType: enhanced
# Stream enhanced health events to CloudWatch Logs
HealthStreamingEnabled: true
# Instances must return Ok status (not just Degraded) to be counted healthy
# Options: Ok | Warning | Degraded | Severe
HealthCheckSuccessThreshold: Ok
# How many consecutive failed health checks before EB replaces the instance
# (This is separate from ALB's UnhealthyThresholdCount)
EnhancedHealthAuthEnabled: true
The enhanced health agent reports application-level metrics: requests per second, 2xx/4xx/5xx response counts, and P50/P75/P99 latency. For an MCP server these metrics correspond to tool call throughput and latency — connect AliveMCP uptime monitoring for external endpoint checks alongside EB's internal metrics for complete observability coverage.
IAM instance profile for MCP server instances
Every EC2 instance in an EB environment uses an IAM instance profile to authenticate AWS SDK calls. EB creates a default role named aws-elasticbeanstalk-ec2-role with the AWSElasticBeanstalkWebTier managed policy attached. This managed policy grants the minimum permissions for EB to function:
s3:GetObjecton the EB application artifacts bucket (to download the deployment zip)cloudwatch:PutMetricDatafor enhanced health metricslogs:PutLogEvents,logs:CreateLogStream,logs:DescribeLogGroupsfor CloudWatch Logs streamingxray:PutTraceSegments,xray:PutTelemetryRecordsfor X-Ray tracings3:PutObjecton the EB log delivery bucket (foreb logs --all)
MCP servers typically need additional permissions for their tool implementations. Add an inline policy to the aws-elasticbeanstalk-ec2-role rather than attaching additional managed policies, to keep the permission footprint auditable:
# Create an inline policy for MCP server runtime permissions
aws iam put-role-policy \
--role-name aws-elasticbeanstalk-ec2-role \
--policy-name mcp-server-runtime \
--policy-document '{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "SecretsManagerAccess",
"Effect": "Allow",
"Action": [
"secretsmanager:GetSecretValue",
"secretsmanager:DescribeSecret"
],
"Resource": "arn:aws:secretsmanager:us-east-1:123456789012:secret:mcp-server/*"
},
{
"Sid": "DynamoDBToolStorage",
"Effect": "Allow",
"Action": [
"dynamodb:GetItem",
"dynamodb:PutItem",
"dynamodb:UpdateItem",
"dynamodb:DeleteItem",
"dynamodb:Query"
],
"Resource": "arn:aws:dynamodb:us-east-1:123456789012:table/mcp-tool-state"
},
{
"Sid": "BedrockInvoke",
"Effect": "Allow",
"Action": [
"bedrock:InvokeModel",
"bedrock:InvokeModelWithResponseStream"
],
"Resource": "arn:aws:bedrock:us-east-1::foundation-model/anthropic.claude-3-5-sonnet-20241022-v2:0"
}
]
}'
Reference this instance profile in .ebextensions so that environment rebuilds always use the correct role:
# .ebextensions/iam.config
option_settings:
aws:autoscaling:launchtemplate:
IamInstanceProfile: aws-elasticbeanstalk-ec2-role
Deployment bundle: .ebignore and npm install on instance
EB's Node.js platform runs npm install --production on each EC2 instance during deployment, using the package.json and package-lock.json from your bundle. This means you should not include node_modules/ in your deployment zip — doing so inflates the bundle size (often by 100–500 MB for MCP servers with TypeScript toolchains) and slows down both the S3 upload and the per-instance extraction.
# .ebignore — files excluded from the deployment bundle
# Syntax is identical to .gitignore
# Never include node_modules — EB runs npm install on the instance
node_modules/
# Never include .env files — use .ebextensions option_settings or Secrets Manager
.env
.env.local
.env.production
# TypeScript source if you pre-compile to dist/
src/
tsconfig*.json
*.ts
!dist/**/*.js
# Development configs
jest.config.js
.eslintrc*
.prettierrc*
vitest.config.ts
# Local IDE and OS files
.DS_Store
.idea/
.vscode/
# Git history (usually auto-excluded but explicit is safer)
.git/
If your MCP server is written in TypeScript, compile to dist/ before deploying and reference the compiled output in your Procfile:
# Procfile for pre-compiled TypeScript MCP server
web: node dist/server.js
The npm install --production that EB runs only installs dependencies, not devDependencies. Ensure all runtime dependencies (@modelcontextprotocol/sdk, AWS SDK v3 clients, etc.) are in dependencies, not devDependencies.
Logs: eb logs, --cloudwatch-logs, and log groups
EB aggregates several log streams from each instance. When you run eb logs, it retrieves a snapshot of the last 100 lines from each stream:
/var/log/web.stdout.log— stdout from your Node.js process (Procfileweb:)/var/log/eb-hooks.log— output from .ebextensions commands and platform hooks/var/log/nginx/access.log— nginx access log (request URIs, response codes, bytes)/var/log/nginx/error.log— nginx error log (proxy timeouts, upstream connection failures)/var/log/eb-engine.log— EB deployment engine log (deployment steps, errors)
# Retrieve snapshot logs from all instances
eb logs mcp-server-prod --all
# Stream logs in real time (requires CloudWatch Logs streaming enabled)
eb logs mcp-server-prod --cloudwatch-logs enable
# After enabling, view the CloudWatch log group
aws logs tail /aws/elasticbeanstalk/mcp-server-prod/var/log/web.stdout.log \
--follow \
--format short
# CloudWatch log group naming convention:
# /aws/elasticbeanstalk/{environment-name}/{log-file-path}
For production MCP servers, enable CloudWatch Logs streaming in .ebextensions as shown earlier. Without streaming, logs are only available for the duration of the instance's life — if EB replaces an instance during a scale-in event, the logs from that instance are gone unless they were streamed to CloudWatch first.
Complete example: minimal MCP server EB deployment
The following is a complete, working deployment configuration for a Node.js MCP server using the SSE transport on Elastic Beanstalk.
project/
├── server.js # MCP server entry point
├── package.json
├── package-lock.json
├── Procfile # process configuration
├── .ebignore # deployment bundle exclusions
└── .ebextensions/
├── mcp.config # option_settings + health check
└── iam.config # instance profile
# Procfile
web: node server.js
# .ebextensions/mcp.config
option_settings:
aws:elasticbeanstalk:application:environment:
NODE_ENV: production
MCP_LOG_LEVEL: info
aws:elasticbeanstalk:application:
Application Healthcheck URL: /health
aws:elasticbeanstalk:healthreporting:system:
SystemType: enhanced
HealthStreamingEnabled: true
HealthCheckSuccessThreshold: Ok
aws:elasticbeanstalk:cloudwatch:logs:
StreamLogs: true
RetentionInDays: 30
DeleteOnTerminate: false
aws:elasticbeanstalk:environment:proxy:
ProxyServer: nginx
GzipCompression: true
# Full eb CLI command sequence for first deployment
# 1. Initialize application
eb init mcp-server-app \
--platform "Node.js 20 running on 64bit Amazon Linux 2023" \
--region us-east-1
# 2. Create production environment with ALB
eb create mcp-server-prod \
--elb-type application \
--instance-type t3.medium \
--min-instances 2 \
--max-instances 8 \
--tags Environment=production,Service=mcp-server,ManagedBy=eb
# 3. Wait for environment to be Ready (Green), then check URL
eb status mcp-server-prod
# 4. Verify health check passes
curl https://mcp-server-prod.us-east-1.elasticbeanstalk.com/health
# {"status":"ok","uptime":142.3}
# 5. For subsequent code changes, just deploy
eb deploy mcp-server-prod --message "feat: add search tool"
Once deployed, connect AliveMCP to monitor the /health endpoint at https://mcp-server-prod.us-east-1.elasticbeanstalk.com/health for external uptime tracking independent of EB's internal health reporting.