Serverless Agents: Real-World Tooling with Strands SDK, MCP & AWS • Akshatha Laxmi • GOTO 2025
A deep dive into building production-ready, stateless, and scalable LLM agents by leveraging the Model Context Protocol (MCP) and Strands SDK on AWS Lambda. The session demonstrates how to expose real-world functionality to language models, moving beyond mere reasoning to tangible action.
Traditional AI agents often face challenges with complex integrations, monolithic deployments, and brittle state management. Deploying tools for different LLMs like ChatGPT and Claude requires redundant effort, and hosting multiple tools with diverse dependencies on a single server leads to bloated, inefficient systems.
The Model Context Protocol (MCP)
The Model Context Protocol (MCP) provides a standardized, language-model-agnostic interface for defining and exposing tools to LLMs. It acts like a universal Type-C port for agent tools, allowing any LLM to understand and interact with them without custom integrations.
Key characteristics of MCP include:
- Standardized Tool Description: It defines a clear schema for tools, including name, description, and input/output schemas, which any LLM can understand.
- Statelessness: Designed for real-time, chat-based interactions, MCP offloads state management to the chat history of the LLM client. This stateless nature makes it a perfect architectural match for serverless platforms like AWS Lambda.
- Event-Driven: The request-response lifecycle of MCP, which includes initialization, tool listing, tool calls, and disconnection, aligns perfectly with the event-driven paradigm of serverless computing.
Building MCP Servers with Strands SDK
Strands SDK is a framework designed to simplify the creation of MCP agents, servers, and clients. It provides a clean abstraction layer over various LLMs and offers several key features:
- Model-Driven Orchestration: It uses the LLM itself to plan, orchestrate, and select the appropriate tool from a provided set.
- Built-in Tools: Includes pre-built functionalities like an HTTP request tool and a calculator.
- AWS Integration: Offers seamless integration with AWS services, particularly Lambda, EC2, and ECS.
Practical Examples and Architecture
Weather Tool
A simple “Hello World” example demonstrates how to wrap a weather-fetching agent in an MCP server. The server is implemented as a class that handles the required MCP lifecycle methods: handle_initialize_request, process_request (for listing tools), and handle_weather_request (for the actual tool call). This transforms a basic agent into a discoverable and usable tool for an LLM.
Database Agent
A more complex example features a database agent that allows a business analyst to query a PostgreSQL database using natural language.
- Architecture: The client (e.g., Claude) communicates with an MCP server hosted on AWS Lambda. The Lambda function, in turn, queries the database and returns the results.
- Implementation: The agent is given a system prompt defining its persona as a business analyst focused on identifying trends and patterns. The tool definition (
query_business_data) specifies a natural language query as its input. This allows the user to ask, “Show me the revenue summary of the last 30 days,” and the agent translates this into the necessary SQL query, executes it, and summarizes the results.
Deployment, Best Practices, and Security
Serverless Deployment
Deploying these agents on AWS Lambda is straightforward using the AWS CDK. Key considerations include:
- Packaging dependencies with the function or using Lambda Layers to reduce bloat.
- Setting appropriate timeouts and memory, as agentic chains can sometimes take longer to process.
- Using AWS Secrets Manager to securely handle database credentials and API keys.
Patterns and Best Practices
- Stateless, Separated Tools: Adhere to the separation of concerns by deploying individual tools or related groups of tools as separate Lambda functions. For example, the weather agent and database agent should be deployed independently.
- Intelligent Tool Composition: Leverage Strands SDK’s ability to intelligently detect and route requests to the correct tool, even if multiple tools are managed within the same Lambda function.
- Error Handling: Utilize the clean error messages from the Strands SDK for robust error management.
Security Considerations
- Prevent Injection: Use parameterized queries to protect against SQL injection and other malicious inputs.
- Least Privilege: Grant the Lambda function only the permissions it absolutely needs (e.g., access to Amazon Bedrock for the model and RDS for the database).
- LLM Guardrails: Implement guardrails to prevent the LLM from being exploited.
- Data Privacy: Be aware of the LLM provider’s data privacy policies and opt out of model training if working with sensitive data.
By combining the standardized, stateless nature of MCP with the scalability and ease of deployment of AWS Lambda, it’s possible to build robust, production-ready AI agents that can take meaningful actions in the real world.