Skip to content

Auth Failing while adding MCP server in DevOps Agent

0

While attempting to connect my MCP server URL to the AWS DevOps Agent, I encounter the following error:

“An error occurred while trying to access resources from the external service provider. Could not complete request to provider.”

To troubleshoot, I inspected the incoming requests on my MCP server. It appears that requests originating from the AWS DevOps Agent are not including the expected authorization headers. In contrast, when invoking the same endpoint using tools such as curl or other agents (e.g., VS Code GPT/Claude integrations), the headers are correctly included and the requests succeed.

This suggests that the AWS DevOps Agent may not be properly forwarding or attaching the configured authentication headers when making requests to external MCP endpoints.

23 April 2026, 14:50
=== INCOMING HEADERS ===
devops-mcp
23 April 2026, 14:50
x-forwarded-for: 122.183.54.4
devops-mcp
23 April 2026, 14:50
x-forwarded-proto: https
devops-mcp
23 April 2026, 14:50
x-forwarded-port: 443
devops-mcp
23 April 2026, 14:50
host: devopsmcp.xyz.ai
devops-mcp
23 April 2026, 14:50
x-amzn-trace-id: Root=1-69e9e45f-4e1238b66f8686763e298e00
devops-mcp
23 April 2026, 14:50
content-length: 272
devops-mcp
23 April 2026, 14:50
authorization: Bearer devops123
devops-mcp
23 April 2026, 14:50
content-type: application/json
devops-mcp
23 April 2026, 14:50
accept: text/event-stream, application/json
devops-mcp
23 April 2026, 14:50
user-agent: Visual Studio Code/1.117.0
devops-mcp
23 April 2026, 14:50
accept-language: *
devops-mcp
23 April 2026, 14:50
sec-fetch-mode: cors
devops-mcp
23 April 2026, 14:50
accept-encoding: br, gzip, deflate
devops-mcp
23 April 2026, 14:50
========================
devops-mcp
23 April 2026, 14:50
INFO: 172.31.47.219:16698 - "POST /mcp HTTP/1.1" 200 OK

AND trying to connect with AWS devops agent

=== INCOMING HEADERS ===
devops-mcp
23 April 2026, 14:24
x-forwarded-for: 3.83.156.16
devops-mcp
23 April 2026, 14:24
x-forwarded-proto: https
devops-mcp
23 April 2026, 14:24
x-forwarded-port: 443
devops-mcp
23 April 2026, 14:24
host: devopsmcp.xyz.ai
devops-mcp
23 April 2026, 14:24
x-amzn-trace-id: Root=1-69e9de2d-335cbe845c792fe111495b03
devops-mcp
23 April 2026, 14:24
content-length: 206
devops-mcp
23 April 2026, 14:24
content-type: application/json
devops-mcp
23 April 2026, 14:24
accept: application/json, text/event-stream
devops-mcp
23 April 2026, 14:24
accept-language: *
devops-mcp
23 April 2026, 14:24
sec-fetch-mode: cors
devops-mcp
23 April 2026, 14:24
user-agent: node
devops-mcp
23 April 2026, 14:24
accept-encoding: br, gzip, deflate
devops-mcp
23 April 2026, 14:24
========================
devops-mcp
23 April 2026, 14:24
INFO: 172.31.13.119:19992 - "POST /mcp HTTP/1.1" 401 Unauthorized

I would appreciate guidance on:

Whether there are known limitations or configuration requirements for header forwarding in AWS DevOps Agent Any specific setup needed to ensure authorization headers (e.g., Bearer tokens or API keys) are included in outgoing requests Recommended debugging steps or logs to further isolate the issue

5 Answers
3

The logs you have posted, confirm that the AWS DevOps Agent is failing to forward the Authorization header.

While the VS Code request includes authorization: Bearer devops123, the AWS Agent request is missing it entirely, resulting in the 401 Unauthorized error.

To resolve this, check the following in your AWS DevOps Agent configuration:

  • Header Sanitization: AWS managed services often strip the standard Authorization header for security. Try using a custom header instead (e.g., X-API-Key: your_token) and update your MCP server to accept it.
  • Secret Mapping: Ensure the token is not just defined as a variable, but explicitly mapped to the outgoing request headers. In many AWS environments, you must reference a Secret Manager ARN rather than hardcoding the string.
  • Case Sensitivity: Ensure the header is defined as Authorization (capitalized). Some AWS proxies filter non-standard casing.

Try the following debugging

  • Redirect to RequestBin: Point the AWS Agent URL to a tool like webhook.site to verify exactly which headers are leaving the AWS environment.
  • IAM Policies: Confirm the Agent's IAM Role has the secretsmanager:GetSecretValue permission if the token is stored in AWS Secrets Manager.
EXPERT
answered 25 days ago
  • Hi thank you for the reply ,

    I have tried the method with "X-API-Key" in headers , still after sending it through Devops Agent , it is missing.

    23 April 2026, 16:40
    === INCOMING HEADERS ===
    devops-mcp
    23 April 2026, 16:40
    x-forwarded-for: 44.203.91.168
    devops-mcp
    23 April 2026, 16:40
    x-forwarded-proto: https
    devops-mcp
    23 April 2026, 16:40
    x-forwarded-port: 443
    devops-mcp
    23 April 2026, 16:40
    host: devopsmcp.xyz.ai
    devops-mcp
    23 April 2026, 16:40
    x-amzn-trace-id: Root=1-69e9fe2a-468b11044942249b2c14419a
    devops-mcp
    23 April 2026, 16:40
    content-length: 206
    devops-mcp
    23 April 2026, 16:40
    content-type: application/json
    devops-mcp
    23 April 2026, 16:40
    accept: application/json, text/event-stream
    devops-mcp
    23 April 2026, 16:40
    accept-language: *
    devops-mcp
    23 April 2026, 16:40
    sec-fetch-mode: cors
    devops-mcp
    23 April 2026, 16:40
    user-agent: node
    devops-mcp
    23 April 2026, 16:40
    accept-encoding: br, gzip, deflate
    devops-mcp
    23 April 2026, 16:40
    ========================
    devops-mcp
    23 April 2026, 16:40
    INFO: 172.31.47.219:28610 - "POST /mcp HTTP/1.1" 401 Unauthorized
    
