🤖 CrewAI with MCP Tool: Build an Agentic AI Weather Assistant Using Python

Published by TechToGeek.com

🌤️ Introduction

Artificial Intelligence is entering a new era — one where AI models no longer just respond to prompts, but actually take intelligent actions. This is the world of Agentic AI, where systems can connect to tools, perform tasks, and generate meaningful results autonomously.

In this blog, we’ll dive deep into how you can create an Agentic AI Weather Assistant using CrewAI with MCP tool — a perfect blend of intelligent orchestration and tool-based reasoning.

You’ve developed an amazing tool that gives real-time weather information for any city by integrating CrewAI framework and the Model Context Protocol (MCP). The code is available open-source at:
👉 https://github.com/subasen85/CrewAI-MCP.git

This article explains everything — from installation to working, including hands-on code snippets, architecture insights, and an FAQ section to help beginners understand how CrewAI with MCP tool powers modern AI agents.


🚀 What Is CrewAI Framework?

CrewAI is an innovative open-source framework that makes building multi-agent AI systems easy, flexible, and production-ready.

Instead of having a single model do everything, CrewAI allows you to create a team (crew) of AI agents — each with its own expertise and goals. These agents can:

  • Communicate with each other
  • Divide and delegate tasks
  • Access external tools
  • Solve complex problems collaboratively

When you use CrewAI with MCP tool, the AI agents become capable of performing real-world actions — like fetching data, analyzing it, and presenting results — autonomously.

Key Benefits of CrewAI Framework:

  • 🧠 Supports multi-agent collaboration
  • ⚡ Fast orchestration and event handling
  • 🧩 Integrates easily with APIs and external tools
  • 🔄 Works great with frameworks like LlamaIndex, LangChain, and OpenAI APIs

In this project, you’ve harnessed CrewAI’s orchestration capability and MCP’s tool-execution power to build a smart weather-fetching agent that’s reliable, scalable, and easy to extend.


🌐 What Is MCP (Model Context Protocol)?

CrewAI with MCP tool

The Model Context Protocol (MCP) is a modern standard that enables AI models to interact with external tools and APIs securely.

In simple terms, MCP allows your AI model to say:

“Hey, I need to fetch the current weather in Tokyo,”
and then automatically execute the required API call — without human intervention.

It’s like giving your AI agent a “toolbox” it can use whenever it needs real-world data.

With CrewAI with MCP tool, you can connect AI reasoning directly with real actions. The MCP tool bridges your AI agents with weather APIs, stock data, or any custom endpoint — giving your AI a powerful sense of agency.


☁️ About the AI Weather Assistant

The AI tool you’ve developed uses Python, CrewAI, and MCP tool to provide weather conditions for any city.

When the user enters a query like “What’s the weather in Delhi?”, the system intelligently uses its agents to:

  1. Parse the user’s request
  2. Identify the target city
  3. Call the weather API via MCP
  4. Return a clear, human-readable weather update

This makes it a true Agentic AI product — one that doesn’t just reply but acts intelligently.


🛠️ Installation Guide

Let’s go step-by-step to set up and run this CrewAI with MCP tool weather assistant.

Step 1: Clone the Repository

git clone https://github.com/subasen85/CrewAI-MCP.git
cd CrewAI-MCP

Step 2: Create a Virtual Environment

python -m venv venv
source venv/bin/activate  # For Linux/Mac
venv\Scripts\activate     # For Windows

Step 3: Install Dependencies

pip install -r requirements.txt

Step 4: Add Your API Key

Open the .env file and insert your weather API key:

WEATHER_API_KEY=your_api_key_here

Step 5: Run the Application

python app.py

That’s it! You’re now ready to use your Agentic AI Weather Assistant.

Example query:

What is the weather in Bangalore?

Response:

“The weather in Bangalore is partly cloudy with a temperature of 28°C. You can expect mild humidity today.”


⚙️ How It Works

The architecture of your CrewAI with MCP tool weather assistant is elegant and modular.

Let’s break it down:

1️⃣ User Input

The user provides a text query such as:

“Tell me the weather in New York.”

2️⃣ CrewAI Agents Process the Query

