ollama-mcp-example
by kirillsaidov·★ 18·Score 37
A beginner-friendly example demonstrating MCP server and client implementation with Ollama.
Overview
This repository provides a straightforward example of implementing MCP (Model Context Protocol) with Ollama. It demonstrates how to create an MCP server that exposes tools over a network and an MCP client that connects to these servers to make them available to an LLM. The example includes clear implementation of both server and client sides, showing how tool calls are routed through MCP instead of executing locally.
Try asking AI
After installing, here are 5 things you can ask your AI assistant:
When to choose this
Choose this when you're learning MCP basics or need a simple, minimal example to understand how MCP servers and clients work together.
When NOT to choose this
Don't choose this for production use cases as it's an example with minimal error handling and no authentication mechanisms.
Tools this server exposes
1 tool extracted from the READMEget_weatherget_weather(city: str) -> strGets weather information for a specified city
Comparable tools
Installation
Installation
- Clone the repository:
git clone https://github.com/kirillsaidov/ollama-mcp-example.git
cd ollama-mcp-example- Create a virtual environment and install dependencies:
python3 -m venv venv
./venv/bin/pip install -r requirements.txt- Run the server and client:
# Start MCP server
./venv/bin/python mcp_server.py
# Run MCP client
./venv/bin/python mcp_client.pyFor Claude Desktop integration, add this to your config.json:
{
"mcpServers": {
"ollama-mcp": {
"command": "python",
"args": ["mcp_server.py"],
"env": {
"PYTHONPATH": "."
}
}
}
}FAQ
- What is the difference between MCP and regular function calling?
- With MCP, you don't need to implement, define, or execute the tools yourself. MCP servers handle that. Most importantly, they are reusable and model-agnostic.
- How can I add my own functions to this example?
- Simply add your own decorated function to mcp_server.py using the @mcp.tool() decorator.
Compare ollama-mcp-example with
Last updated · Auto-generated from public README + GitHub signals.