MCP Catalogs
Home

ollama-mcp-example

by kirillsaidov·18·Score 37

A beginner-friendly example demonstrating MCP server and client implementation with Ollama.

ai-llmdeveloper-toolsother
1
Forks
0
Open issues
8 mo ago
Last commit
2d ago
Indexed

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:

you:Learning MCP implementation from scratch
you:Understanding how MCP servers and clients interact
you:Creating reusable, model-agnostic tools for LLM applications
you:What is the difference between MCP and regular function calling?
you:How can I add my own functions to this example?

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 README
  • get_weatherget_weather(city: str) -> str

    Gets weather information for a specified city

Comparable tools

mcp-server-templatenexus-mcpfunctionary-mcpmcp-ollama-server

Installation

Installation

  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
./venv/bin/pip install -r requirements.txt
  1. Run the server and client:
# Start MCP server
./venv/bin/python mcp_server.py

# Run MCP client
./venv/bin/python mcp_client.py

For 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

GitHub →

Last updated · Auto-generated from public README + GitHub signals.