Get the FREE Ultimate OpenClaw Setup Guide →

ollama -example

Ollama MCP example for dummies.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio kirillsaidov-ollama-mcp-example python mcp_server.py

How to use

This MCP server example exposes a simple set of tools over the network using Python. The server is designed to work with an Ollama-based MCP client, allowing the LLM to discover and call tools exposed by the server without embedding the tool logic directly in your application. You start the server, then run the client which queries the server for its available tools, translates them into a function-calling interface for the LLM, and routes tool calls back to the server for execution. The included client script demonstrates how to connect to the server, fetch the tool list, and use those tools in a chat-style interaction with the Ollama LLM.

To use it, first run the MCP server, then run the client. The client will fetch the server’s tools and present them to Ollama as functions that the LLM can call. When the LLM decides a tool is needed, the framework routes the call to the appropriate server for execution and returns the result to the LLM for continuing the conversation.

How to install

Prerequisites:

  • Python 3.8+
  • Ollama installed and running
  • Access to the repository with mcp_server.py and mcp_client.py

Installation steps:

  1. Clone the repository
git clone https://github.com/kirillsaidov/ollama-mcp-example.git
cd ollama-mcp-example
  1. Create a virtual environment and install dependencies
python3 -m venv venv
source venv/bin/activate  # on macOS/Linux
venv\Scripts\activate     # on Windows
pip install -r requirements.txt
  1. Run the MCP server and client
# start MCP server
python mcp_server.py

# run MCP client (in another terminal)
python mcp_client.py

Additional notes

Tips and notes:

  • The server exposes tools defined in mcp_server.py. You can customize or add new tools by decorating functions with @mcp.tool() as shown in the README example.
  • Ensure Ollama is configured to use the MCP client when querying tools; the client in this project demonstrates the integration workflow.
  • If you modify the server or tools, restart the server so the client can fetch the updated tool list.
  • If tools require specific environment variables or external services, document them in the tool implementation and consider adding them to the server’s environment configuration.
  • Common issues: Python path mismatches, missing dependencies, or the client not able to reach the server due to network restrictions. Verify the server is running and accessible at the expected address/port, and check firewall settings if applicable.

Related MCP Servers

Sponsor this space

Reach thousands of developers