Skip to content
Conduit

mcp server

ollama-mcp

thomwebb/ollama-mcpcommunitylistedunreviewed

Set up

Runs on your computer. Pick your agent and operating system.

Before you start

  • uv (`curl -LsSf https://astral.sh/uv/install.sh | sh`)
~/Library/Application Support/Claude/claude_desktop_config.json
{
  "mcpServers": {
    "thomwebb-ollama-mcp": {
      "command": "uvx",
      "args": [
        "ollama-mcp-discord"
      ]
    }
  }
}

same format Cursor, GitHub Copilot CLI, Junie, JetBrains AI Assistant, Augment (Auggie CLI), Factory Droid, Kiro, Devin CLI +12

Values in angle brackets are placeholders. Restart Claude Desktop after editing its config.Claude Desktop docs

README

synced Oct 14, 2026

Ollama MCP Discord Bot

A Discord bot powered by Ollama and MCP servers, providing AI-powered interactions.

Prerequisites

  • Python 3.8+
  • uv package manager

Installation

  1. Install uv:

    # macOS/Linux
    curl -LsSf https://astral.sh/uv/install.sh | sh
    
    # Windows (PowerShell)
    Invoke-WebRequest -Uri https://astral.sh/uv/install.ps1 -OutFile install.ps1; powershell -ExecutionPolicy Bypass -File ./install.ps1
    
  2. Clone the Repository:

    git clone https://github.com/yourusername/ollama-mcp-discord.git
    cd ollama-mcp-discord
    
  3. Create and Activate Virtual Environment:

    uv venv
    source .venv/bin/activate  # macOS/Linux
    # OR
    .venv\Scripts\activate     # Windows
    
  4. Install Project Dependencies:

    uv pip install .
    
  5. Install Development Dependencies (optional):

    uv pip install .[dev]
    

Configuration

  1. Copy Environment Template:

    cp .env.example .env
    
  2. Edit .env and Add Your Discord Token:

    DISCORD_TOKEN=your_discord_bot_token_here
    

Running the Bot

python -m ollama_mcp_discord

Development

Running Tests

uv pip install .[dev]
make test

Code Formatting

black .
isort .

Contributing

Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Features

  • Chat with AI models using Discord
  • Select different AI models
  • Create and manage memories
  • Set custom system messages

Commands

Basic Commands

  • !chat <message> - Chat with the AI model
  • !model <model_name> - Select a different AI model
  • !remember <content> - Create a new memory
  • !system_message <message> - Set a custom system message for the AI
  • !help - Show available commands

Quick Start

  1. Clone this repository
  2. Install dependencies: uv pip install -r requirements.txt
  3. Configure environment variables in .env
  4. Start the bot: python -m ollama_mcp_discord

Configuration

Create a .env file with the following variables:

DISCORD_TOKEN=your_discord_bot_token
OLLAMA_HOST=http://localhost:11434
DEFAULT_MODEL=llama3

MCP Server Configuration

The Ollama-MCP Discord bot uses Model Context Protocol (MCP) servers to extend its capabilities. These servers provide specialized services like memory management, web fetching, browser automation, and sequential reasoning.

Server Types

  1. Memory Server: Stores and retrieves contextual information

    • Default Endpoint: http://localhost:3100
    • Package: @modelcontextprotocol/server-memory
  2. Fetch Server: Retrieves web content

    • Default Endpoint: http://localhost:3101
    • Package: mcp-server-fetch
  3. Puppeteer Server: Enables browser automation

    • Default Endpoint: http://localhost:3102
    • Package: @modelcontextprotocol/server-puppeteer
  4. Sequential Thinking Server: Supports multi-step reasoning

    • Default Endpoint: http://localhost:3103
    • Package: @modelcontextprotocol/server-sequential-thinking

Configuration File

Create a mcp.json file in the project root to configure MCP servers:

{
  "mcpServers": {
    "memory": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-memory"],
      "env": {
        "MEMORY_FILE_PATH": "/path/to/memory-storage.json"
      }
    },
    "fetch": {
      "command": "uvx",
      "args": ["mcp-server-fetch"]
    },
    "mcp-puppeteer": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-puppeteer"],
      "env": {
        "PUPPETEER_LAUNCH_OPTIONS": "{ \"headless\": true}",
        "ALLOW_DANGEROUS": "false"
      }
    },
    "sequential-thinking": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-sequential-thinking"]
    }
  }
}

