Guide · AWS Application Signals · ECS Fargate
AWS Application Signals for ECS Fargate MCP Servers — ADOT Sidecar, Task Definition, and IAM
Enabling Application Signals on an ECS Fargate MCP server requires two changes: an ADOT collector sidecar container in the task definition, and four environment variables on your MCP server container. The sidecar runs the OpenTelemetry Collector with the Application Signals pipeline enabled — it receives trace data from your Node.js MCP server via OTLP, forwards spans to X-Ray, and exports aggregated metrics to CloudWatch. No collector configuration file is needed; OTEL_AWS_APPLICATION_SIGNALS_ENABLED=true activates the managed pipeline. This guide covers the exact task definition JSON, IAM task role policy, dependency ordering, and health check configuration.
TL;DR
Add the public.ecr.aws/aws-observability/aws-otel-collector:latest container to your ECS task definition with the command ["--config=/etc/ecs/container-insights/otel-task-metrics-config.yaml"]. Set four environment variables on your MCP server container: OTEL_AWS_APPLICATION_SIGNALS_ENABLED=true, OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4316, OTEL_RESOURCE_ATTRIBUTES=service.name=mcp-server,deployment.environment=production, and NODE_OPTIONS=--require @aws/aws-distro-opentelemetry-node-autoinstrumentation/register. Attach the Application Signals IAM policy to the ECS task role. See the overview guide for the full API surface and SLO guide for reliability tracking.
ADOT sidecar container for ECS
The AWS Distro for OpenTelemetry (ADOT) collector runs as a sidecar container in the same ECS task as your MCP server. Because both containers share the same network namespace in ECS (they communicate over localhost), the MCP server's OTLP exporter can reach the collector without any network configuration.
The ADOT collector image for Application Signals is public.ecr.aws/aws-observability/aws-otel-collector:latest. When started with the Application Signals config flag, it runs three pipeline components:
- OTLP receiver — listens on port 4316 (gRPC) and 4318 (HTTP) for telemetry from the MCP server process
- X-Ray exporter — exports trace spans to AWS X-Ray for distributed tracing and service map population
- CloudWatch EMF exporter — converts span metrics to CloudWatch Embedded Metric Format and publishes to the
AWS/ApplicationSignalsnamespace
The Application Signals-specific collector configuration is bundled inside the ADOT image at /etc/ecs/container-insights/otel-task-metrics-config.yaml. Specifying this path in the container command activates the Application Signals pipeline. You do not need to provide or mount a custom collector config.
Task definition JSON
The following task definition configures a Node.js MCP server with Application Signals enabled. The ADOT sidecar must start before the MCP server container begins serving traffic — use the dependsOn field to enforce ordering:
{
"family": "mcp-server-task",
"networkMode": "awsvpc",
"requiresCompatibilities": ["FARGATE"],
"cpu": "1024",
"memory": "2048",
"executionRoleArn": "arn:aws:iam::ACCOUNT_ID:role/mcp-server-execution-role",
"taskRoleArn": "arn:aws:iam::ACCOUNT_ID:role/mcp-server-task-role",
"containerDefinitions": [
{
"name": "mcp-server",
"image": "ACCOUNT_ID.dkr.ecr.REGION.amazonaws.com/mcp-server:latest",
"portMappings": [
{ "containerPort": 3000, "protocol": "tcp" }
],
"environment": [
{
"name": "NODE_OPTIONS",
"value": "--require @aws/aws-distro-opentelemetry-node-autoinstrumentation/register"
},
{
"name": "OTEL_AWS_APPLICATION_SIGNALS_ENABLED",
"value": "true"
},
{
"name": "OTEL_EXPORTER_OTLP_ENDPOINT",
"value": "http://localhost:4316"
},
{
"name": "OTEL_RESOURCE_ATTRIBUTES",
"value": "service.name=mcp-server,deployment.environment=production,aws.log.group.names=/ecs/mcp-server"
},
{
"name": "OTEL_PROPAGATORS",
"value": "xray,tracecontext,b3"
}
],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/ecs/mcp-server",
"awslogs-region": "us-east-1",
"awslogs-stream-prefix": "mcp-server"
}
},
"dependsOn": [
{
"containerName": "aws-otel-collector",
"condition": "START"
}
],
"essential": true
},
{
"name": "aws-otel-collector",
"image": "public.ecr.aws/aws-observability/aws-otel-collector:latest",
"command": [
"--config=/etc/ecs/container-insights/otel-task-metrics-config.yaml"
],
"environment": [
{
"name": "AOT_CONFIG_CONTENT",
"value": ""
}
],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/ecs/mcp-server",
"awslogs-region": "us-east-1",
"awslogs-stream-prefix": "aws-otel-collector"
}
},
"essential": false,
"healthCheck": {
"command": ["/healthcheck"],
"interval": 5,
"timeout": 6,
"retries": 5,
"startPeriod": 1
}
}
]
}
Key points in this configuration:
- The
dependsOnconditionSTARTensures the ADOT collector container is started (but not necessarily healthy) before the MCP server container starts. If you need a stronger guarantee (collector fully healthy before traffic flows), change the condition toHEALTHYand ensure the collector health check passes before the MCP server begins accepting connections. - The collector is marked
"essential": false. If the collector crashes, the MCP server continues serving requests — telemetry is lost but the service stays up. If you prefer to fail the entire task when telemetry breaks (e.g., for compliance reasons), set"essential": true. - The
aws.log.group.namesattribute inOTEL_RESOURCE_ATTRIBUTESlinks your CloudWatch Logs output to Application Signals, enabling log correlation in the console.
Registering the task definition via SDK
Register and deploy the task definition programmatically using the ECS SDK — this fits into CI/CD pipelines and Infrastructure as Code tooling:
import { ECSClient, RegisterTaskDefinitionCommand, UpdateServiceCommand } from "@aws-sdk/client-ecs";
import { readFileSync } from "fs";
const ecs = new ECSClient({ region: process.env.AWS_REGION });
async function deployMcpServerWithApplicationSignals(
clusterName: string,
serviceName: string,
imageTag: string
) {
const accountId = process.env.AWS_ACCOUNT_ID;
const region = process.env.AWS_REGION;
// Register new task definition revision
const taskDef = await ecs.send(new RegisterTaskDefinitionCommand({
family: "mcp-server-task",
networkMode: "awsvpc",
requiresCompatibilities: ["FARGATE"],
cpu: "1024",
memory: "2048",
executionRoleArn: `arn:aws:iam::${accountId}:role/mcp-server-execution-role`,
taskRoleArn: `arn:aws:iam::${accountId}:role/mcp-server-task-role`,
containerDefinitions: [
{
name: "mcp-server",
image: `${accountId}.dkr.ecr.${region}.amazonaws.com/mcp-server:${imageTag}`,
portMappings: [{ containerPort: 3000, protocol: "tcp" }],
environment: [
{ name: "NODE_OPTIONS", value: "--require @aws/aws-distro-opentelemetry-node-autoinstrumentation/register" },
{ name: "OTEL_AWS_APPLICATION_SIGNALS_ENABLED", value: "true" },
{ name: "OTEL_EXPORTER_OTLP_ENDPOINT", value: "http://localhost:4316" },
{ name: "OTEL_RESOURCE_ATTRIBUTES", value: `service.name=mcp-server,deployment.environment=production,aws.log.group.names=/ecs/mcp-server` },
{ name: "OTEL_PROPAGATORS", value: "xray,tracecontext,b3" }
],
logConfiguration: {
logDriver: "awslogs",
options: {
"awslogs-group": "/ecs/mcp-server",
"awslogs-region": region!,
"awslogs-stream-prefix": "mcp-server"
}
},
dependsOn: [{ containerName: "aws-otel-collector", condition: "START" }],
essential: true
},
{
name: "aws-otel-collector",
image: "public.ecr.aws/aws-observability/aws-otel-collector:latest",
command: ["--config=/etc/ecs/container-insights/otel-task-metrics-config.yaml"],
logConfiguration: {
logDriver: "awslogs",
options: {
"awslogs-group": "/ecs/mcp-server",
"awslogs-region": region!,
"awslogs-stream-prefix": "aws-otel-collector"
}
},
essential: false,
healthCheck: {
command: ["/healthcheck"],
interval: 5,
timeout: 6,
retries: 5,
startPeriod: 1
}
}
]
}));
const taskDefArn = taskDef.taskDefinition?.taskDefinitionArn;
console.log("Registered task definition:", taskDefArn);
// Update ECS service to use new task definition
await ecs.send(new UpdateServiceCommand({
cluster: clusterName,
service: serviceName,
taskDefinition: taskDefArn,
forceNewDeployment: true
}));
console.log(`Updated service ${serviceName} to task definition ${taskDefArn}`);
return taskDefArn;
}
IAM task role configuration
The ECS task role (attached to the task, not the execution role used for ECR image pulls) must include permissions for the ADOT collector to export telemetry and for Application Signals to synthesize metrics. Create this role in IAM and attach the following policy:
import { IAMClient, PutRolePolicyCommand } from "@aws-sdk/client-iam";
const iam = new IAMClient({ region: "us-east-1" });
await iam.send(new PutRolePolicyCommand({
RoleName: "mcp-server-task-role",
PolicyName: "ApplicationSignalsPolicy",
PolicyDocument: JSON.stringify({
Version: "2012-10-17",
Statement: [
{
Effect: "Allow",
Action: [
"xray:PutTraceSegments",
"xray:PutTelemetryRecords",
"xray:GetSamplingRules",
"xray:GetSamplingTargets",
"xray:GetSamplingStatisticSummaries"
],
Resource: "*"
},
{
Effect: "Allow",
Action: [
"cloudwatch:PutMetricData"
],
Resource: "*",
Condition: {
StringEquals: {
"cloudwatch:namespace": ["AWS/ApplicationSignals", "ECS/ContainerInsights"]
}
}
},
{
Effect: "Allow",
Action: [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents",
"logs:DescribeLogGroups",
"logs:DescribeLogStreams"
],
Resource: "arn:aws:logs:*:*:log-group:/ecs/*"
},
{
Effect: "Allow",
Action: [
"application-signals:ListServices",
"application-signals:GetService",
"application-signals:ListServiceOperations",
"application-signals:ListServiceDependencies"
],
Resource: "*"
}
]
})
}));
Restrict the cloudwatch:PutMetricData permission to the specific namespaces the ADOT collector writes to. This follows the least-privilege principle — the task role cannot write arbitrary CloudWatch metrics, only the Application Signals and Container Insights namespaces.
The execution role (used by ECS to pull images and write task logs) needs the standard AmazonECSTaskExecutionRolePolicy managed policy. It does not need Application Signals permissions — those are needed at task runtime, not at startup. Keep the execution role and task role separate.
Environment variable reference
The following environment variables control Application Signals behavior on the MCP server container. All are set at the container level in the task definition:
| Variable | Value | Purpose |
|---|---|---|
NODE_OPTIONS |
--require @aws/aws-distro-opentelemetry-node-autoinstrumentation/register |
Loads the ADOT auto-instrumentation hook before any application code, patching http, AWS SDK, and common DB clients |
OTEL_AWS_APPLICATION_SIGNALS_ENABLED |
true |
Activates the Application Signals pipeline in both the Node.js SDK and the ADOT collector — required for CloudWatch metric synthesis |
OTEL_EXPORTER_OTLP_ENDPOINT |
http://localhost:4316 |
OTLP gRPC endpoint where the Node.js SDK sends spans — points to the ADOT collector sidecar on the shared task network |
OTEL_RESOURCE_ATTRIBUTES |
service.name=mcp-server,deployment.environment=production |
Attributes that identify this service in Application Signals; service.name and deployment.environment become the SLO key attributes |
OTEL_PROPAGATORS |
xray,tracecontext,b3 |
Trace context propagation formats; xray is required for X-Ray trace correlation; tracecontext handles W3C standard propagation from upstream services |
OTEL_TRACES_SAMPLER |
xray (default) |
Use X-Ray central sampling rules for trace sampling; avoids hard-coded sample rates and allows dynamic sampling rule updates from the console |
OTEL_AWS_APPLICATION_SIGNALS_EXPORTER_ENDPOINT |
http://localhost:4316 |
Endpoint the Application Signals metrics exporter in the Node.js SDK sends metrics to; defaults to the OTLP endpoint but can be overridden |
Package installation and Dockerfile changes
The only change to your MCP server Docker image is installing the ADOT auto-instrumentation package. Add it as a production dependency:
# In your package.json:
# "dependencies": {
# "@aws/aws-distro-opentelemetry-node-autoinstrumentation": "^0.3.0",
# "@modelcontextprotocol/sdk": "^1.9.0",
# ...
# }
# Dockerfile — no changes needed to the CMD or ENTRYPOINT:
FROM node:22-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --omit=dev
COPY . .
# NODE_OPTIONS is set via ECS environment variables, not here.
# Do NOT bake OTEL settings into the image — they vary by environment.
CMD ["node", "dist/server.js"]
Avoid baking NODE_OPTIONS or any OTEL environment variables into the Docker image. These values differ between production and staging — using ECS environment variable overrides keeps the image environment-agnostic.
The @aws/aws-distro-opentelemetry-node-autoinstrumentation package adds approximately 15MB to the production bundle and around 50-150ms to Node.js cold start time. If cold start latency is critical (e.g., for Lambda-based MCP servers), see the Lambda guide for the layer-based approach that avoids installing the package in the deployment artifact.
Verifying Application Signals is working
After deploying the updated task definition, verify that Application Signals is receiving data:
import {
ApplicationSignalsClient,
ListServicesCommand
} from "@aws-sdk/client-application-signals";
async function verifyApplicationSignalsActive(serviceName: string) {
const client = new ApplicationSignalsClient({ region: process.env.AWS_REGION });
const now = new Date();
const fiveMinutesAgo = new Date(now.getTime() - 5 * 60 * 1000);
const response = await client.send(new ListServicesCommand({
StartTime: fiveMinutesAgo,
EndTime: now
}));
const found = response.ServiceSummaries?.some(s =>
s.KeyAttributes?.["Name"] === serviceName
);
if (found) {
console.log(`✓ Service '${serviceName}' is emitting Application Signals data`);
} else {
console.log(`✗ Service '${serviceName}' not yet visible — wait for traffic and retry`);
console.log("Available services:", response.ServiceSummaries?.map(s => s.KeyAttributes?.["Name"]));
}
return found;
}
// Also check ADOT collector logs for export errors:
// aws logs tail /ecs/mcp-server --filter-pattern "aws-otel-collector"
// Look for: "Everything is ready. Begin running and processing data."
// Errors to watch: "Failed to export" — usually a permissions issue
If the service does not appear within 5 minutes of deployment, check the ADOT collector container logs first. Common startup issues are IAM permission denials (X-Ray and CloudWatch write blocked), misconfigured OTLP endpoint (MCP server sending to wrong port), or the auto-instrumentation package not loading (check that NODE_OPTIONS is correctly set in the task definition and not being overridden by the container's CMD).
Common ECS deployment issues and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
| ADOT collector container exits at startup | Wrong config path in the command field, or image is too old to include the Application Signals config |
Use the exact path --config=/etc/ecs/container-insights/otel-task-metrics-config.yaml; use aws-otel-collector:latest or a version tag ≥ v0.38.0 which includes Application Signals support |
| MCP server starts before ADOT collector is ready, then auto-instrumentation fails to connect | dependsOn condition set to START but collector needs more time to initialize |
Change dependsOn condition to HEALTHY and ensure the ADOT collector health check is configured; alternatively, the Node.js OTLP exporter retries on connection failure — telemetry from the first few seconds may be lost but the connection eventually succeeds |
| NODE_OPTIONS not taking effect — no OTEL initialization logs at startup | NODE_OPTIONS overridden by a value in the Docker image or the container CMD uses a shell wrapper that resets environment |
Check the ECS task definition effective environment (AWS console → task → containers → environment); ensure NODE_OPTIONS is listed; if the Dockerfile sets ENV NODE_OPTIONS, the task definition value takes precedence — verify there are no conflicts |
| X-Ray traces appear but no Application Signals metrics in CloudWatch | OTEL_AWS_APPLICATION_SIGNALS_ENABLED set to "True" (capitalized) or 1 instead of "true" |
The value must be the lowercase string "true" — the ADOT SDK checks for this exact string; also verify cloudwatch:PutMetricData is allowed in the task role for the AWS/ApplicationSignals namespace |
| High memory usage after enabling Application Signals | The ADOT collector sidecar's default memory limit is 256MB but it buffers spans in memory under high load | Set a memory reservation on the collector container ("memoryReservation": 128); if the MCP server generates very high trace volume, consider enabling X-Ray sampling rules to reduce trace output — Application Signals metrics do not require every trace, only a statistically representative sample |
Application Signals arc — related guides
This guide covers ECS-specific deployment for Application Signals. The arc also includes:
- AWS Application Signals overview — auto-instrumentation model, service topology, IAM permissions, and the core SDK APIs for querying service health
- Service Level Objectives with Application Signals — SLO creation, error budgets, burn-rate alarms, and per-tool SLO patterns
- Application Signals for Lambda-based MCP servers — Lambda layer ARN, handler wrapping, cold start tradeoffs, and function URL patterns
Application Signals tracks reliability from the inside. For external uptime monitoring — detecting when your ECS-hosted MCP server is unreachable from outside your VPC — AliveMCP provides active probe-based monitoring with Slack and email alerting.