Ollama MCP server

Integrates Ollama's local LLM models with MCP-compatible applications, enabling on-premise AI processing and custom model deployment while maintaining data control.
Back to servers
Setup instructions
Provider
tigreen
Release date
Feb 13, 2025
Language
TypeScript
Package
Stats
3.5K downloads
117 stars

Ollama MCP Server is a powerful tool that enables seamless integration between your local LLM models and MCP-compatible applications like Claude Desktop and Cline. It exposes the complete Ollama SDK as MCP tools, allowing AI assistants to directly leverage your local language models.

Getting Started

Installation Options

Quick Start with Claude Desktop

Add to your Claude Desktop configuration file (located at ~/Library/Application Support/Claude/claude_desktop_config.json on macOS):

{
  "mcpServers": {
    "ollama": {
      "command": "npx",
      "args": ["-y", "ollama-mcp"]
    }
  }
}

Global Installation

Install the package globally using npm:

npm install -g ollama-mcp

For Cline (VS Code)

Add to your Cline MCP settings in cline_mcp_settings.json:

{
  "mcpServers": {
    "ollama": {
      "command": "npx",
      "args": ["-y", "ollama-mcp"]
    }
  }
}

Configuration Options

Environment Variables

Variable Default Description
OLLAMA_HOST http://127.0.0.1:11434 Ollama server endpoint
OLLAMA_API_KEY - API key for Ollama Cloud (required for web tools)

Custom Ollama Host

You can specify a custom Ollama host:

{
  "mcpServers": {
    "ollama": {
      "command": "npx",
      "args": ["-y", "ollama-mcp"],
      "env": {
        "OLLAMA_HOST": "http://localhost:11434"
      }
    }
  }
}

Ollama Cloud Configuration

To use Ollama's cloud platform with web search and fetch capabilities:

{
  "mcpServers": {
    "ollama": {
      "command": "npx",
      "args": ["-y", "ollama-mcp"],
      "env": {
        "OLLAMA_HOST": "https://ollama.com",
        "OLLAMA_API_KEY": "your-ollama-cloud-api-key"
      }
    }
  }
}

Hybrid Mode (Local + Cloud)

You can use both local and cloud models simultaneously:

{
  "mcpServers": {
    "ollama": {
      "command": "npx",
      "args": ["-y", "ollama-mcp"],
      "env": {
        "OLLAMA_HOST": "http://127.0.0.1:11434",
        "OLLAMA_API_KEY": "your-ollama-cloud-api-key"
      }
    }
  }
}

Available Tools

Model Management Tools

Tool Description
ollama_list List all available local models
ollama_show Get detailed information about a specific model
ollama_pull Download models from Ollama library
ollama_push Push models to Ollama library
ollama_copy Create a copy of an existing model
ollama_delete Remove models from local storage
ollama_create Create custom models from Modelfile

Model Operations Tools

Tool Description
ollama_ps List currently running models
ollama_generate Generate text completions
ollama_chat Interactive chat with models (supports tools/functions)
ollama_embed Generate embeddings for text

Web Tools (Ollama Cloud)

Tool Description
ollama_web_search Search the web with customizable result limits
ollama_web_fetch Fetch and parse web page content

Note: Web tools require an Ollama Cloud API key. They connect to Ollama's cloud service for web search and fetch operations.

Usage Examples

Chat with a Model

{
  "tool": "ollama_chat",
  "arguments": {
    "model": "llama3.2:latest",
    "messages": [
      { "role": "user", "content": "Explain quantum computing" }
    ]
  }
}

Generate Embeddings

{
  "tool": "ollama_embed",
  "arguments": {
    "model": "nomic-embed-text",
    "input": ["Hello world", "Embeddings are great"]
  }
}

Web Search

{
  "tool": "ollama_web_search",
  "arguments": {
    "query": "latest AI developments",
    "max_results": 5
  }
}

Retry Behavior

The server includes intelligent retry logic for handling transient failures:

Automatic Retry Strategy

  • Automatically retries on rate limit errors (HTTP 429)
  • Maximum of 3 retry attempts
  • 30-second request timeout per request
  • Respects the Retry-After header when provided
  • Uses exponential backoff with jitter when Retry-After is not present

The retry mechanism ensures robust handling of temporary API issues while respecting server-provided retry guidance and preventing excessive request rates.

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "rawveg-ollama-mcp" '{"command":"npx","args":["-y","@rawveg/ollama-mcp"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "@rawveg/ollama-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "@rawveg/ollama-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "@rawveg/ollama-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "@rawveg/ollama-mcp"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later