Ollama MCP AI Agents: Build POWERFUL & FREE Local AI in Minutes
By Mervin Praison
Key Concepts
- Local AI Processing: Running AI models directly on your device, ensuring data privacy and eliminating reliance on cloud services.
- Ollama: A tool for running large language models (LLMs) locally.
- mCP (Model Context Protocol): A universal AI tool standard that allows AI agents to access and utilize various tools.
- AI Agents: Software entities designed to perform specific tasks autonomously, often leveraging LLMs.
- Prais Agents: A Python library simplifying the creation of AI agents with LLMs and mCP tools.
- Gradio: A Python library for creating user interfaces for machine learning models.
Local AI Agents with mCP Tools using Ollama
Introduction
The video demonstrates how to create AI agents that run 100% locally using Ollama and leverage mCP tools for enhanced functionality. This approach offers privacy, cost-effectiveness, and unlimited usage compared to cloud-based AI services.
Benefits of Local AI Processing
- Privacy: Data never leaves your device.
- Cost: No monthly subscription fees.
- Unlimited Usage: No API rate limits.
Ollama Setup
- Download Ollama: Go to https://ollama.com/ and download the appropriate version for your operating system.
- Pull the LLM: Open your terminal and run
ollama pull llama3:latestto download the Llama 3 model.
Creating an AI Agent with Prais Agents and mCP
-
Install Required Libraries: Run
pip install prais agents gradioin your terminal. -
Create
app.py: Create a new Python file namedapp.pyand open it in your code editor. -
Import Libraries: Add the following lines to
app.py:from praison_agents import agent, mcp import gradio as gr -
Define the Agent: Create an AI agent using the
agentfunction, specifying the model and instructions:def search_airbnb(query): search_agent = agent( instruction="You help book apartments on Airbnb", llm="llama3:latest", tools=["airbnb"] ) result = search_agent.start(query) return resultinstruction: Defines the agent's purpose.llm: Specifies the LLM to use (in this case, Llama 3).tools: A list of mCP tools the agent can access.
Adding mCP Tools
- mCP Servers: The video mentions a list of available mCP servers, including Airbnb.
- Adding a Tool: Each mCP server has a specific command to add it to the agent. For example, the Airbnb tool requires running a command like
npx -y @modelcontext/cli add airbnb --ignore-robots-txt. - Environment Variables: Some mCP tools require API keys or tokens, which can be set as environment variables (e.g.,
BRAVE_API_KEYfor the Brave Search tool).
Creating a User Interface with Gradio
-
Define the Interface: Use Gradio to create a user interface for interacting with the agent:
iface = gr.Interface( fn=search_airbnb, inputs=gr.Textbox(lines=2, placeholder="Search for apartments in Paris for two nights 5th and 6th April 2025"), outputs="text", title="Airbnb Booking Assistant", description="Enter your search query to find apartments on Airbnb." ) iface.launch()fn: The function to call when the user submits the query (in this case,search_airbnb).inputs: Defines the input field (a text box).outputs: Specifies the output type (text).titleanddescription: Set the title and description of the user interface.
-
Launch the Interface: Run
demo.launch()to start the Gradio interface.
Running the Application
- Run the Script: Open your terminal and run
python app.py. - Access the Interface: Open the URL provided in the terminal (usually
http://127.0.0.1:7860/) in your web browser. - Enter a Query: Type your search query in the text box and click "Submit."
- View the Results: The AI agent will process the query using the Airbnb mCP tool and display the results in the output area.
Example Query
- "Paris for two nights 5th and 6th April 2025"
Additional Resources
- mCP Documentation: Clear documentation is available for mCP.
- Example mCP Servers: Examples are provided for Brave Search, GitHub, and Google Maps.
Conclusion
The video demonstrates a simple and powerful way to create local AI agents with access to various tools using Ollama, Prais Agents, and mCP. This approach offers privacy, cost-effectiveness, and flexibility, enabling users to build custom AI solutions tailored to their specific needs. The use of Gradio further simplifies the process by providing an easy-to-use interface for interacting with the agents.
Chat with this Video
AI-PoweredLoad the transcript when you're ready to chat so the initial page stays lighter.
Related Videos

Why Does This Guy Appear In Kids Videos?
sphynx

TIC en las Organizaciones - Electiva Complementaria II Unisimon
Julieth Güell S

How to Tame Your Advice Monster | Michael Bungay Stanier | TED
TED

Margaret Heffernan: Why it's time to forget the pecking order at work
TED

The importance of psychological safety: Amy Edmondson
The King's Fund

What Is Psychological Safety?
Harvard Business Review

13-Conflict Management: Listening in Conflict
Deliberate Development