ollama-mcp-agent

MCP.Pizza Chef: godstale

Ollama MCP Agent is a client that lets you run large language models locally on your PC for free, leveraging Ollama's LLMs combined with the Model Context Protocol (MCP) to extend AI capabilities. It supports streaming responses, tool call monitoring, and integrates easily with MCP servers, providing a powerful, cost-effective way to enhance LLM functionality with local resources.

Use This MCP client To

Run LLM models locally without cloud costs Extend local LLMs with MCP protocol features Monitor tool calls during LLM interactions Stream LLM response outputs in real time Integrate local LLMs with MCP servers for enhanced workflows

README

Ollama MCP Agent

Ollama MCP Agent allows you to use LLM models locally on your PC for free. Using Ollama's locally installed LLM models along with MCP (Model Context Protocol) additional features, you can easily extend LLM functionality.

Key Features

  • Run LLM models locally on your PC (no additional costs)
  • Extend LLM capabilities through MCP
  • Streaming response output
  • Tool call information monitoring

System Requirements

  • Python 3.12 or higher
  • Ollama installation
  • uv - Fast Python package installer and resolver
  • MCP server (optional)

Installation

  1. Clone repository
git clone https://github.com/godstale/ollama-mcp-agent
cd ollama-mcp-agent
  1. Install uv (if not installed)
# Using pip
pip install uv

# Or using curl (Unix-like systems)
curl -LsSf https://astral.sh/uv/install.sh | sh

# Or using PowerShell (Windows)
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
  1. Create virtual environment and install dependencies
# Install dependencies
uv sync
  1. Install Ollama and download model
# Install Ollama (refer to https://ollama.ai for platform-specific installation)
# Download LLM model which supports Tool calling feature
ollama pull qwen3:14b

Configuration

MCP Configuration (mcp_config.json)

You can extend LLM functionality through the MCP configuration file. You can implement MCP servers directly in Python or add MCP servers found on smithery.ai. Add settings to the mcp_config.json file:

{
  "mcpServers": {
    "weather": {
      "command": "python",
      "args": ["./mcp_server/mcp_server_weather.py"],
      "transport": "stdio"
    },
    "fetch": {
      "command": "npx",
      "args": [
        "-y",
        "@smithery/cli@latest",
        "run",
        "@smithery-ai/fetch",
        "--key",
        "your_unique_uuid"
      ]
    }
  }
}

Running the Application (with Ollama)

Basic execution:

uv run main.py

With options:

uv run main.py --temp 0.7 --timeout 300 --show-tools

Using Google Gemini Model

Ollama MCP Agent now supports Google's Gemini model as an alternative to Ollama. (written by: odeothx) To use Gemini:

  1. Set up Google API Key
# Create .env file and add your Google API key
echo GOOGLE_API_KEY=your_google_api_key_here > .env

# Or set environment variable directly
export GOOGLE_API_KEY=your_google_api_key_here  # For Unix-like systems
# Or
set GOOGLE_API_KEY=your_google_api_key_here     # For Windows
  1. Run with Gemini
uv run gemini.py

Gemini Run Options

  • --temp: Set temperature value (0.0 ~ 1.0, default: 0.5)
  • --system-prompt: Set custom system prompt
  • --timeout: Response generation timeout (seconds, default: 300)
  • --show-tools: Display tool call information

Important Notes for Gemini

  • Requires valid Google API key
  • Uses Gemini 1.5 Flash model by default
  • Supports all MCP tools like the Ollama version
  • Streaming responses are enabled by default

Run Options

  • --temp: Set temperature value (0.0 ~ 1.0, default: 0.1)
  • --system-prompt: Set system prompt
  • --timeout: Response generation timeout (seconds, default: 300)
  • --show-tools: Display tool call information

Key Files

  • main.py: Main application file
  • mcp_manager.py: MCP client management
  • mcp_config.json: MCP server configuration file

Extending MCP Tools

  1. Add new MCP server and tools to mcp_config.json
  2. Implement and run MCP server
  3. Restart application

Refer to smithery.ai to add and use various MCP servers.

Exit Commands

Enter one of the following commands to exit the program:

  • quit
  • exit
  • bye

Important Notes

  • Basic LLM functionality works even without MCP server configuration
  • Response speed may vary depending on local PC performance
  • Be mindful of memory usage (especially when using large LLM models)

License

MIT License

ollama-mcp-agent FAQ

How do I install Ollama MCP Agent?
Clone the GitHub repository, ensure Python 3.12+, install Ollama and uv package, then follow setup instructions.
Can I use Ollama MCP Agent without an MCP server?
Yes, the MCP server is optional; you can run local LLMs standalone.
What are the system requirements for Ollama MCP Agent?
Requires Python 3.12 or higher, Ollama installed locally, and uv package for Python.
Does Ollama MCP Agent support streaming responses?
Yes, it supports streaming output from LLMs for real-time interaction.
Can I monitor tool calls with Ollama MCP Agent?
Yes, it provides tool call information monitoring during LLM usage.
Is Ollama MCP Agent free to use?
Yes, it allows free use of local LLM models without additional costs.
Which LLM providers does Ollama MCP Agent support?
Primarily Ollama's local models, but it includes examples for Gemini and can be extended to others like OpenAI and Claude.
How does Ollama MCP Agent extend LLM capabilities?
By leveraging MCP features, it enables enhanced context handling and tool integrations with local models.