Amazon Bedrock AgentCore is in preview release and is subject to change.
Transform an existing agent for AgentCore runtime
To make your existing AgentCore agent code compatible with Amazon Bedrock AgentCore Runtime, use the MCP server to guide the transformation process. For example, if you have a Strands AgentCore agent, the transformation helps convert it to be Amazon Bedrock AgentCore-compatible by updating imports, dependencies, and application structure.
Transform your agent code
The MCP server guides your MCP client to make the following changes to your AgentCore agent code:
Add runtime library imports
The MCP server adds the required AgentCore imports:
from bedrock_agentcore.runtime import BedrockAgentCoreApp
Update dependencies
The MCP server updates your requirements.txt
file:
bedrock-agentcore strands-agents
Initialize the AgentCore application
The MCP server adds application initialization:
app = BedrockAgentCoreApp()
Decorate the main entrypoint
The MCP server converts your handler function:
@app.entrypoint def handler(event, context): # Your agent logic here pass
Add application runner
The MCP server adds the application runner:
if __name__ == "__main__": app.run()
Transformation procedure
To transform your AgentCore agent, open your existing AgentCore agent file (for example, weather_agent.py
) in your MCP client and use your MCP client's AI assistant with the following prompt:
Transform this AgentCore agent code to be compatible with AgentCore runtime. Update the imports, dependencies, and application structure as needed.