Strands Agents: Few Lines of Code, Custom Tools and MCP Integration

Learn to create Strands agents with few lines of code, custom tools, and MCP to query APIs, calculate, and monitor weather and other services.

domingo, 17 de agosto de 2025 • 4 min read • Q2BSTUDIO Team

Artificial-Intelligence-

Building Strands Agents with Few Lines of Code: Custom Tools and MCP Integration

In this article, we explain in a practical way how to create Strands agents capable of interacting with the environment, consuming APIs, and extending functionalities through custom tools and the MCP Model Context Protocol. We also describe conceptual examples such as a weather agent and a simple calculator-type MCP server, and how to integrate them into real applications.

Preparation and basic dependencies: clone the repository https://github.com/elizabethfuentes12/strands-agent-samples or the reference repository https://github.com/aws-samples/sample-getting-started-with-strands-agents-course. Create a Python virtual environment, activate the environment, and install dependencies with pip install -r requirements.txt. Make sure to configure environment variables for the API keys you use in your models and services.

Weather agent with HTTP tools: a weather-oriented agent uses an HTTP tool that allows making GET and POST requests to services like the National Weather Service API. The general logic consists of requesting coordinates or grid data, retrieving the forecast URL, and then obtaining and formatting the forecast for the user. When designing responses, the agent should highlight temperature, probability of precipitation, and alerts, as well as translate technical terms into accessible language.

Custom tools in Python: Strands allows you to define your own tools that the agent can invoke. A useful example is a function that converts Fahrenheit to Celsius. By exposing tools as clearly typed and described functions, the agent can delegate calculations or transformations and return clear results for the user. Document each tool and handle errors and invalid inputs to improve robustness.

Introduction to MCP: the MCP Model Context Protocol standardizes the way tools are exposed so that multiple agents or applications can consume them. An MCP server acts as a catalog of tools accessible over the network and facilitates the reuse of functionalities such as a calculator, text analysis, or querying external systems.

Example of a calculator-type MCP server: implement a server that exposes basic arithmetic operations such as addition, subtraction, multiplication, and division. Each operation is registered as a tool with clear descriptions and signatures. For division, include validation to avoid division by zero. The server can run over an HTTP transport compatible with streaming to facilitate real-time interaction with agents.

Connecting the agent to the MCP server: from the Strands agent, create an MCP client pointing to the server URL. Get the list of available tools and create the agent by passing those tools to the constructor. Define a system prompt explaining that the agent should use MCP tools to perform calculations instead of doing them locally, and that it should explain the process to the user.

Testing and deployment: run the MCP server in a controlled environment and then launch the agent. Validate example calls such as weather queries or arithmetic calculations. Monitor logs and agent behavior to adjust prompts, error handling, and timeouts. For production, consider deploying in containers and orchestrators that optimize availability and scaling.

Best practices: security first, limiting permissions and access to resources; robust error handling in each tool; resource control when processing large files; design of composable tools to combine capabilities; and clear documentation of all tools and MCP endpoints. Also implement authentication and authorization on the MCP server if it is shared in enterprise environments.

Complementary services and observability: integrate observability solutions for tracing and evaluating agent behaviors, and use automated evaluation pipelines to measure accuracy and cost. Consider caching mechanisms for external data and rate limiting on calls to public APIs.

About Q2BSTUDIO: Q2BSTUDIO is a software development company specialized in custom applications and custom software. We are experts in artificial intelligence and in creating AI agents for businesses, in addition to offering cybersecurity services, aws and azure cloud services, and business intelligence services solutions. We design and deploy applications that integrate conversational models, data pipelines, and visualization with Power BI to support decision-making. If you are looking for AI for businesses or consulting in power bi and advanced analytics, Q2BSTUDIO offers end-to-end solutions ranging from requirements assessment to delivery and maintenance.

Recommended use cases: assistants for technical support, agents that query internal systems and APIs to automate tasks, dashboards integrated with Power BI for data and model observability, and accelerators for artificial intelligence projects and business intelligence services in aws and azure cloud environments. We are also capable of integrating cybersecurity measures to protect data flows and access to MCP tools.

Useful resources: examples repository https://github.com/elizabethfuentes12/strands-agent-samples, getting started guide https://github.com/aws-samples/sample-getting-started-with-strands-agents-course and official documentation at https://docs.strands.ai. For implementation questions and consulting on custom projects, contact Q2BSTUDIO to receive advice on architecture, model selection, and cloud deployment.

What's next: we will continue publishing guides on agent-to-agent A2A communication, observability and evaluation of agents, integrations with RAG solutions, and monitoring tools for production deployments. Stay tuned for new implementations and practical examples that simplify building AI agents with custom tools and MCP integration.

Thank you for reading and for trusting Q2BSTUDIO for your custom software, artificial intelligence, cybersecurity, and aws and azure cloud services projects.

OUR SERVICES

How we can help you

Do you have a project in mind?

Tell us your vision and we'll turn it into a software solution. Whatever the scope, we make your idea real.