AI Voice Assistant MCP Server
Enables a voice-enabled AI assistant to call 7 built-in MCP tools including calculator, web search (DuckDuckGo), weather (wttr.in), date/time, and local file read/write/list operations, integrating with Gemini 2.0 Flash for tool-calling conversations.
README
AI Voice Assistant with MCP Tool Calling
A fully free, end-to-end voice-enabled AI assistant built with Python.
| Component | Technology |
|---|---|
| π§ AI Brain | Google Gemini API (gemini-2.0-flash) β free tier |
| ποΈ Speech-to-Text | Google Web Speech API via SpeechRecognition β free |
| π Text-to-Speech | pyttsx3 (offline) β free |
| π οΈ Tool Calling | Model Context Protocol (MCP) β free |
| π Web Search | DuckDuckGo β free, no key needed |
| π€οΈ Weather | wttr.in REST API β free, no key needed |
Features
- ποΈ Voice Input β speak naturally; the assistant understands you
- π Voice Output β responses are read aloud via offline TTS
- π€ Gemini AI β context-aware, multi-turn conversation
- π οΈ 7 MCP Tools available to the AI:
- Calculator β safe math expression evaluator
- Web Search β DuckDuckGo (no API key)
- Weather β real-time via wttr.in (no API key)
- Date/Time β current date and time
- Read File β read any local file
- Write File β write/append to a local file
- List Directory β browse local folders
- π¬ Multi-turn memory β remembers conversation context
- β¨οΈ Text mode β works without a microphone (
--textflag)
Prerequisites
- Python 3.11+
- A free Gemini API key β get one at https://aistudio.google.com/app/apikey
- Internet connection (for speech recognition, Gemini API, and web tools)
- Microphone (optional β text mode works without one)
Installation
1. Clone / download the project
# If using git:
git clone <your-repo-url>
cd "AI voice assistant"
# Or just open the folder in your terminal
cd "C:\Users\sasid\Downloads\AI voice assistant"
2. Create and activate a virtual environment (recommended)
python -m venv .venv
# Windows:
.venv\Scripts\activate
# macOS / Linux:
source .venv/bin/activate
3. Install PyAudio (Windows β required for microphone)
PyAudio on Windows needs a pre-built binary. The easiest way:
pip install pipwin
pipwin install pyaudio
Or download the correct .whl from https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyaudio
and install with:
pip install PyAudioβ0.2.14βcpXXβcpXXβwin_amd64.whl
4. Install remaining dependencies
pip install -r requirements.txt
5. Set your Gemini API key
Option A β .env file (recommended):
copy .env.example .env
# Then open .env and replace "your_gemini_api_key_here" with your actual key
Option B β edit config.py directly:
Open config.py and change:
GEMINI_API_KEY: str = os.getenv("GEMINI_API_KEY", "YOUR_GEMINI_API_KEY_HERE")
to:
GEMINI_API_KEY: str = "your_actual_api_key"
Running
Voice mode (default β microphone + TTS)
python main.py
Text-only mode (no microphone needed)
python main.py --text
List available TTS voices
python main.py --list-voices
Example Interactions
| You say | What happens |
|---|---|
| "What's the weather in Tokyo?" | Calls get_weather MCP tool β speaks result |
| "Calculate 2 to the power of 32" | Calls calculator tool β speaks 4294967296 |
| "Search for the latest Python news" | Calls web_search β summarises top results |
| "What day is today?" | Calls get_datetime β speaks date & time |
| "Read the file notes.txt" | Calls read_file β speaks file contents |
| "Write 'Hello World' to test.txt" | Calls write_file β creates/updates file |
| "Reset conversation" | Clears chat history |
| "Goodbye" / "Exit" | Exits the assistant |
Project Structure
AI voice assistant/
βββ main.py # Entry point β CLI, banner, main loop
βββ assistant.py # Gemini + MCP integration (agentic tool-call loop)
βββ speech.py # SpeechRecognition (STT) + pyttsx3 (TTS)
βββ mcp_server.py # MCP tool server with 7 built-in tools
βββ config.py # All settings and API key placeholder
βββ requirements.txt # Python dependencies
βββ .env.example # API key template
βββ README.md # This file
Customisation
Change the AI's personality
Edit SYSTEM_PROMPT in config.py.
Adjust microphone sensitivity
Edit MIC_ENERGY_THRESHOLD in config.py (lower = more sensitive).
Change TTS voice or speed
Edit TTS_RATE and TTS_VOICE_PREFERENCE in config.py.
Run python main.py --list-voices to see available voice names.
Add more MCP tools
Open mcp_server.py, add a new function, then register it in list_tools() and call_tool().
Gemini Free Tier Limits
| Limit | Value |
|---|---|
| Requests per minute | 15 |
| Tokens per day | 1,000,000 |
| Cost | $0 |
Get your key at: https://aistudio.google.com/app/apikey
Troubleshooting
"No module named 'pyaudio'" β See PyAudio installation step above.
"Could not understand audio"
β Speak clearly; adjust MIC_ENERGY_THRESHOLD lower in config.py.
"Speech recognition service error" β Check your internet connection (Google Web Speech API requires internet).
Gemini 429 / rate limit error β You've hit the free tier limit. Wait a minute and try again.
Assistant doesn't speak / TTS silent
β Check system audio / volume. Try python main.py --list-voices to verify pyttsx3 works.
License
MIT β free to use, modify, and distribute.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.