Manual Server Management

If automatic server startup fails, you can manually start servers:

# Memory Server
npx -y @modelcontextprotocol/server-memory

# Fetch Server
uvx mcp-server-fetch

# Puppeteer Server
npx -y @modelcontextprotocol/server-puppeteer

# Sequential Thinking Server
npx -y @modelcontextprotocol/server-sequential-thinking

Troubleshooting MCP Servers

Common Issues

  1. Server Not Starting

    • Ensure all required packages are installed
    • Check that the specified command exists
    • Verify network ports are available
  2. Connection Errors

    • Confirm servers are running on expected ports
    • Check firewall settings
    • Ensure no other applications are using the ports

Debugging Steps

  1. Verify server installation:

    npx -y @modelcontextprotocol/server-memory --version
    
  2. Check port availability:

    # macOS/Linux
    lsof -i :3100  # Replace with specific port
    
    # Windows
    netstat -ano | findstr :3100
    
  3. Run servers with verbose logging:

    # Add verbose flag or environment variables for debugging
    DEBUG=* npx -y @modelcontextprotocol/server-memory
    

Environment Variables

  • MEMORY_SERVER_ENDPOINT: Custom memory server URL
  • FETCH_SERVER_ENDPOINT: Custom fetch server URL
  • PUPPETEER_SERVER_ENDPOINT: Custom puppeteer server URL
  • SEQUENTIAL_THINKING_SERVER_ENDPOINT: Custom sequential thinking server URL
  • MCP_CONFIG_PATH: Path to MCP configuration file (default: mcp.json)

Security Considerations

  • Use ALLOW_DANGEROUS=false for Puppeteer server
  • Set specific memory file paths
  • Limit server exposure to trusted networks

Usage

The bot provides several ways to interact:

Text Commands

  • !chat <message> - Have a conversation with the AI model

    !chat What is the capital of France?
    !chat Can you help me with Python programming?
    
  • !model <model_name> - Switch to a different Ollama model

    !model llama3
    !model mistral
    
  • !remember <content> - Store information in the AI's memory

    !remember My favorite color is blue
    !remember Python is a programming language
    
  • !help - Display help information about all available commands

Automatic Responses

  • The bot only responds to whole words, not parts of words

Tips

  1. The bot maintains conversation history for context
  2. You can use any Ollama model that's installed on your server
  3. The bot has access to several tools through MCP servers:
    • Memory: Store and retrieve information
    • Fetch: Get information from the web
    • Puppeteer: Control a browser
    • Sequential Thinking: Break down complex problems

Example Conversation

User: !model llama3
Bot: Model set to llama3

User: !chat Tell me about Python
Bot: [Detailed response about Python]

User: hello
Bot: Hello there! How can I help you today?

User: !remember Python is a high-level programming language
Bot: I'll remember that! Memory created with ID: [memory_id]

Development

Check the ROADMAP.md file for implementation status and upcoming features.

System Message Management

Setting System Message

You can set the system message for the model in two ways:

  1. Using a Slash Command:

    /set_system_message Your custom system message here
    
  2. Programmatically:

    from system_message import set_system_message
    
    set_system_message("Your custom system message here")
    

Retrieving System Message

from system_message import get_system_message

current_message = get_system_message()
print(current_message)

Clearing System Message

from system_message import clear_system_message

clear_system_message()

The system message is stored in ~/.mcp_system_message.json and persists between sessions.

Requirements

  • Python 3.11 or newer
  • Ollama server running locally or remotely
  • Discord Bot Token
  • MCP servers (optional, for enhanced capabilities)

Dependencies

  • nextcord: Discord API wrapper
  • pydantic: Data validation and settings management
  • httpx: Modern async HTTP client
  • ollama: Python client for Ollama
  • python-dotenv: Environment variable management
  • langchain: (Optional) LLM conversation management
  • python-daemon: (Optional) Process management
  • structlog: (Optional) Structured logging

Architecture

The bot's architecture consists of these key components:

  1. Discord Bot: Handles Discord events and commands
  2. Ollama Client: Communicates with the Ollama API
  3. MCP Clients: Interface with various MCP servers
  4. Session Management: Maintains conversation state
  5. Configuration: Pydantic-based settings management
  6. HTTP Client: Shared HTTPX-based client for API requests
↑↓ navigate openesc close