
Ollama
STDIOMCP server connecting Claude Desktop with locally-running LLMs via Ollama API.
MCP server connecting Claude Desktop with locally-running LLMs via Ollama API.
An enhanced MCP (Model Context Protocol) server for interacting with the Ollama API, providing a robust bridge between Claude Desktop and locally-running LLMs via Ollama.
Install Ollama and ensure it's running:
# Download from https://ollama.com or use: curl -fsSL https://ollama.com/install.sh | sh ollama serve
Install the MCP server:
git clone https://github.com/cuba6112/ollama-mcp.git cd ollama-mcp python3 -m venv venv source venv/bin/activate pip install -r requirements.txt
Configure Claude Desktop by adding to your config file:
{ "mcpServers": { "ollama": { "command": "/Users/mac_orion/mcp_server/ollama_mcp_server/venv/bin/python", "args": ["-m", "ollama_mcp_server.main"], "cwd": "/Users/mac_orion/mcp_server/ollama_mcp_server" } } }
Restart Claude Desktop and start using Ollama models!
Smithery provides a convenient way to install and manage MCP servers. The Ollama MCP server includes automatic network detection to work seamlessly with external tools like Smithery.
npx -y @smithery/cli@latest install @cuba6112/ollama-mcp --client windsurf --key YOUR_KEY
The server automatically detects the appropriate Ollama host:
http://localhost:11434
when Ollama is accessible locallyhttp://YOUR_LOCAL_IP:11434
) when localhost is not accessibleOLLAMA_HOST
environment variable for custom configurationsFor Smithery and other external tools to connect to your local Ollama instance:
Start Ollama with external binding:
ollama serve --host 0.0.0.0
Or set environment variable:
export OLLAMA_HOST=0.0.0.0 ollama serve
Verify connectivity:
# Test from another machine or tool curl http://YOUR_LOCAL_IP:11434/api/tags
If Smithery cannot connect to your Ollama instance:
ollama serve --host 0.0.0.0
http://YOUR_LOCAL_IP:11434
from another deviceOLLAMA_LOG_LEVEL=DEBUG
for detailed connection informationInstall Ollama and ensure it's running:
# Download from https://ollama.com or use: curl -fsSL https://ollama.com/install.sh | sh ollama serve
Install the MCP server:
git clone https://github.com/cuba6112/ollama-mcp.git cd ollama-mcp python3 -m venv venv source venv/bin/activate pip install -r requirements.txt
Configure Claude Desktop by adding to your config file:
{ "mcpServers": { "ollama": { "command": "/path/to/your/venv/bin/python", "args": ["-m", "ollama_mcp_server.main"], "cwd": "/path/to/ollama-mcp" } } }
Restart Claude Desktop and start using Ollama models!
Install Ollama: Download and install from the official Ollama website.
Install the MCP server:
git clone https://github.com/cuba6112/ollama-mcp.git cd ollama-mcp python -m venv venv .\venv\Scripts\activate pip install -r requirements.txt
Configure Claude Desktop by adding to your config file:
{ "mcpServers": { "ollama": { "command": "C:\\path\\to\\your\\venv\\Scripts\\python.exe", "args": ["-m", "ollama_mcp_server.main"], "cwd": "C:\\path\\to\\ollama-mcp" } } }
Restart Claude Desktop and start using Ollama models!
uv
or pip
is installed for package management.Navigate to the project directory:
cd /Users/mac_orion/mcp_server/ollama_mcp_server
Create a virtual environment:
Using venv
:
python -m venv .venv source .venv/bin/activate
Install dependencies:
Using pip
:
pip install -e .
Or using uv
:
uv pip install -e .
Once the dependencies are installed, you can run the server directly:
python -m ollama_mcp_server.main
Or use the mcp dev tool for development:
mcp dev ollama_mcp_server/main.py
To use this server with the Claude Desktop app, you need to add it to your configuration file.
On macOS, edit ~/Library/Application Support/Claude/claude_desktop_config.json
:
{ "mcpServers": { "ollama": { "command": "/path/to/your/venv/bin/python", "args": ["-m", "ollama_mcp_server.main"], "cwd": "/Users/mac_orion/mcp_server/ollama_mcp_server" } } }
Replace /path/to/your/venv/bin/python
with the actual path to your Python executable.
list_models
: List all available Ollama models with size and modification infoshow_model
: Get detailed information about a specific modelcheck_model_exists
: Check if a model exists locallygenerate_completion
: Generate text completions with advanced options
generate_chat_completion
: Generate chat responses with conversation history
generate_embeddings
: Create embeddings for text (supports both single strings and lists)pull_model
: Download models from the Ollama librarycopy_model
: Duplicate a model with a new namedelete_model
: Remove models from local storagelist_running_models
: Show currently loaded models in memoryThe server can be configured using environment variables or a .env
file:
# Ollama host - automatically detected by default OLLAMA_HOST=http://localhost:11434 # Manual override for Ollama API URL OLLAMA_REQUEST_TIMEOUT=30.0 # Request timeout in seconds OLLAMA_CONNECTION_TIMEOUT=5.0 # Connection timeout in seconds OLLAMA_MAX_RETRIES=3 # Max retry attempts OLLAMA_RETRY_DELAY=1.0 # Initial retry delay
The server automatically detects the appropriate Ollama host:
OLLAMA_HOST
is set, uses that valuehttp://localhost:11434
This ensures seamless operation in both local development and external access scenarios (like Smithery).
# Logging OLLAMA_LOG_LEVEL=INFO # Log level (DEBUG, INFO, WARNING, ERROR) OLLAMA_LOG_REQUESTS=false # Log all API requests/responses # Performance OLLAMA_ENABLE_CACHE=true # Enable response caching OLLAMA_CACHE_TTL=300 # Cache TTL in seconds
Copy .env.example
to .env
and customize as needed.
If Claude Desktop shows connection errors:
ollama ps
should show running modelsOLLAMA_LOG_LEVEL=DEBUG
in your .env
fileIf you see parameter-related errors:
pip install -r requirements.txt
If the server can't connect to Ollama:
ollama serve
curl http://localhost:11434/api/tags
For better performance:
OLLAMA_ENABLE_CACHE=true
OLLAMA_CACHE_TTL=600
OLLAMA_REQUEST_TIMEOUT=60
Test the server directly using the MCP dev tool:
mcp dev ollama_mcp_server/main.py
Or run the server and test individual tools:
# Start the server python -m ollama_mcp_server.main # In another terminal, test with Claude Desktop or other MCP clients # You can also check the example usage: python examples/usage_example.py
This will verify that all core functions work correctly with your Ollama installation.
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues or have questions: