Ollama logo

Ollama

Community
rawveg

An MCP Server for Ollama

Publisherrawveg
Repositoryollama-mcp
LanguageTypeScript
Forks
28
Stars
160
Available tools
0
Transport typestdio
Categories
LicenseAGPL-3.0
Links
  • Connect tools to AI workflows

    Ollama exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 0 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    160 stars and 28 forks from the linked repository.

πŸ¦™ Ollama MCP Server

Supercharge your AI assistant with local LLM access

License: AGPL-3.0 TypeScript MCP Coverage

An MCP (Model Context Protocol) server that exposes the complete Ollama SDK as MCP tools, enabling seamless integration between your local LLM models and MCP-compatible applications like Claude Desktop and Cline.

Features β€’ Installation β€’ Available Tools β€’ Configuration β€’ Retry Behavior β€’ Development


✨ Features

  • ☁️ Ollama Cloud Support - Full integration with Ollama's cloud platform
  • πŸ”§ 14 Comprehensive Tools - Full access to Ollama's SDK functionality
  • πŸ”„ Hot-Swap Architecture - Automatic tool discovery with zero-config
  • 🎯 Type-Safe - Built with TypeScript and Zod validation
  • πŸ“Š High Test Coverage - 96%+ coverage with comprehensive test suite
  • πŸš€ Zero Dependencies - Minimal footprint, maximum performance
  • πŸ”Œ Drop-in Integration - Works with Claude Desktop, Cline, and other MCP clients
  • 🌐 Web Search & Fetch - Real-time web search and content extraction via Ollama Cloud
  • πŸ”€ Hybrid Mode - Use local and cloud models seamlessly in one server

πŸ’‘ Level Up Your Ollama Experience with Claude Code and Desktop

The Complete Package: Tools + Knowledge

This MCP server gives Claude the tools to interact with Ollama - but you'll get even more value by also installing the Ollama Skill from the Skillsforge Marketplace:

  • πŸš— This MCP = The Car - All the tools and capabilities
  • πŸŽ“ Ollama Skill = Driving Lessons - Expert knowledge on how to use them effectively

The Ollama Skill teaches Claude:

  • Best practices for model selection and configuration
  • Optimal prompting strategies for different Ollama models
  • When to use chat vs generate, embeddings, and other tools
  • Performance optimization and troubleshooting
  • Advanced features like tool calling and function support

Install both for the complete experience:

  1. βœ… This MCP server (tools)
  2. βœ… Ollama Skill (expertise)

Result: Claude doesn't just have the car - it knows how to drive! 🏎️

πŸ“¦ Installation

Quick Start with Claude Desktop

Add to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):

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

Global Installation

bash
npm install -g ollama-mcp

For Cline (VS Code)

Add to your Cline MCP settings (cline_mcp_settings.json):

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

πŸ› οΈ Available Tools

Model Management

ToolDescription
ollama_listList all available local models
ollama_showGet detailed information about a specific model
ollama_pullDownload models from Ollama library
ollama_pushPush models to Ollama library
ollama_copyCreate a copy of an existing model
ollama_deleteRemove models from local storage
ollama_createCreate custom models from Modelfile

Model Operations

ToolDescription
ollama_psList currently running models
ollama_generateGenerate text completions
ollama_chatInteractive chat with models (supports tools/functions)
ollama_embedGenerate embeddings for text

Web Tools (Ollama Cloud)

ToolDescription
ollama_web_searchSearch the web with customizable result limits (requires OLLAMA_API_KEY)
ollama_web_fetchFetch and parse web page content (requires OLLAMA_API_KEY)

Note: Web tools require an Ollama Cloud API key. They connect to https://ollama.com/api for web search and fetch operations.

βš™οΈ Configuration

Environment Variables

VariableDefaultDescription
OLLAMA_HOSThttp://127.0.0.1:11434Ollama server endpoint (use https://ollama.com for cloud)
OLLAMA_API_KEY-API key for Ollama Cloud (required for web tools and cloud models)

Custom Ollama Host

json
{
  "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:

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

Cloud Features:

  • ☁️ Access cloud-hosted models
  • πŸ” Web search with ollama_web_search (requires API key)
  • πŸ“„ Web fetch with ollama_web_fetch (requires API key)
  • πŸš€ Faster inference on cloud infrastructure

Get your API key: Visit ollama.com to sign up and obtain your API key.

Hybrid Mode (Local + Cloud)

You can use both local and cloud models by pointing to your local Ollama instance while providing an API key:

json
{
  "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"
      }
    }
  }
}

This configuration:

  • βœ… Runs local models from your Ollama instance
  • βœ… Enables cloud-only web search and fetch tools
  • βœ… Best of both worlds: privacy + web connectivity

πŸ”„ Retry Behavior

The MCP server includes intelligent retry logic for handling transient failures when communicating with Ollama APIs:

Automatic Retry Strategy

Web Tools (ollama_web_search and ollama_web_fetch):

  • Automatically retry on rate limit errors (HTTP 429)
  • Maximum of 3 retry attempts (4 total requests including initial)
  • Request timeout: 30 seconds per request (prevents hung connections)
  • Respects the Retry-After header when provided by the API
  • Falls back to exponential backoff with jitter when Retry-After is not present

Retry-After Header Support

The server intelligently handles the standard HTTP Retry-After header in two formats:

1. Delay-Seconds Format:

Retry-After: 60

Waits exactly 60 seconds before retrying.

2. HTTP-Date Format:

Retry-After: Wed, 21 Oct 2025 07:28:00 GMT

