mcp-ollama-python
by pblagoje
README.md
# ๐ฆ Ollama MCP Server (Python)
**Supercharge your AI assistant with local LLM access โ run powerful AI models on your own computer, no internet required.**
[](https://python.org)
[](https://python-poetry.org)
[](https://github.com/anthropics/model-context-protocol)
[](https://pypi.org/project/mcp-ollama-python/)
[](LICENSE)
A Python [MCP](https://github.com/anthropics/model-context-protocol) server that exposes your local [Ollama](https://ollama.ai) models as tools for AI assistants like **Windsurf**, **VS Code**, **Claude Desktop**, and more.
| | Links |
|---|---|
| **Docs** | [Full documentation](https://pblagoje.github.io/mcp-ollama-python/) |
| **PyPI** | [mcp-ollama-python](https://pypi.org/project/mcp-ollama-python/) |
| **VS Code UI** | Companion extension: [mcp-ollama-extension](https://github.com/pblagoje/mcp-ollama-extension) ยท [docs](https://pblagoje.github.io/mcp-ollama-extension/) ยท [Marketplace](https://marketplace.visualstudio.com/items?itemName=internetics.mcp-ollama-extension) |
---
## Ecosystem
These two repositories work together:
```
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ mcp-ollama-extension (VS Code) โ โ start/stop, models UI, logs
โ https://github.com/pblagoje/ โ
โ mcp-ollama-extension โ
โโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโ
โ stdio / MCP
โโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโ
โ mcp-ollama-python (this repo) โ โ MCP tools for Ollama
โ https://github.com/pblagoje/ โ
โ mcp-ollama-python โ
โโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโ
โ HTTP :11434
โโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโ
โ Ollama โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
```
- **This package** is the MCP server (required). Install with `pip install mcp-ollama-python`.
- **[MCP Ollama Manager](https://github.com/pblagoje/mcp-ollama-extension)** is the optional VS Code UI to manage that server. Prefer it if you use VS Code and want status bar controls, model sidebar, and log viewing without editing JSON by hand.
You can also wire this server into any MCP client (Windsurf, Cursor, Claude Desktop, etc.) without the extension โ see [Quick Start](#quick-start) below.
---
## What It Does
Connect your local LLMs to any MCP-compatible AI assistant. No cloud APIs needed.
| Tool | What it does |
|------|-------------|
| `ollama_chat` | Chat with any local model (multi-turn, tool-calling) |
| `ollama_generate` | Generate text completions |
| `ollama_embed` | Create vector embeddings |
| `ollama_list` | List installed models |
| `ollama_show` | Inspect model details |
| `ollama_pull` | Download new models |
| `ollama_delete` | Remove models |
| `ollama_ps` | List running models |
## Quick Start
**Prerequisites:** Python 3.10+, [Ollama](https://ollama.ai) running locally
```bash
pip install mcp-ollama-python
```
### Option A โ VS Code with the companion extension (recommended for VS Code)
1. Install [MCP Ollama Manager](https://marketplace.visualstudio.com/items?itemName=internetics.mcp-ollama-extension) from the Marketplace
2. Ensure `mcp-ollama-python` is installed (the extension can offer **Install Now** if missing)
3. Command Palette โ **MCP Ollama: Configure Server** โ **MCP Ollama: Start Server**
Details: [extension docs](https://pblagoje.github.io/mcp-ollama-extension/) ยท [repo](https://github.com/pblagoje/mcp-ollama-extension)
### Option B โ Any MCP client (Windsurf / VS Code MCP / Cursor / โฆ)
Add to your MCP config (e.g. `mcp_config.json`):
```json
{
"mcpServers": {
"ollama": {
"command": "py",
"args": ["-m", "mcp_ollama_python"],
"disabled": false
}
}
}
```
Restart your editor โ done. Your AI assistant can now use local Ollama models.
### Try It
Type in your AI assistant's chat:
> **MCP Tool: ollama / ollama_chat** โ Use model llama3.1 and explain quantum computing
## Key Features
- ๐ง **8 MCP tools** โ Full Ollama SDK access
- ๐ **Hot-swap architecture** โ Drop a file in `tools/`, it's auto-discovered
- ๐ฏ **Type-safe** โ Pydantic models throughout
- ๐ **Lightweight** โ Minimal dependencies, fast startup
- ๐ **Universal** โ Works with any MCP client
## Documentation
| Guide | Description |
|-------|-------------|
| [Installation](https://pblagoje.github.io/mcp-ollama-python/installation/) | Setup and prerequisites |
| [Available Tools](https://pblagoje.github.io/mcp-ollama-python/tools/) | All tools with examples |
| [Configuration](https://pblagoje.github.io/mcp-ollama-python/configuration/) | Environment variables, model config |
| [Windsurf Integration](https://pblagoje.github.io/mcp-ollama-python/windsurf/) | Complete Windsurf setup guide |
| [VS Code Integration](https://pblagoje.github.io/mcp-ollama-python/vscode/) | VS Code setup + companion extension |
| [Architecture](https://pblagoje.github.io/mcp-ollama-python/architecture/) | How it works, adding tools |
| [Server Control](https://pblagoje.github.io/mcp-ollama-python/SERVER_CONTROL/) | Start/stop/manage the server |
| [Interactive Manager](https://pblagoje.github.io/mcp-ollama-python/mcp_interactive/) | Menu-driven management UI |
| [Development](https://pblagoje.github.io/mcp-ollama-python/development/) | Contributing, code quality |
| [Security](https://pblagoje.github.io/mcp-ollama-python/SECURITY/) | Threat model, host validation, opt-in execute |
## Security (v1.0.8)
- **`ollama_execute` is opt-in** โ set `OLLAMA_EXECUTE_ENABLED=1`; shell/bash removed
- **`OLLAMA_HOST` validation** โ loopback by default; set `OLLAMA_ALLOW_REMOTE_HOST=1` for LAN/remote Ollama
- **No HTTP redirects** โ reduces SSRF risk toward internal endpoints
Details: [docs/SECURITY.md](docs/SECURITY.md)
## Changelog
### 1.0.8
- Security hardening: host validation, execute tool gating, env allowlist, input limits
- Fixed `__version__` mismatch with package version
- Added `tests/test_security.py` and `docs/SECURITY.md`
## Related Projects
| Project | Role | Links |
|---------|------|-------|
| **[mcp-ollama-extension](https://github.com/pblagoje/mcp-ollama-extension)** | VS Code UI for this server | [GitHub](https://github.com/pblagoje/mcp-ollama-extension) ยท [Docs](https://pblagoje.github.io/mcp-ollama-extension/) ยท [Marketplace](https://marketplace.visualstudio.com/items?itemName=internetics.mcp-ollama-extension) |
| [Ollama](https://ollama.ai/) | Local LLM runtime | [ollama.ai](https://ollama.ai/) |
## License
[MIT](LICENSE)
---
<div align="center">
Made with โค๏ธ using Python, Poetry, and Ollama
</div>
This server cannot be deployed
Maintenance
ActivityActive
ResponsivenessNo issues