
Run a remote MCP server as an AWS Lambda Web Function that calls an existing HTTP API on a second Web Function, protected with IamAuth and SigV4.
/mcp. The second is a plain HTTP API with no MCP code, standing in for a service you already run.IamAuth auth type, so Lambda only forwards requests signed with AWS Signature Version 4 by a principal that has lambda:InvokeWebFunctionEndpoint. The MCP server signs each request with its own execution role, whose policy allows invoking only that endpoint. Lambda removes the Authorization header after validating the signature, so the API code does no authentication of its own.get_current_time runs in the MCP server. run_cpu_work calls the API, which runs 1-20 seconds of SHA-256 hashing and streams a JSON line every second. The MCP server relays each line to the MCP client as a progress notification over a Server-Sent Events stream, and a client cancel closes the backend connection and stops the work.ApplicationManaged auth type, which makes it public. Add authentication to it before using this pattern outside a demo.git clone https://github.com/aws-samples/serverless-patterns/cd serverless-patterns/lambda-web-mcp-server/nodejs/awscliSet a name prefix, <code>export STACK=lambda-web-mcp-server</code>, then deploy the API: <code>aws lambda-web deploy --name $STACK-cpu-api --code cpu-api --timeout-seconds 60</code>.Switch its endpoint to IamAuth: <code>aws lambda-web update-web-function-endpoint --function-name $STACK-cpu-api --endpoint-name dev --auth-type IamAuth</code>.See the GitHub repo for creating the MCP server's execution role and deploying the MCP server.aws lambda-web delete-web-function --function-name $STACK-mcp and aws lambda-web delete-web-function --function-name $STACK-cpu-api.