You can build private, local AI agents to eliminate API costs by utilizing Model Context Protocol (MCP) servers and Ollama, allowing enterprise clients to run large language models (LLM) on their own infrastructure. This approach enables local data security and reduces reliance on cloud-based services, which can incur significant API costs. By hosting private ai agents on MCP servers, companies can maintain control over their data and avoid paying per-request fees, such as those associated with Twilio or Vapi, and instead leverage tools like ElevenLabs for text-to-speech voices and Deepgram for speech-to-text capabilities.
What you need To build private ai agents using MCP servers, you will need a combination of tools that provide local data security, speech-to-text capabilities, and voice-agent orchestration. | Tool | Plan/Price | Role | | --- | --- | --- | | Ollama | check current pricing | Private AI agent development | | MCP | included with Ollama | Model Context Protocol for local AI agents | | ElevenLabs | from $0.005/min | Text-to-speech voices for AI agents | | Deepgram | from $0.25/min | Speech-to-text transcription for voice data | | Vapi | from $0.05/min | Voice-agent orchestration for AI agents | | Twilio | from $0.0085/min | Telephony services for voice interactions | | n8n | free tier available | Workflow automation for integrating AI agents with other tools |
How it works 1. The process starts with the enterprise client's local data being processed by the Ollama large language model (LLM), which generates text-based outputs that are then used to train the private AI agents. This local data processing ensures local data security and reduces api costs associated with cloud-based services. 2. The trained private ai agents are then deployed on the MCP servers, which utilize the Model Context Protocol (MCP) to manage and orchestrate the agents' interactions with various tools and services. 3. When a user interacts with the private AI agent, the agent's response is generated using the Ollama LLM and then sent to the ElevenLabs text-to-speech service to generate an audio output. 4. The audio output is then sent to the Twilio telephony service, which handles the actual call and audio playback to the user, with Vapi providing voice-agent orchestration to manage the call flow and agent interactions. 5. The user's speech input is captured by Twilio and sent to the Deepgram speech-to-text service for transcription, which is then used as input for the private AI agent's next response. 6. The entire workflow is managed and automated using n8n, which connects the various tools and services, including the MCP servers, Ollama LLM, and Vapi, to create a direct and integrated experience for the enterprise client.
How to build it
To build a private AI agent using Ollama and MCP servers, follow these steps:
1. Set up an MCP server on your local network to handle the Model Context Protocol (MCP) requests. This will be the central hub for your private AI agents.
2. Install Ollama, a framework for building private AI models, on the same network as your MCP server. Ollama will provide the necessary tools for creating and training your private AI agents.
3. Configure the Ollama framework to use the MCP server as the endpoint for model updates and queries. This can be done by setting the mcp_server field in the Ollama configuration file to the IP address or hostname of your MCP server.
4. Create a new private AI agent using the Ollama framework. This can be done by running the ollama create-agent command and specifying the agent's name, description, and other parameters.
5. Train the private AI agent using your local data. This can be done by running the ollama train-agent command and specifying the agent's name, training data, and other parameters.
6. Integrate the private AI agent with your enterprise application using the MCP protocol. This can be done by sending MCP requests to the MCP server, which will then forward the requests to the private AI agent.
7. Use a speech-to-text service like Deepgram or Whisper to transcribe audio inputs, and a text-to-speech service like ElevenLabs to generate audio outputs.
8. Use a telephony service like Twilio to handle phone calls and send audio inputs to the private AI agent for processing.
- To reduce api costs, make sure to handle errors and exceptions properly, and implement a retry mechanism for failed requests. You can also use a service like Vapi to orchestrate your voice agents and reduce the number of requests made to the MCP server.
For more information on building private AI agents, you can visit the https://getaab.com/blog/ or check the documentation for the ollama framework and the MCP protocol. You can also check the Vapi API reference for more information on how to use the Vapi service to orchestrate your voice agents.