Calculates delay until the specified timestamp.

Exponential Backoff

When Retry-After is not provided or invalid:

  • Initial delay: 1 second (default)
  • Maximum delay: 10 seconds (default, configurable)
  • Strategy: Exponential backoff with full jitter
  • Formula: random(0, min(initialDelay Γ— 2^attempt, maxDelay))

Example retry delays:

  • 1st retry: 0-1 seconds
  • 2nd retry: 0-2 seconds
  • 3rd retry: 0-4 seconds (capped at 0-10s max)

Error Handling

Retried Errors (transient failures):

  • HTTP 429 (Too Many Requests) - rate limiting
  • HTTP 500 (Internal Server Error) - transient server issues
  • HTTP 502 (Bad Gateway) - gateway/proxy received invalid response
  • HTTP 503 (Service Unavailable) - server temporarily unable to handle request
  • HTTP 504 (Gateway Timeout) - gateway/proxy did not receive timely response

Non-Retried Errors (permanent failures):

  • Request timeouts (30 second limit exceeded)
  • Network timeouts (no status code)
  • Abort/cancel errors
  • HTTP 4xx errors (except 429) - client errors requiring changes
  • Other HTTP 5xx errors (501, 505, 506, 508, etc.) - configuration/implementation issues

The retry mechanism ensures robust handling of temporary API issues while respecting server-provided retry guidance and preventing excessive request rates. Transient 5xx errors (500, 502, 503, 504) are safe to retry for the idempotent POST operations used by ollama_web_search and ollama_web_fetch. Individual requests timeout after 30 seconds to prevent indefinitely hung connections.

🎯 Usage Examples

Chat with a Model

typescript
// MCP clients can invoke:
{
  "tool": "ollama_chat",
  "arguments": {
    "model": "llama3.2:latest",
    "messages": [
      { "role": "user", "content": "Explain quantum computing" }
    ]
  }
}

Generate Embeddings

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

Web Search

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

πŸ—οΈ Architecture

This server uses a hot-swap autoloader pattern:

src/
β”œβ”€β”€ index.ts          # Entry point (27 lines)
β”œβ”€β”€ server.ts         # MCP server creation
β”œβ”€β”€ autoloader.ts     # Dynamic tool discovery
└── tools/            # Tool implementations
    β”œβ”€β”€ chat.ts       # Each exports toolDefinition
    β”œβ”€β”€ generate.ts
    └── ...

Key Benefits:

  • Add new tools by dropping files in src/tools/
  • Zero server code changes required
  • Each tool is independently testable
  • 100% function coverage on all tools

πŸ§ͺ Development

Prerequisites

  • Node.js v16+
  • npm or pnpm
  • Ollama running locally

Setup

bash
# Clone repository
git clone https://github.com/rawveg/ollama-mcp.git
cd ollama-mcp

# Install dependencies
npm install

# Build project
npm run build

# Run tests
npm test

# Run tests with coverage
npm run test:coverage

Test Coverage

Statements   : 96.37%
Branches     : 84.82%
Functions    : 100%
Lines        : 96.37%

Adding a New Tool

  1. Create src/tools/your-tool.ts:
typescript
import { ToolDefinition } from '../autoloader.js';
import { Ollama } from 'ollama';
import { ResponseFormat } from '../types.js';

export const toolDefinition: ToolDefinition = {
  name: 'ollama_your_tool',
  description: 'Your tool description',
  inputSchema: {
    type: 'object',
    properties: {
      param: { type: 'string' }
    },
    required: ['param']
  },
  handler: async (ollama, args, format) => {
    // Implementation
    return 'result';
  }
};
  1. Create tests in tests/tools/your-tool.test.ts
  2. Done! The autoloader discovers it automatically.

🀝 Contributing

Contributions are welcome! Please follow these guidelines:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Write tests - We maintain 96%+ coverage
  4. Commit with clear messages (git commit -m 'Add amazing feature')
  5. Push to your branch (git push origin feature/amazing-feature)
  6. Open a Pull Request

Code Quality Standards

  • All new tools must export toolDefinition
  • Maintain β‰₯80% test coverage
  • Follow existing TypeScript patterns
  • Use Zod schemas for input validation

πŸ“„ License

This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0).

See LICENSE for details.

πŸ”— Related Projects

πŸ™ Acknowledgments

Built with:

  • Ollama SDK - Official Ollama JavaScript library
  • MCP SDK - Model Context Protocol SDK
  • Zod - TypeScript-first schema validation

⬆ back to top

Made with ❀️ by Tim Green

Installation

TypingMind
Prerequisites:

Node.js 18+

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

Use Ollama MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once Ollama is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. This MCP runs locally through the TypingMind MCP connector on your device.

Setup guide to use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add Ollama as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the Ollama MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "ollama": {
      "command": "npx",
      "args": [
        "-y",
        "@rawveg/ollama-mcp"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the Ollama MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the Ollama MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use Ollama to help me with this task?
Ollama
Sure. I read it.
Here is what I found using Ollama.

Frequently asked questions

What is the Ollama MCP server used for?

Ollama is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use Ollama MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use Ollama with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use Ollama MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With Ollama connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect Ollama MCP to TypingMind?

Ollama runs through the TypingMind local MCP connector. This is best when the MCP server needs access to local files, desktop apps, command-line tools, or private resources on your computer.

What tools does Ollama MCP provide in TypingMind?

Ollama exposes MCP capabilities that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use Ollama MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If Ollama requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter πŸ‘‡