Skip to content

AWS AgentCore Gateway MCP target issue

0

Hi,

I successfully deployed the stateless-mcp-on-lambda-nodejs (https://github.com/aws-samples/sample-serverless-mcp-servers/tree/main/stateless-mcp-on-lambda-nodejs) example to AWS Lambda, and the MCP server works as expected when tested with the MCP Inspector, Postman, and when added as tools to my agent.

However, when I try to configure it as a target in AWS AgentCore Gateway, I receive the following error:

Update Target operation failed for target-quick-start: Gateway target update failed or timed out: Failed to connect and fetch tools from the provided MCP target server. Please check the server endpoint or tool capability support. Unable to connect to the MCP server.

I also found out that having my own MCP server deployed in AgentCore Runtime cannot be used as a target in AgentCore Gateway. Not sure why, but I'm getting a generic error: Failed to connect and fetch tools from the provided MCP target server. Please check the server endpoint or tool capability support. Unable to connect to the MCP server. Please check the server

I’ve tried all the troubleshooting steps I could think of without success. Do you have any idea what might be causing this issue?

asked 10 months ago3.2K views

5 Answers
0

When configuring an MCP server as a target in AWS AgentCore Gateway, several factors could cause the connection error you're experiencing. Here are some key areas to check:

  1. URL Configuration: Ensure the URL for your Lambda-based MCP server is correctly encoded and accessible from the Gateway. The Gateway will use this exact URL to invoke the server.

  2. Protocol Version Support: Verify that your MCP server supports one of the required protocol versions - either "2025-06-18" or "2025-03-26". The Gateway requires the MCP server to have compatible tool capabilities.

  3. Authorization Configuration: Check if you've properly set up the authorization strategy. AgentCore Gateway supports two types:

  • NoAuth (not recommended)
  • OAuth2 (two-legged OAuth, which requires configuring the authorization provider in AgentCore Identity)
  1. IAM Permissions: Ensure the IAM role used for creating or updating the MCP server target has the necessary permissions.

  2. Network Access: Confirm that the Gateway can reach your Lambda-based MCP server. Network connectivity issues could prevent successful synchronization.

  3. Synchronization Process: The Gateway needs to synchronize with the MCP server to discover and catalog its tools. This process happens asynchronously and can take several minutes for large tool sets. You can monitor the target status through GetGatewayTarget to track synchronization progress.

If you've verified these aspects and still encounter issues, you might want to try explicit synchronization by making a PUT request to /gateways/{gatewayIdentifier}/synchronize with the target ID in the request body. This can help refresh the connection between your Gateway and the MCP server.
Sources
MCP servers targets - Amazon Bedrock AgentCore
Use the MCP Inspector - Amazon Bedrock AgentCore
Transform your MCP architecture: Unite MCP servers through AgentCore Gateway | Artificial Intelligence

answered 10 months ago

  • Hi,

    Thanks for the detailed response. I’ve verified all of the items you mentioned and the issue still persists.

0

Hi,

The AWS docs seem contradictory at first - they say "Authorization strategy: NoAuth or OAuth2" but also mention the Gateway needs auth. After digging into this, here's what I think is happening:

Two different authentication layers:

The issue might be your Lambda Function URL is likely set to AuthType: AWS_IAM, which requires SigV4 signing. AgentCore Gateway's MCP Server Target supports NoAuth or OAuth2 when calling your MCP server(here is your Lambda). But if switching to NONE fixes the connection issue than it might be Lambda IAM AuthType, Gateway needs something to authenticate.

test purpose only if you can try temporarily changing your Lambda Function URL to AuthType: NONE: than debug be precise.

Helpful resources:->

https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/gateway-core-concepts.html

https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/gateway-target-MCPservers.html

Best, Malini

answered 10 months ago

  • Hi Malini,

    Thank you for the answer.

    Unfortunately, my Lambda Function URL AuthType is already set to NONE. I forgot to mention that in the main question. I also tried to put AWS Gateway in front of my Lambda, but the result is the same.

    Regards, Igor

0

hi again,

As your lambda "Lambda Function URL AuthType is already set to NONE" looks like it needs IAM role. "select IAM role type for Lambda targets - it's the only supported and correct option for this target type."

Lambda targets in AgentCore Gateway, you must select IAM role type for the outbound authorization.

I think this is helpful. I used Q to clarify this gateway console Target Type confusion.

and Q answer so perfect, :-> here is the copy past

"When you select Lambda ARN as the target type, here's what you should use for Outbound Auth configurations:

For Lambda Targets: Use GATEWAY_IAM_ROLE You should select GATEWAY_IAM_ROLE as the credential provider type.

Here's why:

Lambda Function Invocation Requirements When AgentCore Gateway invokes your Lambda function (which is your MCP server), it needs AWS IAM permissions to call lambda:InvokeFunction. This is different from your Lambda function's internal URL AuthType.

Configuration Structure { "credentialProviderType": "GATEWAY_IAM_ROLE" }

Why GATEWAY_IAM_ROLE is Required AWS Service Integration: Lambda functions are AWS services that require IAM authentication for invocation Gateway Service Role: The AgentCore Gateway uses its service role to invoke your Lambda function AWS Signature V4: The gateway authenticates using AWS SigV4 to call your Lambda What Happens Behind the Scenes AgentCore Gateway → (uses IAM role) → Lambda:InvokeFunction → Your MCP Server Code

The flow is:

Gateway receives MCP request from agent Gateway uses its IAM service role credentials Gateway calls lambda:InvokeFunction with your Lambda ARN Your Lambda function (MCP server) processes the request Your Lambda returns JSON-RPC 2.0 response Gateway forwards response to agent Your Lambda Function's AuthType The fact that your Lambda function's URL AuthType is set to NONE is separate - that's for direct HTTP invocations of your Lambda function URL. But AgentCore Gateway doesn't use the function URL; it uses the Lambda service API (lambda:InvokeFunction), which always requires IAM authentication.

Required Permissions The Gateway's service role needs:

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "lambda:InvokeFunction", "Resource": "arn:aws:lambda:region:account:function:your-mcp-server" } ] }

