Guide · Amazon EFS · Shared Storage
Amazon EFS for MCP Servers — Shared Persistent Storage, Mount Targets, and Access Points
Amazon Elastic File System (EFS) is a fully managed NFS file system that grows and shrinks automatically as you store and delete files. For MCP servers, EFS fills the gap between S3 (object storage, no POSIX semantics) and EBS (block storage, single-instance). EFS lets multiple EC2 instances, ECS tasks, or Lambda functions share a common file namespace: pre-cached embedding models, shared tool artifact directories, shared session state files, or configuration bundles that are too large to fit in environment variables and too expensive to fetch from S3 on every cold start. This guide covers creating an EFS file system, configuring mount targets and security groups, enabling IAM-based authorization, using access points for per-service isolation, managing lifecycle storage tiers, and comparing EFS to S3 and EBS for common MCP server use cases.
TL;DR
Create an EFS file system with ThroughputMode: elastic (auto-scales, no burst credits to manage). Create a mount target in every AZ your MCP servers run in — each mount target needs a security group that allows inbound TCP 2049 (NFS) from your server's security group. Enable IAM authorization (elasticfilesystem:ClientMount) and create access points to give each service its own isolated directory subtree with enforced POSIX UID/GID. Mount using amazon-efs-utils with tls,iam options for in-transit encryption and IAM credential verification. Use Intelligent-Tiering lifecycle policy to automatically move files to IA storage after 14–30 days of inactivity.
When to use EFS for MCP servers
EFS makes sense when two or more compute units need concurrent read/write access to the same file namespace. The three most common MCP server patterns are:
- Shared model cache — download a large embedding model (e.g., 1.5 GB ONNX file) once to EFS and have every Lambda function or ECS task read it from
/mnt/efs/models/rather than fetching from S3 on every cold start. Cold-start latency drops from ~8s (S3 download) to ~100ms (EFS NFS read). - Shared tool artifacts — MCP tools that generate reports, PDFs, or rendered images can write to EFS and have another tool or service read the same files without an S3 round-trip.
- Shared session state — if multiple MCP server instances serve the same client session (behind an ALB without sticky sessions), EFS provides a common store for conversation context files. For simple key-value data, ElastiCache is a better fit; for binary blobs with POSIX semantics, EFS is the right choice.
EFS is the wrong choice for high-IOPS random-write workloads (use EBS gp3 or io2), for key-value data (use DynamoDB or ElastiCache), or for cold object storage (use S3 Standard-IA or Glacier). The table below summarizes the tradeoffs:
| Storage | Semantics | Multi-attach | Latency | Price | Best for MCP servers |
|---|---|---|---|---|---|
| EBS gp3 | Block device | No (single instance) | <1ms | $0.08/GB/mo | OS volumes, database files, single-instance write-heavy workloads |
| EFS Standard | NFS (POSIX) | Yes (thousands) | 1–10ms | $0.30/GB/mo | Shared model caches, shared artifacts, multi-instance reads |
| EFS IA | NFS (POSIX) | Yes (thousands) | 1–10ms + retrieval | $0.016/GB/mo + $0.01/GB retrieval | Infrequently read models or config bundles |
| S3 | Object (HTTP API) | Yes (unlimited) | 5–200ms first byte | $0.023/GB/mo | Large artifacts, backups, cold data, CDN origin |
Creating an EFS file system
Use @aws-sdk/client-efs (Node.js) or the CLI. The key parameters are ThroughputMode, PerformanceMode, and Encrypted:
import {
EFSClient,
CreateFileSystemCommand,
CreateMountTargetCommand,
CreateAccessPointCommand,
PutLifecycleConfigurationCommand,
} from "@aws-sdk/client-efs";
const efs = new EFSClient({ region: "us-east-1" });
// 1. Create the file system
const { FileSystemId } = await efs.send(new CreateFileSystemCommand({
ThroughputMode: "elastic", // auto-scales, no burst credit management
PerformanceMode: "generalPurpose", // <7ms metadata latency; use maxIO only for 100+ clients
Encrypted: true, // KMS encryption at rest (uses AWS-managed CMK by default)
Tags: [
{ Key: "Name", Value: "mcp-server-shared" },
{ Key: "Service", Value: "mcp-server" },
],
// ClientToken is used for idempotency — same value returns existing FS instead of creating duplicate
ClientToken: `mcp-server-shared-${Date.now()}`,
}));
console.log("FileSystemId:", FileSystemId); // fs-0abc123def456
The file system starts in the creating state and transitions to available within 30–60 seconds. Poll with DescribeFileSystemsCommand before creating mount targets.
import { DescribeFileSystemsCommand } from "@aws-sdk/client-efs";
async function waitForAvailable(fileSystemId: string): Promise<void> {
for (let i = 0; i < 20; i++) {
const { FileSystems } = await efs.send(new DescribeFileSystemsCommand({
FileSystemId: fileSystemId,
}));
if (FileSystems?.[0]?.LifeCycleState === "available") return;
await new Promise(r => setTimeout(r, 3000));
}
throw new Error("EFS file system did not become available in 60s");
}
Mount targets — one per AZ
A mount target is a network interface (ENI) in a specific subnet that NFS clients connect to. You need one mount target per AZ where your MCP servers run. Each mount target is associated with a security group that controls NFS access.
# CLI: create mount targets in two AZs
# First, create the EFS security group
aws ec2 create-security-group \
--group-name efs-sg \
--description "EFS mount target — allows NFS from MCP server SG" \
--vpc-id vpc-12345678
# Allow inbound NFS (TCP 2049) only from the MCP server SG
aws ec2 authorize-security-group-ingress \
--group-id sg-efs \
--protocol tcp \
--port 2049 \
--source-group sg-mcp-server # the SG attached to your EC2/ECS/Lambda
# Create mount target in AZ us-east-1a
aws efs create-mount-target \
--file-system-id fs-0abc123def456 \
--subnet-id subnet-aaa111 \ # subnet in us-east-1a
--security-groups sg-efs
# Create mount target in AZ us-east-1b
aws efs create-mount-target \
--file-system-id fs-0abc123def456 \
--subnet-id subnet-bbb222 \ # subnet in us-east-1b
--security-groups sg-efs
Mount targets take 1–2 minutes to reach the available state. The DNS name for the file system is <FileSystemId>.efs.<region>.amazonaws.com. When you mount using this DNS name, Route 53 returns the IP of the mount target in the same AZ as the resolver — this means NFS traffic stays within the AZ, avoiding cross-AZ data transfer costs ($0.01/GB).
Critical: the MCP server security group must allow outbound TCP 2049. The default SG egress rule allows all outbound traffic, so this is usually satisfied by default — but if you've restricted egress, add an explicit rule:
aws ec2 authorize-security-group-egress \
--group-id sg-mcp-server \
--protocol tcp \
--port 2049 \
--destination-group sg-efs
Mounting on EC2 with amazon-efs-utils
The recommended mount method is amazon-efs-utils, which handles TLS encryption, IAM-based authorization, and automatic mount target discovery. Install it at bootstrap time (user data) for AL2023:
#!/bin/bash
# Install EFS mount helper (AL2023)
dnf install -y amazon-efs-utils
# Create mount point
mkdir -p /mnt/efs/mcp
# Mount with TLS and IAM auth (uses instance role for credential chain)
mount -t efs -o tls,iam,accesspoint=fsap-0xyz789 \
fs-0abc123def456 /mnt/efs/mcp
# Add to /etc/fstab for persistence across reboots
echo "fs-0abc123def456:/ /mnt/efs/mcp efs tls,iam,accesspoint=fsap-0xyz789,_netdev 0 0" \
>> /etc/fstab
The tls option wraps NFS in TLS (via stunnel under the hood). The iam option instructs the mount helper to sign every NFS request with the instance profile credentials and present the signed request to the EFS mount target, which verifies the IAM permission elasticfilesystem:ClientMount. Without iam, IAM auth is bypassed and only the resource-based file system policy applies.
On Ubuntu, install via snap or package manager:
# Ubuntu
apt-get install -y amazon-efs-utils
# Or install from GitHub if not in apt repo
git clone https://github.com/aws/efs-utils
cd efs-utils && ./build-deb.sh && dpkg -i build/amazon-efs-utils*deb
IAM authorization — ClientMount and ClientWrite
EFS supports two authorization layers: NFS POSIX permissions (UID/GID, file mode) and IAM-based access control. Enable IAM auth by setting a file system policy that requires signed requests and granting the IAM role the appropriate actions.
The two relevant IAM actions are:
elasticfilesystem:ClientMount— required to mount the file system (read-only or read-write)elasticfilesystem:ClientWrite— required to write files (create, modify, delete)
# IAM policy for an MCP server role that reads from EFS (read-only mount)
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"elasticfilesystem:ClientMount"
],
"Resource": "arn:aws:elasticfilesystem:us-east-1:123456789012:file-system/fs-0abc123def456",
"Condition": {
"StringEquals": {
"elasticfilesystem:AccessPointArn":
"arn:aws:elasticfilesystem:us-east-1:123456789012:access-point/fsap-0xyz789"
}
}
}
]
}
# IAM policy for a writer role (e.g., a data pipeline that writes models to EFS)
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"elasticfilesystem:ClientMount",
"elasticfilesystem:ClientWrite"
],
"Resource": "arn:aws:elasticfilesystem:us-east-1:123456789012:file-system/fs-0abc123def456",
"Condition": {
"StringEquals": {
"elasticfilesystem:AccessPointArn":
"arn:aws:elasticfilesystem:us-east-1:123456789012:access-point/fsap-0xyz789"
}
}
}
]
}
Optionally, enforce IAM auth at the file system level by adding a resource-based policy that denies unauthenticated NFS access. This prevents any mount that does not use the iam option:
aws efs put-file-system-policy \
--file-system-id fs-0abc123def456 \
--policy '{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Deny",
"Principal": { "AWS": "*" },
"Action": ["elasticfilesystem:ClientMount", "elasticfilesystem:ClientWrite"],
"Condition": {
"Bool": { "aws:SecureTransport": "false" }
}
}
]
}'
Access points — per-service POSIX isolation
An access point is a named entry point into an EFS file system that enforces a specific directory path and POSIX UID/GID on every file operation. Access points let you share one EFS file system across multiple services while keeping each service's data isolated at the filesystem level — no service can accidentally read or overwrite another service's directory.
const { AccessPointId, AccessPointArn } = await efs.send(
new CreateAccessPointCommand({
FileSystemId: "fs-0abc123def456",
// Enforce these POSIX credentials for all operations via this access point
PosixUser: {
Uid: 1001, // UID of the Node.js process in your Docker container
Gid: 1001,
},
RootDirectory: {
Path: "/mcp-server/models", // created automatically on first access
CreationInfo: {
OwnerUid: 1001,
OwnerGid: 1001,
Permissions: "755", // octal string, not number
},
},
Tags: [{ Key: "Service", Value: "mcp-server-reader" }],
})
);
console.log("AccessPointId:", AccessPointId); // fsap-0xyz789
When mounted via this access point, the NFS client sees /mcp-server/models as the root directory (the actual EFS root is hidden). Files created through this access point are owned by UID 1001 / GID 1001 regardless of the actual process UID, preventing privilege escalation between services sharing the same file system.
A common pattern is to have one access point per service with a directory structure like:
/ (EFS root — not directly mountable if IAM-only policy)
├── mcp-server/
│ ├── models/ → access point fsap-models (UID 1001, read-only)
│ ├── artifacts/ → access point fsap-artifacts (UID 1001, read-write)
│ └── sessions/ → access point fsap-sessions (UID 1001, read-write)
├── data-pipeline/
│ └── uploads/ → access point fsap-uploads (UID 2000, read-write)
└── admin/
└── audit-logs/ → access point fsap-audit (UID 0, read-write)
Lifecycle storage tiers
EFS has four storage classes. Files automatically move between classes based on access patterns when you configure a lifecycle policy:
| Storage class | Price (us-east-1) | Retrieval fee | Latency |
|---|---|---|---|
| Standard | $0.30/GB/month | None | Low (sub-ms for warm data) |
| Standard-Infrequent Access (IA) | $0.016/GB/month | $0.01/GB | Same as Standard for first read; then same |
| One Zone | $0.043/GB/month | None | Low (single AZ) |
| One Zone-IA | $0.00743/GB/month | $0.01/GB | Same as One Zone |
For a shared model cache, models are written once and read frequently at first (warm cache) then rarely after a newer model ships. Configure a 30-day IA transition:
aws efs put-lifecycle-configuration \
--file-system-id fs-0abc123def456 \
--lifecycle-policies \
'[
{"TransitionToIA": "AFTER_30_DAYS"},
{"TransitionToPrimaryStorageClass": "AFTER_1_ACCESS"}
]'
The TransitionToPrimaryStorageClass: AFTER_1_ACCESS policy moves a file back to Standard tier after one read, so a cache miss doesn't incur repeated retrieval fees. For true cold archival data that you read very rarely, omit the back-transition policy.
EFS Intelligent-Tiering is a shorthand for enabling both transition policies simultaneously and is equivalent to the two-policy setup above. Use it for model caches and artifact directories where access patterns vary unpredictably across files.
File system policy — deny root access and enforce encryption
A production EFS file system policy should deny root access from outside the file system (unless explicitly needed) and require TLS for all mounts. Combine these with the IAM-only mount approach:
aws efs put-file-system-policy \
--file-system-id fs-0abc123def456 \
--policy '{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DenyNonTLSAccess",
"Effect": "Deny",
"Principal": { "AWS": "*" },
"Action": "*",
"Condition": {
"Bool": { "aws:SecureTransport": "false" }
}
},
{
"Sid": "DenyRootAccess",
"Effect": "Deny",
"Principal": { "AWS": "*" },
"Action": "elasticfilesystem:ClientRootAccess",
"Resource": "*"
}
]
}'
The ClientRootAccess denial ensures that even if a process runs as UID 0 inside a container, it cannot bypass POSIX permissions on the EFS file system. Access points with PosixUser set override the UID anyway, but denying root access is an additional defense in depth.
Monitoring EFS with CloudWatch
Key EFS CloudWatch metrics for MCP server operators:
| Metric | Namespace | What it means | Alarm threshold |
|---|---|---|---|
BurstCreditBalance | AWS/EFS | Remaining burst throughput credits (Bursting mode only) | Alert when <1 GB (1073741824 bytes) — means sustained burst will be throttled |
TotalIOBytes | AWS/EFS | Total bytes read and written per period | Baseline capacity planning — alert if approaches provisioned throughput limit |
PercentIOLimit | AWS/EFS | Percentage of General Purpose performance mode limit used | Alert when >80% — if sustained, switch to Max I/O performance mode |
MeteredIOBytes | AWS/EFS | Bytes billed for throughput (Elastic mode) | Use for cost anomaly detection |
ClientConnections | AWS/EFS | Number of connected NFS clients | Use to verify mount targets are in use; alert on 0 if expected >0 |
import { CloudWatchClient, PutMetricAlarmCommand } from "@aws-sdk/client-cloudwatch";
const cw = new CloudWatchClient({ region: "us-east-1" });
// Alert when PercentIOLimit exceeds 80% (sustained = switch to Max I/O)
await cw.send(new PutMetricAlarmCommand({
AlarmName: "efs-mcp-server-io-limit",
Namespace: "AWS/EFS",
MetricName: "PercentIOLimit",
Dimensions: [{ Name: "FileSystemId", Value: "fs-0abc123def456" }],
Period: 300,
EvaluationPeriods: 3,
Threshold: 80,
ComparisonOperator: "GreaterThanThreshold",
Statistic: "Average",
AlarmActions: ["arn:aws:sns:us-east-1:123456789012:ops-alerts"],
TreatMissingData: "notBreaching",
}));
Common errors and fixes
| Error | Cause | Fix |
|---|---|---|
mount.nfs4: Connection refused | Security group missing inbound TCP 2049 on the EFS SG, or missing outbound TCP 2049 on the client SG | Verify both rules; also confirm mount target is in available state and in the same VPC |
mount.nfs4: Operation not permitted | IAM auth enabled but instance role lacks elasticfilesystem:ClientMount | Attach IAM policy with ClientMount on the file system ARN; use -o iam in mount options |
Permission denied on file writes | POSIX UID of running process does not match access point PosixUser UID, or ClientWrite permission missing | Check id in container; align Dockerfile USER UID with access point PosixUser.Uid; add ClientWrite to IAM policy |
mount: wrong fs type | amazon-efs-utils not installed; falls back to standard nfs4 mount type | Install amazon-efs-utils; use -t efs mount type (not nfs4) |
| Stale NFS file handle | Mount target was replaced (e.g., after mount target deletion and recreation) | Unmount and remount; use _netdev in fstab to delay mount until network is ready |
AccessPointAlreadyExists | ClientToken collision or duplicate access point creation | Use DescribeAccessPointsCommand to find existing access point; use idempotent ClientToken derived from a stable identifier |
| High latency on first read after idle | Files migrated to IA tier; first access incurs retrieval penalty (~10ms additional) | Enable TransitionToPrimaryStorageClass: AFTER_1_ACCESS so frequently re-read files move back to Standard tier |
Related guides
- EFS with Lambda: mounting shared file systems in serverless MCP server functions
- EFS performance modes and throughput: Bursting, Elastic, and Provisioned for MCP servers
- EFS with ECS and Fargate: persistent volumes for stateful MCP server containers
- Running MCP servers on Amazon EC2: instance profiles, IMDSv2, and security groups
- MCP server uptime monitoring