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`)
{
"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, 2026Ollama MCP Discord Bot
A Discord bot powered by Ollama and MCP servers, providing AI-powered interactions.
Prerequisites
- Python 3.8+
uvpackage manager
Installation
-
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 -
Clone the Repository:
git clone https://github.com/yourusername/ollama-mcp-discord.git cd ollama-mcp-discord -
Create and Activate Virtual Environment:
uv venv source .venv/bin/activate # macOS/Linux # OR .venv\Scripts\activate # Windows -
Install Project Dependencies:
uv pip install . -
Install Development Dependencies (optional):
uv pip install .[dev]
Configuration
-
Copy Environment Template:
cp .env.example .env -
Edit
.envand 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
- Clone this repository
- Install dependencies:
uv pip install -r requirements.txt - Configure environment variables in
.env - 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
-
Memory Server: Stores and retrieves contextual information
- Default Endpoint:
http://localhost:3100 - Package:
@modelcontextprotocol/server-memory
- Default Endpoint:
-
Fetch Server: Retrieves web content
- Default Endpoint:
http://localhost:3101 - Package:
mcp-server-fetch
- Default Endpoint:
-
Puppeteer Server: Enables browser automation
- Default Endpoint:
http://localhost:3102 - Package:
@modelcontextprotocol/server-puppeteer
- Default Endpoint:
-
Sequential Thinking Server: Supports multi-step reasoning
- Default Endpoint:
http://localhost:3103 - Package:
@modelcontextprotocol/server-sequential-thinking
- Default Endpoint:
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
-
Server Not Starting
- Ensure all required packages are installed
- Check that the specified command exists
- Verify network ports are available
-
Connection Errors
- Confirm servers are running on expected ports
- Check firewall settings
- Ensure no other applications are using the ports
Debugging Steps
-
Verify server installation:
npx -y @modelcontextprotocol/server-memory --version -
Check port availability:
# macOS/Linux lsof -i :3100 # Replace with specific port # Windows netstat -ano | findstr :3100 -
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 URLFETCH_SERVER_ENDPOINT: Custom fetch server URLPUPPETEER_SERVER_ENDPOINT: Custom puppeteer server URLSEQUENTIAL_THINKING_SERVER_ENDPOINT: Custom sequential thinking server URLMCP_CONFIG_PATH: Path to MCP configuration file (default:mcp.json)
Security Considerations
- Use
ALLOW_DANGEROUS=falsefor 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
- The bot maintains conversation history for context
- You can use any Ollama model that's installed on your server
- 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:
-
Using a Slash Command:
/set_system_message Your custom system message here -
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 wrapperpydantic: Data validation and settings managementhttpx: Modern async HTTP clientollama: Python client for Ollamapython-dotenv: Environment variable managementlangchain: (Optional) LLM conversation managementpython-daemon: (Optional) Process managementstructlog: (Optional) Structured logging
Architecture
The bot's architecture consists of these key components:
- Discord Bot: Handles Discord events and commands
- Ollama Client: Communicates with the Ollama API
- MCP Clients: Interface with various MCP servers
- Session Management: Maintains conversation state
- Configuration: Pydantic-based settings management
- HTTP Client: Shared HTTPX-based client for API requests