CrewAI orchestrates multiple agents:

  • Parsing Agent: Understands the intent and extracts the city name.
  • Execution Agent: Invokes the MCP tool to call the weather API.
  • Response Agent: Formats the weather data into a natural, human-readable message.

3️⃣ MCP Tool Fetches Data

The MCP tool connects to an external weather API using the extracted city name.

4️⃣ Response Delivered

The response agent presents the data back to the user in clear language.

This structured process ensures reliability, accuracy, and scalability.


🧩 Code Snippet

Below is a simplified version of how CrewAI with MCP tool works in Python:

from crewai import Agent, Crew
from mcp_tool import WeatherClient

# Define your weather tool
weather_tool = WeatherClient()

# Create an agent for weather retrieval
weather_agent = Agent(
    name="WeatherAgent",
    role="Fetches live weather updates",
    goal="Get current weather details for any city",
    tools=[weather_tool]
)

# Define crew with the weather agent
crew = Crew(agents=[weather_agent])

# Run the crew for a specific city
def get_weather(city_name):
    response = crew.run(f"What is the weather in {city_name}?")
    print(response)

if __name__ == "__main__":
    city = input("Enter city: ")
    get_weather(city)

This simple snippet shows how the CrewAI framework and MCP tool interact seamlessly.
The CrewAI agent orchestrates the request, while the MCP tool executes the external API call.


🌍 Why CrewAI with MCP Tool Is a Game Changer

Integrating CrewAI with MCP tool represents a major leap in how we design AI applications. Here’s why:

FeatureAdvantage
🧠 Multi-Agent CoordinationEach agent has a defined goal and can collaborate effectively.
⚡ Tool Access with MCPSecure, standardized way to use external APIs.
🧩 Structured & ScalableEasily extendable for new tools or data sources.
🐍 Python SimplicityRapid development and easy debugging.
🤖 Agentic BehaviorThe system acts on its own — not just replies.

Your weather assistant isn’t just responding — it’s reasoning, planning, and taking action, which is the very essence of Agentic AI.


🐳 Docker Deployment

To make your app deployable anywhere, you’ve used Docker. Here’s how to do it:

Dockerfile

FROM python:3.10
WORKDIR /app
COPY . /app
RUN pip install -r requirements.txt
CMD ["python", "app.py"]

Build and Run

docker build -t crewai-mcp .
docker run -p 8080:8080 crewai-mcp

Now, your CrewAI with MCP tool-powered weather assistant runs consistently across environments.


🔍 Example Use Case

Imagine you’re planning a weekend trip. You open your assistant and type:

“What’s the weather like in Goa this Saturday?”

Here’s what happens:

  • CrewAI orchestrates the request.
  • MCP fetches real-time weather data.
  • The agent analyzes and formats the output.

Response:

“Expect light rain in Goa this Saturday with temperatures around 29°C.”

That’s how CrewAI with MCP tool turns a simple query into an intelligent interaction.


❓ FAQ

1. What is CrewAI?
CrewAI is an open-source framework for building multi-agent AI systems that can collaborate, plan, and execute complex tasks autonomously.

2. What is MCP?
MCP (Model Context Protocol) allows AI models to communicate with external tools and APIs securely, enabling true Agentic behavior.

3. Why use CrewAI with MCP tool together?
Together, they combine reasoning (CrewAI) and action (MCP), allowing AI systems to process, plan, and execute tasks intelligently.

4. Do I need a paid weather API?
Not necessarily. Free API keys from OpenWeatherMap or WeatherAPI work fine for testing.

5. Can I expand this system?
Yes. You can extend it to include stock analysis, news summaries, or even IoT device monitoring — all via MCP integration.


🧾 Conclusion

Your project beautifully demonstrates how CrewAI with MCP tool can be used to create Agentic AI systems capable of interacting with the world around them.

By combining CrewAI’s orchestration and MCP’s tool-handling power, you’ve built a reliable and intelligent AI Weather Assistant that understands, acts, and delivers real-time insights.

This is not just an AI bot — it’s the foundation of the next generation of intelligent, autonomous systems.

The future of AI lies in agents that act — and CrewAI with MCP tool is leading that evolution.

Published by TechToGeek.com

Leave a Reply

Your email address will not be published. Required fields are marked *