So to answer your question directly: Use GATEWAY_IAM_ROLE for the outbound auth configuration when your target type is Lambda ARN. This is the standard and required approach for Lambda targets in AgentCore Gateway.

Best

Malini

answered 10 months ago

  • Hi Malini, thanks again for your response.

    I explicitly want to use the MCP server as a target for the gateway, not the Lambda itself. I’m currently using a Lambda Function URL only for PoC purposes — in production this will sit behind API Gateway (I already tried that setup as well, with the same result).

    I don’t believe this is a permissions issue. When I configure the Lambda Function URL as an MCP server target, I can see in CloudWatch that AgentCore Gateway is successfully invoking the Lambda.

    Specifically, I see:

    A POST /mcp with:

    { "jsonrpc": "2.0", "method": "initialize", "id": "eedac1e3-0", "params": { "protocolVersion": "2025-06-18", "capabilities": {}, "clientInfo": { "name": "genesis-gateway", "version": "1.0.0" } } }

    A second POST /mcp:

    { "jsonrpc": "2.0", "method": "notifications/initialized" }

    Then a GET /mcp request.

    My MCP server is fully stateless, and I suspect this is the issue — the GET /mcp call returns:

    res.writeHead(405).end(JSON.stringify({ jsonrpc: "2.0", error: { code: -32000, message: "Method not allowed." }, id: null, }));

    Since MCP servers running in Lambda cannot be stateful, this may indicate that AgentCore Gateway expects some level of session state, which feels contradictory to the guidance that MCP servers deployed via AgentCore Runtime must be stateless due to the wrapper AWS provides.

    At this point, I’m not sure what to try next.

0

hi, Yes! You've identified a fundamental architectural conflict. Excellent debugging work!

Hope an AWS expert see your intended architecture for Lambda-based MCP servers with AgentCore Gateway! best

answered 10 months ago

0

I ran into a similar issue:

  1. Created MCP server (A) in AgentCore Gateway with REST API and Lambda targets.
  2. Created another MCP server (B) in AgentCore gateway.
  3. Registered MCP Server A as a target on MCP server B and was seeing failures on create and also on sync.

After enabling the logs on MCP server A and attempting to sync again, I saw the requestBody from server A always included 'protocolVersion=2025-06-18', even though I created both servers to support version 2025-03-26.

I recreated server B but this time to support both versions: 2025-06-18 & 2025-03-26 and the connection was successful. MCP server A was able to call MCP server B.

answered 8 months 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.