Beyond Chatbots: Wrapping My RAG Agent in an MCP Server
In my last post, I walked through a RAG pipeline that answers questions from a company policy document. The next question I wanted to answer: what happens when I want other AI systems to use that same capability, without hardcoding a Python import? That's what pulled me into building an MCP server. In this article, I will explain how I built a custom MCP server that exposes tools to AI agents and how this architecture enables more powerful enterprise AI applications. What is MCP? Model Context Protocol is an open protocol that standardizes how AI applications communicate with external tools and data sources. Instead of creating custom integrations for every AI application, MCP provides a common interface where servers expose tools that AI clients can discover and invoke. Technology Stack Python, MCP SDK, Ollama / Local LLM, AI Agent Client, FastAPI (optional integration). What's actually in the server I built this with FastMCP, and it currently exposes four tool categories: Calculator tools — calculator_add and calculator_multiply. search_company_documents — the RAG agent from my last project, but now reached over HTTP instead of a direct function call. The MCP tool sends a request to the RAG agent's FastAPI /search endpoint and returns the answer. This one requires an api_key parameter. get_employee_leave — looks up an employee's remaining PTO from an in-memory store. Simple lookup, no external calls. get_ticket_information — same pattern, returning ticket status, assigned team, and priority. Each tool is registered with a @mcp .tool() decorator, which is what makes FastMCP genuinely pleasant to work with. Challenges I Encountered The calculator, employee, and ticket tools were straightforward pure functions with no external dependencies. The RAG search tool was a different problem entirely, and it was the hardest part of this whole project. My RAG agent runs as its own FastAPI service, on its own process, with its own vector store loaded into memory. The MCP serve