Ollama MCP (Model Context Protocol)
- agent-framework
MCP client for local ollama models
About
What is Ollama MCP?
Ollama MCP is a tool for connecting Ollama-based language models with external tools and services using the Model Context Protocol (MCP). It runs locally on the command line and is designed for developers who want to enable LLMs to interact with systems like Git repositories, shell commands, and other tool-enabled services.
How to use Ollama MCP?
Install Python 3.13+, clone the repository, then create a virtual environment with uv and install dependencies with uv pip install -e .. Ensure Ollama is running and at least one model is pulled locally. At startup, the application lists all locally available Ollama models and prompts you to select one. After selection, run uv run main.py to start an interactive CLI where you can ask the assistant to perform Git operations. You can extend the system by creating new tool wrappers, registering them with OllamaToolManager, and connecting to different MCP servers.
Key features of Ollama MCP
- Seamless integration between Ollama language models and MCP servers
- Support for Git operations through the MCP Git server
- Extensible tool management system for custom tools
- Interactive command-line assistant interface
- Interactive model selection from locally available Ollama models at startup
Use cases of Ollama MCP
- Automate Git workflows (commits, branches, logs) by asking the assistant in natural language
- Connect Ollama LLMs to any MCP-compatible service (databases, APIs, file systems)
- Build custom toolchains by registering new tool wrappers and MCP servers
- Interactively run shell commands or other operations through the Ollama agent
FAQ from Ollama MCP
What models does Ollama MCP support?
It supports any Ollama model pulled locally, with particular emphasis on models that support tool usage (see Ollama’s tool‑capable models). You select from a list of all installed models at startup.
What are the system requirements?
Python 3.13 or higher, MCP 1.5.0 or higher, and Ollama 0.4.7 or higher. Ollama must be installed and running with at least one model pulled locally.
How do I extend Ollama MCP with custom tools?
Create a new tool wrapper that follows the MCP tool specification, register it with the OllamaToolManager, and then connect to the relevant MCP server (e.g., via StdioServerParameters).
Does Ollama MCP require a running Ollama instance?
Yes. The application depends on Ollama being installed and running locally, and you must have at least one model pulled before starting the assistant.
Is Ollama MCP free to use?
The README does not mention pricing or licensing terms. The source code is available in a public repository, implying it is open source. Running the tool requires only your own local Ollama and Python environment.
Details
- Author
- mihirrd
- GitHub stars
- 45
- Category
- agent-framework
- Repository
- mihirrd/ollama-mcp-client
Ollama MCP (Model Context Protocol)
Ollama MCP is a tool for connecting Ollama-based language models with external tools and services using the Model Context Protocol (MCP). This integration enables LLMs to interact with various systems like Git repositories, shell commands, and other tool-enabled services.
Features
- Seamless integration between Ollama language models and MCP servers
- Support for Git operations through MCP Git server
- Extensible tool management system
- Interactive command-line assistant interface
- Interactive Ollama model selection at startup from available local models
Installation
1. Ensure you have Python 3.13+ installed
2. Clone this repository
3. Install dependencies:
# Create a virtual environment
uv add ruff check
Activate the virtual environment
source .venv/bin/activate
Install the package in development mode
uv pip install -e .
Usage
Ollama Model Selection
Before the main application starts, you will be prompted to select an Ollama model to use.
1. Prerequisites:
Ensure Ollama is installed and running.
You must have at least one model pulled locally (e.g., via ollama pull llama3.1:8b). A list of models that support tool usage can be found on the Ollama website.
2. Startup Process:
The application will automatically detect and list all Ollama models available on your local machine.
You will be prompted to type the name of the model you wish to use from the displayed list.
If you enter an invalid model name, you will be prompted again until a valid selection is made.
The chosen model will then be used by the agent for all subsequent operations.
Running the Git Assistant
uv run main.py
To run tests
pytest -xvs tests/test_ollama_toolmanager.py
This will start an interactive CLI where you can ask the assistant to perform Git operations.
Extending with Custom Tools
You can extend the system by:
1. Creating new tool wrappers
2. Registering them with the OllamaToolManager
3. Connecting to different MCP servers
Components
- OllamaToolManager: Manages tool registrations and execution
- MCPClient: Handles communication with MCP servers
- OllamaAgent: Orchestrates Ollama LLM and tool usage
Examples
# Creating a Git-enabled agent
git_params = StdioServerParameters(
command="uvx",
args=["mcp-server-git", "--repository", "/path/to/repo"],
env=None
)
Connect and register tools
async with MCPClient(git_params) as client:
# Register tools with the agent
# Use the agent for Git operations
Requirements
- Python 3.13+
- MCP 1.5.0+
- Ollama 0.4.7+