How to Create a Smart Agent Using Open-WebUI and MCPO: A Detailed Guide

daybreakdaybreak
3 min read

In the rapidly evolving world of AI, integrating tools seamlessly is crucial. This guide walks you through building a smart agent using Open-WebUI and MCPO, streamlining the process for efficiency and ease.

What You’ll Learn

  • Setting up Open-WebUI

  • Installing and configuring MCPO

  • Integrating MCPO with Open-WebUI

  • Deploying your smart agent

Prerequisites

Before we begin, ensure you have the following:

  • Basic knowledge of Python

  • Python 3.8+ installed

  • Familiarity with command-line interfaces

MCP - A Universal Translator

https://github.com/modelcontextprotocol/servers

Think of MCP as a universal translator at a big international conference: the AI model speaks in its own “language,” MCP interprets that into each tool’s native “tongue,” then converts the responses back into the AI’s format. This means you never have to build a custom adapter for every new service—MCP handles security, error handling, and documentation under one open standard. By exposing data through MCP servers and letting AI clients call them, MCP creates secure, two‑way connections between models and tools without extra glue code.

MCPO

https://github.com/open-webui/mcpo

MCPO (MCP-to-OpenAPI Proxy) is a simple proxy server that exposes any MCP (Model Context Protocol) tool as an OpenAPI-compatible HTTP server. It helps convert MCP server commands into standard RESTful OpenAPI endpoints without the need for custom protocols or additional code.

Example repo:
https://github.com/joydesigner/test-mcpo

Step 1: Setting Up Open-WebUI

Open WebUI

https://docs.openwebui.com/

Open-WebUI provides a user-friendly interface for interacting with AI models. To set it up:

Install Open WebUI

curl -LsSf https://astral.sh/uv/install.sh | sh

Start Open WebUI

open-webui serve

Connect it with LLM

I connect it with my local LLM with Llama. You can connect with any LLM you like with tool capability.

Step 2: Installing MCPO

MCPO (Model Context Protocol to OpenAPI) acts as a bridge between MCP tools and OpenAPI-compatible interfaces. To install MCPO:

pip install mcpo

Step 3: Integrating MCPO with Open-WebUI

  1. Start MCPO:

Using uvx to Start MCPO proxy with Multiple MCP Servers.

uvx mcpo --config /path/to/config.json

Example of the config file

{
  "mcpServers": {
    "fetch": {
      "command": "uvx",
      "args": ["mcp-server-fetch"]
    },
    "time": {
      "command": "uvx",
      "args": ["mcp-server-time", "--local-timezone=America/New_York"]
    }
  }
}
  1. Access the OpenAPI Documentation:

    Navigate to http://localhost:8000/docs to view the auto-generated documentation for your MCP tool.

  1. Configure Open-WebUI:

    • In Open-WebUI, go to Settings > Tools.

    • Add a new tool with the following details:

  1. Congiure the Open WebUI setting to add the mcpo proxy. My local mcpo proxy url is : http://locahost:8000

This setup allows Open-WebUI to communicate with your MCP tool via MCPO seamlessly.

Step 4: Test Your Smart Agent

Select a model (i selected gemma3:12b)

Check the available tools.

With everything configured:

  • Use Open-WebUI’s interface to interact with your MCP tools.

  • Test the smart agent with queries to ensure proper tools are used.

Test 1: Query the LLM to get the current time for a city.
Now I can ask the LLM model to get current time of Brisbane by utilizing the mcp-server-time tool.

Test 2: Query the LLM to fetch the web url content and give me the summary.

Tips and Best Practices

  • Security: Always use secure API keys and consider implementing HTTPS for production environments.

  • Scalability: For multiple MCP tools, consider using MCPO’s configuration file feature to manage them efficiently.

  • Documentation: Regularly update your tool’s documentation to reflect any changes or updates.

Conclusion

Integrating Open-WebUI with MCPO simplifies the process of building smart agents, allowing for efficient and secure communication between tools. By following this guide, you’re well on your way to deploying powerful AI-driven applications.

Note: The example code repo also includes the example of using mcpo with Python code instead of querying the LLM.

0
Subscribe to my newsletter

Read articles from daybreak directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

daybreak
daybreak

I’m Xin, a passionate AI enthusiast and tech-savvy explorer on a mission to demystify the world of artificial intelligence. My journey into AI began with a fascination for how machines can learn and adapt, and it has since grown into a deep dive into the cutting-edge technologies that are shaping our future. On this blog, I aim to share my discoveries, insights, and experiences with fellow AI aficionados and curious minds. Whether you’re a seasoned developer, a tech student, or just someone intrigued by the possibilities of AI, I hope you’ll find something valuable here. From the latest breakthroughs in machine learning to practical applications in everyday life, I strive to make complex concepts accessible and engaging. Join me as we explore the fascinating intersection of AI, technology, and human ingenuity. Feel free to reach out if you have any questions or just want to chat about all things AI. Let’s embark on this exciting journey together!