feat: add FastMCP Lambda template for MCP server scaffolding#420
Closed
aidandaly24 wants to merge 4 commits intoaws:feat/gateway-integrationfrom
Closed
feat: add FastMCP Lambda template for MCP server scaffolding#420aidandaly24 wants to merge 4 commits intoaws:feat/gateway-integrationfrom
aidandaly24 wants to merge 4 commits intoaws:feat/gateway-integrationfrom
Conversation
tejaskash
reviewed
Feb 24, 2026
9421691 to
6ea432f
Compare
notgitika
approved these changes
Feb 24, 2026
e30a275 to
80e1df6
Compare
80e1df6 to
b1f312d
Compare
Add python-fastmcp-lambda template for scaffolding MCP servers that run on AWS Lambda with function URLs. Uses FastMCP for tool definitions and Mangum as the ASGI-to-Lambda adapter. Template includes sample HTTP tools (lookup_ip, get_random_user, fetch_post) matching the existing python/ template patterns. Updates GatewayTargetRenderer to select this template when the compute host is Lambda.
The CLI writes handler: 'handler.lambda_handler' in compute config. The template must export lambda_handler, not handler.
…r Lambda compatibility
bee7adc to
9c3817b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add a FastMCP Lambda template for scaffolding MCP servers that run on AWS Lambda with function URLs.
Currently, the
python-lambdatemplate uses a raw stdlib handler designed for Lambda gateway targets. This PR adds a newpython-fastmcp-lambdatemplate that uses the FastMCP library — a proper MCP server that speaks MCP protocol and is designed to sit behind an AgentCore gateway'smcpServertarget type.The template uses AWS Lambda Web Adapter with uvicorn to run FastMCP's Streamable HTTP app natively on Lambda. This replaces the original Mangum-based approach, which couldn't handle SSE/streaming responses required by the MCP Streamable HTTP protocol. The Lambda Web Adapter runs uvicorn as a sidecar process, and a bootstrap script (
run.sh) starts the server on the port specified by the adapter.Key configuration:
FastMCP(stateless_http=True, host="0.0.0.0")— stateless mode for Lambda, accept any Host header from function URLserver.py— FastAPI wrapper that mountsstreamable_http_app()with proper lifespan managementrun.sh— bootstrap script that runsuvicorn server:appon the Lambda Web Adapter portpyproject.toml— dependencies: mcp >= 1.18.0, fastapi, uvicorn, httpx (no mangum)The template includes sample HTTP tools (lookup_ip, get_random_user, fetch_post) for consistency with existing templates.
Changes:
src/assets/mcp/python-fastmcp-lambda/template directory (handler.py, server.py, run.sh, pyproject.toml, README.md)GatewayTargetRenderer.tsto select the new template when compute host is LambdaThe corresponding CDK changes (Lambda Web Adapter layer,
AWS_LAMBDA_EXEC_WRAPPER,PORTenv var,run.shhandler) are in CDK PR #53.This template is used by the scaffolding flow added in a subsequent PR (Task 14).
Related Issue
Part of the MCP Gateway Phase 1 integration (gateway-integration branch). Task 13.
Type of Change
Testing
How have you tested the change?
npm run test:unitandnpm run test:integnpm run typechecknpm run lintsrc/assets/, I rannpm run test:update-snapshotsand committed the updated snapshotsEnd-to-end tested: scaffolded Lambda MCP server deployed via gateway, agent successfully invoked tools through the gateway.
Checklist