From Local MCP Server to AWS Deployment in Two Commands
Blog

From Local MCP Server to AWS Deployment in Two Commands

@
2026.01.26
·Service·by 이호민
#AWS#MCP#Deployment#Serverless#AgentCore

Key Points

  • 1This paper outlines a simple, two-CLI-command workflow for quickly deploying a local MCP server to production on AWS using Bedrock AgentCore Runtime.
  • 2AgentCore Runtime provides a serverless hosting environment that maintains session state and strict session isolation, specifically designed for agent workloads.
  • 3The deployment process leverages the AgentCore Starter Toolkit for automated containerization, IAM role setup, and cloud-based builds, enabling easy integration with AI agents via IAM-based authentication.

The paper presents a simplified methodology for deploying Message Control Protocol (MCP) servers on AWS using Bedrock AgentCore Runtime. The core problem addressed is the need for a serverless hosting environment that can maintain session state across multiple requests while ensuring strict isolation between individual sessions, a common requirement for agentic workloads. Traditional serverless options like AWS Lambda are stateless, necessitating external session management, while container services like Amazon ECS lack built-in session isolation, potentially leading to costly "one container per session" deployments.

The proposed solution leverages the Bedrock AgentCore Runtime, which combines serverless cost-efficiency with stateful session management and per-session isolation. The workflow centers around the agentcore Command Line Interface (CLI) tool, provided by the Bedrock AgentCore Starter Toolkit, to automate the entire deployment process.

The detailed methodology involves the following steps:

  1. MCP Server Creation: A simple MCP server is developed using FastMCP, a Python library offering a decorator-based API. Key configurations for cloud deployment include:
    • Binding the server to all network interfaces: FastMCP(host="0.0.0.0",...)FastMCP(host="0.0.0.0", ...).
    • Enabling HTTP-based transport for stateless request handling: statelesshttp=Truestateless_http=True.
    • Registering tools using the @mcp.tool() decorator, where docstrings define tool descriptions and type hints define input schemas.
    • Running the server with the standard MCP transport for HTTP-based deployments: mcp.run(transport="streamableβˆ’http")mcp.run(transport="streamable-http").
  1. Local Testing: Before deployment, the server is tested locally. The uv run server.py command initiates the server (which uses Uvicorn internally). MCP requests are then simulated using curl, sending JSON-RPC 2.0 payloads over HTTP. This includes invoking the tools/list method to discover available tools and tools/call to execute a specific tool (e.g., roll_d20) with structured arguments.
  1. AgentCore Runtime Configuration: The Bedrock AgentCore Starter Toolkit is installed and used to configure the deployment. The uv run agentcore configure command is central to this step, automating the generation of necessary infrastructure code. Key parameters for configuration include:
    • --entrypoint <path_to_server_file.py>: Specifies the main Python file to be executed within the container.
    • --requirements-file <path_to_pyproject.toml>: Directs the toolkit to the project's dependency file.
    • --disable-memory --disable-otel: Optional flags to simplify the deployment by disabling session memory persistence and OpenTelemetry-based observability for the current example.
    • --non-interactive: Automates prompts for non-interactive execution.
    • --deployment-type container: Instructs the toolkit to package the server as a container image built via AWS CodeBuild, eliminating the need for local Docker installation.
    • --protocol MCP: Identifies the deployed application as an MCP server.
    • --name <server_name>: Assigns a logical name to the MCP server.
This step generates configuration files such as .bedrock_agentcore.yaml and a Dockerfile for containerization.

  1. Deployment to AgentCore Runtime: The deployment is initiated with uvrunagentcorelaunchβˆ’βˆ’agent<servername>uv run agentcore launch --agent <server_name>. This single command orchestrates the entire cloud-side setup, which involves:
    • ECR Repository Creation: An Amazon Elastic Container Registry (ECR) repository is automatically created to store the container image.
    • IAM Role Setup: Required AWS Identity and Access Management (IAM) roles (Execution Role for runtime permissions and CodeBuild Role for build permissions) are configured.
    • Container Build: AWS CodeBuild executes the container build process in the cloud, utilizing the generated Dockerfile, installing dependencies, and producing an ARM64-compatible image which is then pushed to ECR.
    • Runtime Deployment: Bedrock AgentCore Runtime provisions an instance using the built container image.
Upon successful deployment, an Agent ARN (e.g., arn:aws:bedrock-agentcore:{region}:{account-id}:runtime/{runtime-id}) is provided, which uniquely identifies the deployed server.

  1. Testing the Deployed Server: The deployed server is tested using the AWS CLI's aws bedrock-agentcore invoke-agent-runtime command. This command, similar to local curl tests, sends JSON-RPC payloads to the server's ARN, demonstrating that the MCP protocol remains consistent regardless of deployment environment. IAM credentials handle authentication automatically.
  1. Agent Integration (Optional): The paper demonstrates connecting an AI agent to the deployed server using an IAM-compatible MCP client (mcp-proxy-for-aws) with the Strands Agents SDK. This highlights that any agent framework can integrate with the deployed MCP server via AWS IAM authentication, bypassing the need for OAuth. The client factory pattern is used to construct the MCP client, dynamically building the endpoint URL based on the Agent ARN.
  1. Cleanup: To prevent ongoing costs, the deployed resources are easily removed using uvrunagentcoredestroyβˆ’βˆ’agent<servername>uv run agentcore destroy --agent <server_name>, which meticulously tears down the AgentCore runtime, ECR repository, CodeBuild project, IAM roles, and S3 artifacts created during deployment.

In essence, the paper demonstrates that Bedrock AgentCore Runtime provides a serverless, stateful, and isolated execution environment ideal for MCP servers supporting agent workloads, significantly simplifying deployment through an automated CLI-driven process and leveraging IAM for secure integration.