Ollama MCP server

Provides a standardized server interface for interacting with local language models through Ollama, enabling intelligent guidance, multimodal inputs, and flexible tool integration across generation and chat completion endpoints.
Back to servers
Provider
ShadowSinger
Release date
Mar 10, 2025
Language
Python

This MCP server provides a standardized interface for interacting with Ollama services through the Model Context Protocol. It simplifies API calls to Ollama while providing structured responses and intelligent guidance for Language Learning Models.

Installation Requirements

Before getting started, make sure you have:

  • Python 3.10 or higher installed
  • Ollama installed and running

Installation Steps

# Install uv (recommended)
curl -LsSf https://astral.sh/uv/install.sh | sh

# Create and activate virtual environment
uv venv
source .venv/bin/activate  # Linux/macOS
# or
.venv\Scripts\activate  # Windows

# Install dependencies
uv pip install .

Configuration

The server uses a config.json file for configuration:

{
    "ollama": {
        "host": "http://localhost:11434",  // Ollama service address
        "timeout": 30,                     // Request timeout (seconds)
        "user_agent": "Ollama_MCP_Guidance/1.0"     // Request identifier
    },
    "api_doc": {
        "max_length": 8000,                // Maximum document content length
        "file_path": "ollama-api.md"       // API documentation path
    }
}

Usage Guide

Setting Up the Runtime Script

Since Cursor MCP needs to execute a single command from the default command line environment, it's recommended to create a custom run script.

Create an ollama-mcp-cli file (for macOS/Linux):

#!/bin/bash

# Project path configuration
PROJECT_PATH="your_project_path/Ollama_MCP_Guidance"
if [ ! -d "$PROJECT_PATH" ]; then
    echo "Error: Project directory not found at $PROJECT_PATH"
    exit 1
fi

# Run the program
cd "$PROJECT_PATH"
source .venv/bin/activate  # Activate uv virtual environment
python ollama_mcp_server.py "$@"

Set script permissions:

chmod +x ollama-mcp-cli

Note: Windows users should create an ollama-mcp-cli.bat file with appropriate adjustments.

Configuring in Cursor

  1. Start the Ollama service
  2. In the Cursor MCP configuration, use the following command:
/full_path/ollama-mcp-cli

Tip: If you place the script in your system's executable path (like /usr/local/bin/), you can simply use:

ollama-mcp-cli

Basic Usage Examples

  1. View available models:
result = await get_ollama_list()
  1. Simple conversation:
response = await simple_chat(
    model="llama2",
    prompt="Hello, please introduce yourself"
)
  1. Generate text embeddings:
embeddings = await post_generate_embeddings(
    model="nomic-embed-text",
    text=["This is a sample text"]
)

Supported Features and Limitations

API Endpoint Support Status

Endpoint Method Description Features Tool Name
- - Project starter guide - Smart project navigation ✨
- Personalized feature recommendations 🎯
- Best practices guidance 💡
get_started_guide
/api/version GET Get Ollama server version - Single response ✅
- Includes build info ✅
get_ollama_version
/api/tags GET Get list of installed models - Complete response ✅
- Includes model metadata ✅
get_ollama_list
/api/ps GET View running models - Real-time status ✅
- Resource usage data ✅
get_running_models
/api/show POST Get detailed model information - Detailed mode ✅
- Complete configuration info ✅
post_show_model
/api/chat POST Conversational interaction - Streaming output ❌
- Multi-turn dialogue ❌
- System prompts ❌
- Image input ❌
simple_chat
/api/generate POST Basic text generation - Streaming output ❌
- Context management ❌
- Raw mode ❌
- Model JSON output ❌
- Tool JSON wrapping ✅
simple_generate
/api/embed POST Generate text vector representations - Batch processing ✅
- Fixed dimension output ✅
post_generate_embeddings
/api/embeddings POST Generate text vector representations (deprecated) - Batch processing ✅
- Fixed dimension output ✅
- Replaced by /api/embed ⚠️
post_generate_embeddings

Feature Limitations

  1. Basic Functionality Limitations

    • Only supports non-streaming responses (returns results all at once)
    • Does not support multi-turn conversation history
    • Does not support system prompts
    • Does not support context management
    • Does not support raw mode and specific format outputs
  2. Management Function Limitations

    • For security reasons, the following admin-level operations are not supported:
      • Model copying (/api/copy)
      • Model downloading (/api/pull)
      • Model deletion (/api/delete)
    • Do not modify API endpoint paths in the configuration file
  3. Experimental Features

    • Image processing functionality is not fully implemented and tested
    • Some advanced features (parameter tuning, template customization) are not yet implemented

How to add this MCP server to 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 > MCP and click "Add new global MCP server".

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

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-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 explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

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