ollama-mcp-agent
Ollama MCP Agent allows you to use LLM models locally on your PC for free along with MCP additional features
Links
README
From the repo.
Ollama MCP Agent
Ollama MCP Agent allows you to use LLM models locally on your PC for free. Using Ollama's locally installed LLM models along with MCP (Model Context Protocol) additional features, you can easily extend LLM functionality.
- contains Ollama(main.py), Gemini(gemini.py) example
- Inspired by: Teddynote-lab's mcp agents, langchain mcp adapters
- Contributor: odeothx
Key Features
- Run LLM models locally on your PC (no additional costs)
- Extend LLM capabilities through MCP
- Streaming response output
- Tool call information monitoring
System Requirements
- Python 3.12 or higher
- Ollama installation
- uv - Fast Python package installer and resolver
- MCP server (optional)
Installation
- Clone repository
git clone https://github.com/godstale/ollama-mcp-agent
cd ollama-mcp-agent
- Install uv (if not installed)
# Using pip
pip install uv
# Or using curl (Unix-like systems)
curl -LsSf https://astral.sh/uv/install.sh | sh
# Or using PowerShell (Windows)
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
- Create virtual environment and install dependencies
# Install dependencies
uv sync
- Install Ollama and download model
# Install Ollama (refer to https://ollama.ai for platform-specific installation)
# Download LLM model which supports Tool calling feature
ollama pull qwen3:14b
Configuration
MCP Configuration (mcp_config.json)
You can extend LLM functionality through the MCP configuration file. You can implement MCP servers directly in Python or add MCP servers found on smithery.ai. Add settings to the mcp_config.json file:
{
"mcpServers": {
"weather": {
"command": "python",
"args": ["./mcp_server/mcp_server_weather.py"],
"transport": "stdio"
},
"fetch": {
"command": "npx",
"args": [
"-y",
"@smithery/cli@latest",
"run",
"@smithery-ai/fetch",
"--key",
"your_unique_uuid"
]
}
}
}
Running the Application (with Ollama)
Basic execution:
uv run main.py
With options:
uv run main.py --temp 0.7 --timeout 300 --show-tools
Using Google Gemini Model
Ollama MCP Agent now supports Google's Gemini model as an alternative to Ollama. (written by: odeothx) To use Gemini:
- Set up Google API Key
# Create .env file and add your Google API key
echo GOOGLE_API_KEY=your_google_api_key_here > .env
# Or set environment variable directly
export GOOGLE_API_KEY=your_google_api_key_here # For Unix-like systems
# Or
set GOOGLE_API_KEY=your_google_api_key_here # For Windows
- Run with Gemini
uv run gemini.py
Gemini Run Options
--temp: Set temperature value (0.0 ~ 1.0, default: 0.5)--system-prompt: Set custom system prompt--timeout: Response generation timeout (seconds, default: 300)--show-tools: Display tool call information
Important Notes for Gemini
- Requires valid Google API key
- Uses Gemini 1.5 Flash model by default
- Supports all MCP tools like the Ollama version
- Streaming responses are enabled by default
Run Options
--temp: Set temperature value (0.0 ~ 1.0, default: 0.1)--system-prompt: Set system prompt--timeout: Response generation timeout (seconds, default: 300)--show-tools: Display tool call information
Key Files
main.py: Main application filemcp_manager.py: MCP client managementmcp_config.json: MCP server configuration file
Extending MCP Tools
- Add new MCP server and tools to
mcp_config.json - Implement and run MCP server
- Restart application
Refer to smithery.ai to add and use various MCP servers.
Exit Commands
Enter one of the following commands to exit the program:
- quit
- exit
- bye
Important Notes
- Basic LLM functionality works even without MCP server configuration
- Response speed may vary depending on local PC performance
- Be mindful of memory usage (especially when using large LLM models)
License
MIT License
Collected info
- ★ 66 stars
- ⎇ 14 forks
- Language: Python
- Source updated: 8/14/2026