2

The fact that even a custom X-API-Key header is being stripped confirms that the AWS DevOps Agent (which appears to be running a node environment based on your logs) is likely using a strict egress/allow-list policy or a sanitization middleware that drops any non-standard headers.

Since standard header injection is failing, I recommend trying these three specific approaches:

1. Authentication via Query Parameter (Verification Step)

As a diagnostic test, try appending the token directly to the URL in the Agent configuration: https://devopsmcp.xyz.ai/mcp?token=devops123

If the request succeeds, it confirms the Agent is stripping the header block but leaving the URI intact. You can then decide if you want to support a URL-based fallback on your MCP server (though keep in mind the security implications regarding log visibility).

2. Check Origin Request Policies (If using CloudFront/ALB)

If your MCP server is sitting behind an AWS Application Load Balancer (ALB) or CloudFront, the headers might be stripped there before reaching your server.

  • Ensure you have an Origin Request Policy enabled that allows "All Viewer Headers" or explicitly includes your custom headers.
  • AWS often defaults to a "Managed-CORS-CustomOrigin" policy which may drop headers it doesn't recognize.

3. Switch to IAM-based Authentication (SigV4)

Instead of relying on a Bearer token, which the Agent clearly struggles to forward, you could leverage the Agent's own IAM role.

  • Configure your MCP server (or the entry point like API Gateway/ALB) to require AWS Signature Version 4 (SigV4).
  • The Agent will then sign the request using its execution role, removing the need for a manually injected Authorization header.

Quick Question: What is the underlying infrastructure hosting your MCP server (e.g., Lambda, EC2, or an ECS container behind an ALB)? This would help narrow down exactly where the stripping is occurring.

EXPERT
answered 25 days ago
1

Ok, Check the "Drop invalid header fields" setting on the ALB first. If that is already off, the AWS DevOps Agent (Node.js) is likely not correctly appending the headers to the request object before it hits the wire. Switching to Query Parameters for a quick fix or SigV4 for a long-term secure fix is advised.

However, fixing Auth Header Stripping on AWS ALB/ECS

Given that your MCP server is hosted on ECS behind an ALB, the fact that even custom headers like X-API-Key are being dropped suggests a configuration mismatch at the load balancer level or the way the Agent interacts with the target group.

1. Disable "Drop Invalid Header Fields" on the ALB

By default, AWS Application Load Balancers can be aggressive about what they consider "invalid" headers. If the AWS DevOps Agent is sending the header in a format the ALB dislikes (e.g., underscores instead of hyphens, or specific casing), the ALB will silently drop them.

  • Action: Go to the EC2 Console > Load Balancers > Select your ALB.
  • Settings: Ensure "Drop invalid header fields" is turned OFF. Even if your header looks valid, turning this off is a critical troubleshooting step for proxy-passed requests.

2. Verify ALB "Origin Request" behavior

Unlike CloudFront, ALBs don't have "Origin Request Policies," but they do have specific behavior regarding the Authorization header. If the ALB is configured with OIDC/Cognito Authentication at the listener level, it will often strip or overwrite the incoming Authorization header before it reaches the ECS container.

  • Action: Check if there are any "Authenticate" rules on your ALB Listener. If so, move the authentication logic entirely to your MCP server or use a custom header name that does not conflict with AWS reserved words.

3. Use the "X-Forwarded-*" Verification

In your logs, we see x-forwarded-for and x-amzn-trace-id. This proves the ALB is receiving the request. If the Authorization header is present in a curl request but missing from the node (DevOps Agent) request reaching the same ALB, the Agent's environment is likely failing to inject the header into the outbound HTTP object.

  • Workaround: As a final resort for the DevOps Agent, try passing the token via the User-Agent or a Query Parameter (e.g., /mcp?api_key=...). If your ECS logs show the query parameter arriving but the header missing, the problem is 100% the Agent's header-injection middleware.

4. Recommended Infrastructure Change: SigV4

Since both the Agent and the MCP server (ECS) are within the AWS ecosystem, the most robust "AWS-native" way to fix this is to:

  1. Enable AWS Signature Version 4 (SigV4) on the ALB/Target Group.

  2. Grant the DevOps Agent's IAM Role permission to invoke the ALB.

  3. This eliminates the need for manual Bearer tokens, which are clearly being stripped by the Agent's Node.js runtime environment.

EXPERT
answered 23 days ago
  • The devops agent authentication method cannot be edited or removed as it is enforced by the portal itself.

1

Hello Florian,

Thanks for the reply, I am from the same team as Cedric,

We have MCP server on ECS container behind an ALB

answered 24 days ago
EXPERT
reviewed 23 days ago
0

Hi , I have tried all the mentioned methods, still getting the same logs with no x-api-key (or any other auth key) being attached by the AWS Devops Agent

answered 19 days ago
EXPERT
reviewed 18 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.