{"id":"e3d98280-af5c-4d12-b909-822b328ead38","slug":"thomwebb-ollama-mcp","kind":"mcp","name":"ollama-mcp","summary":"","owner":"thomwebb","repoUrl":"https://github.com/thomwebb/ollama-mcp","license":"MIT","licenseTier":"permissive","trust":"community","stars":0,"match":null,"fewStars":true,"format":"mcp","createdAt":"2025-04-04T06:20:22.000Z","addedAt":"2026-10-14T23:45:18.729Z","logoUrl":"https://avatars.githubusercontent.com/u/11341191?u=86d5d71a21da972495d6b633b72cc3e4ccbbd69f&v=4","linkOnly":false,"collection":null,"skillPath":null,"categories":["utilities"],"tags":[],"runtime":"python","local":true,"cloudCapable":false,"cloudCapability":"unknown","cloudReadyOnPlatform":false,"needsApiKey":false,"reviewed":false,"syncedAt":"2026-10-17T23:45:48.876Z","sample":false,"url":"https://conduits.dev/tools/thomwebb-ollama-mcp","language":"Python","transports":["stdio"],"install":{"pypi":"ollama-mcp-discord"},"requirements":{"env":[],"upstreamMayCharge":false},"tools":null,"readme":"# Ollama MCP Discord Bot\n\nA Discord bot powered by Ollama and MCP servers, providing AI-powered interactions.\n\n## Prerequisites\n\n- Python 3.8+\n- `uv` package manager\n\n## Installation\n\n1. **Install uv**:\n\n   ```bash\n   # macOS/Linux\n   curl -LsSf https://astral.sh/uv/install.sh | sh\n\n   # Windows (PowerShell)\n   Invoke-WebRequest -Uri https://astral.sh/uv/install.ps1 -OutFile install.ps1; powershell -ExecutionPolicy Bypass -File ./install.ps1\n   ```\n\n1. **Clone the Repository**:\n\n   ```bash\n   git clone https://github.com/yourusername/ollama-mcp-discord.git\n   cd ollama-mcp-discord\n   ```\n\n1. **Create and Activate Virtual Environment**:\n\n   ```bash\n   uv venv\n   source .venv/bin/activate  # macOS/Linux\n   # OR\n   .venv\\Scripts\\activate     # Windows\n   ```\n\n1. **Install Project Dependencies**:\n\n   ```bash\n   uv pip install .\n   ```\n\n1. **Install Development Dependencies** (optional):\n\n   ```bash\n   uv pip install .[dev]\n   ```\n\n## Configuration\n\n1. **Copy Environment Template**:\n\n   ```bash\n   cp .env.example .env\n   ```\n\n1. **Edit `.env` and Add Your Discord Token**:\n\n   ```bash\n   DISCORD_TOKEN=your_discord_bot_token_here\n   ```\n\n## Running the Bot\n\n```bash\npython -m ollama_mcp_discord\n```\n\n## Development\n\n### Running Tests\n\n```bash\nuv pip install .[dev]\nmake test\n```\n\n### Code Formatting\n\n```bash\nblack .\nisort .\n```\n\n## Contributing\n\nPlease read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct and the process for submitting pull requests.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Features\n\n- Chat with AI models using Discord\n- Select different AI models\n- Create and manage memories\n- Set custom system messages\n\n## Commands\n\n### Basic Commands\n\n- `!chat <message>` - Chat with the AI model\n- `!model <model_name>` - Select a different AI model\n- `!remember <content>` - Create a new memory\n- `!system_message <message>` - Set a custom system message for the AI\n- `!help` - Show available commands\n\n## Quick Start\n\n1. Clone this repository\n2. Install dependencies: `uv pip install -r requirements.txt`\n3. Configure environment variables in `.env`\n4. Start the bot: `python -m ollama_mcp_discord`\n\n## Configuration\n\nCreate a `.env` file with the following variables:\n\n```bash\nDISCORD_TOKEN=your_discord_bot_token\nOLLAMA_HOST=http://localhost:11434\nDEFAULT_MODEL=llama3\n```\n\n## MCP Server Configuration\n\nThe 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.\n\n### Server Types\n\n1. **Memory Server**: Stores and retrieves contextual information\n\n   - Default Endpoint: `http://localhost:3100`\n   - Package: `@modelcontextprotocol/server-memory`\n\n2. **Fetch Server**: Retrieves web content\n\n   - Default Endpoint: `http://localhost:3101`\n   - Package: `mcp-server-fetch`\n\n3. **Puppeteer Server**: Enables browser automation\n\n   - Default Endpoint: `http://localhost:3102`\n   - Package: `@modelcontextprotocol/server-puppeteer`\n\n4. **Sequential Thinking Server**: Supports multi-step reasoning\n   - Default Endpoint: `http://localhost:3103`\n   - Package: `@modelcontextprotocol/server-sequential-thinking`\n\n### Configuration File\n\nCreate a `mcp.json` file in the project root to configure MCP servers:\n\n```json\n{\n  \"mcpServers\": {\n    \"memory\": {\n      \"command\": \"npx\",\n      \"args\": [\"-y\", \"@modelcontextprotocol/server-memory\"],\n      \"env\": {\n        \"MEMORY_FILE_PATH\": \"/path/to/memory-storage.json\"\n      }\n    },\n    \"fetch\": {\n      \"command\": \"uvx\",\n      \"args\": [\"mcp-server-fetch\"]\n    },\n    \"mcp-puppeteer\": {\n      \"command\": \"npx\",\n      \"args\": [\"-y\", \"@modelcontextprotocol/server-puppeteer\"],\n      \"env\": {\n        \"PUPPETEER_LAUNCH_OPTIONS\": \"{ \\\"headless\\\": true}\",\n        \"ALLOW_DANGEROUS\": \"false\"\n      }\n    },\n    \"sequential-thinking\": {\n      \"command\": \"npx\",\n      \"args\": [\"-y\", \"@modelcontextprotocol/server-sequential-thinking\"]\n    }\n  }\n}\n```\n\n### Manual Server Management\n\nIf automatic server startup fails, you can manually start servers:\n\n```bash\n# Memory Server\nnpx -y @modelcontextprotocol/server-memory\n\n# Fetch Server\nuvx mcp-server-fetch\n\n# Puppeteer Server\nnpx -y @modelcontextprotocol/server-puppeteer\n\n# Sequential Thinking Server\nnpx -y @modelcontextprotocol/server-sequential-thinking\n```\n\n### Troubleshooting MCP Servers\n\n#### Common Issues\n\n1. **Server Not Starting**\n\n   - Ensure all required packages are installed\n   - Check that the specified command exists\n   - Verify network ports are available\n\n2. **Connection Errors**\n   - Confirm servers are running on expected ports\n   - Check firewall settings\n   - Ensure no other applications are using the ports\n\n#### Debugging Steps\n\n1. Verify server installation:\n\n   ```bash\n   npx -y @modelcontextprotocol/server-memory --version\n   ```\n\n2. Check port availability:\n\n   ```bash\n   # macOS/Linux\n   lsof -i :3100  # Replace with specific port\n\n   # Windows\n   netstat -ano | findstr :3100\n   ```\n\n3. Run servers with verbose logging:\n   ```bash\n   # Add verbose flag or environment variables for debugging\n   DEBUG=* npx -y @modelcontextprotocol/server-memory\n   ```\n\n### Environment Variables\n\n- `MEMORY_SERVER_ENDPOINT`: Custom memory server URL\n- `FETCH_SERVER_ENDPOINT`: Custom fetch server URL\n- `PUPPETEER_SERVER_ENDPOINT`: Custom puppeteer server URL\n- `SEQUENTIAL_THINKING_SERVER_ENDPOINT`: Custom sequential thinking server URL\n- `MCP_CONFIG_PATH`: Path to MCP configuration file (default: `mcp.json`)\n\n### Security Considerations\n\n- Use `ALLOW_DANGEROUS=false` for Puppeteer server\n- Set specific memory file paths\n- Limit server exposure to trusted networks\n\n## Usage\n\nThe bot provides several ways to interact:\n\n### Text Commands\n\n- `!chat <message>` - Have a conversation with the AI model\n\n  ```text\n  !chat What is the capital of France?\n  !chat Can you help me with Python programming?\n  ```\n\n- `!model <model_name>` - Switch to a different Ollama model\n\n  ```text\n  !model llama3\n  !model mistral\n  ```\n\n- `!remember <content>` - Store information in the AI's memory\n\n  ```text\n  !remember My favorite color is blue\n  !remember Python is a programming language\n  ```\n\n  ```text\n\n  ```\n\n  ```text\n\n  ```\n\n- `!help` - Display help information about all available commands\n\n### Automatic Responses\n\n- The bot only responds to whole words, not parts of words\n\n### Tips\n\n1. The bot maintains conversation history for context\n2. You can use any Ollama model that's installed on your server\n3. The bot has access to several tools through MCP servers:\n   - Memory: Store and retrieve information\n   - Fetch: Get information from the web\n   - Puppeteer: Control a browser\n   - Sequential Thinking: Break down complex problems\n\n### Example Conversation\n\n```text\nUser: !model llama3\nBot: Model set to llama3\n\nUser: !chat Tell me about Python\nBot: [Detailed response about Python]\n\nUser: hello\nBot: Hello there! How can I help you today?\n\nUser: !remember Python is a high-level programming language\nBot: I'll remember that! Memory created with ID: [memory_id]\n```\n\n## Development\n\nCheck the ROADMAP.md file for implementation status and upcoming features.\n\n## System Message Management\n\n### Setting System Message\n\nYou can set the system message for the model in two ways:\n\n1. Using a Slash Command:\n\n   ```\n   /set_system_message Your custom system message here\n   ```\n\n2. Programmatically:\n\n   ```python\n   from system_message import set_system_message\n\n   set_system_message(\"Your custom system message here\")\n   ```\n\n### Retrieving System Message\n\n```python\nfrom system_message import get_system_message\n\ncurrent_message = get_system_message()\nprint(current_message)\n```\n\n### Clearing System Message\n\n```python\nfrom system_message import clear_system_message\n\nclear_system_message()\n```\n\nThe system message is stored in `~/.mcp_system_message.json` and persists between sessions.\n\n## Requirements\n\n- Python 3.11 or newer\n- Ollama server running locally or remotely\n- Discord Bot Token\n- MCP servers (optional, for enhanced capabilities)\n\n### Dependencies\n\n- `nextcord`: Discord API wrapper\n- `pydantic`: Data validation and settings management\n- `httpx`: Modern async HTTP client\n- `ollama`: Python client for Ollama\n- `python-dotenv`: Environment variable management\n- `langchain`: (Optional) LLM conversation management\n- `python-daemon`: (Optional) Process management\n- `structlog`: (Optional) Structured logging\n\n## Architecture\n\nThe bot's architecture consists of these key components:\n\n1. **Discord Bot**: Handles Discord events and commands\n2. **Ollama Client**: Communicates with the Ollama API\n3. **MCP Clients**: Interface with various MCP servers\n4. **Session Management**: Maintains conversation state\n5. **Configuration**: Pydantic-based settings management\n6. **HTTP Client**: Shared HTTPX-based client for API requests\n"}