# MCP Platform [![Tests](https://github.com/MichaelYagi/mcp-platform/actions/workflows/ci.yml/badge.svg)](https://github.com/MichaelYagi/mcp-platform/actions/workflows/ci.yml) Local MCP runtime with multi-agent orchestration, distributed tool servers, ML-powered media recommendations, persistent cross-session memory, and a proactive agent scheduler. ⚠️ **Experimental** — intended for personal and experimental use only, not for production deployment. --- ## Table of Contents - [Prerequisites](#prerequisites) - [1. Quick Start](#1-quick-start) - [2. Using MCP Servers with Other Clients](#2-using-mcp-servers-with-other-clients) - [3. Client Configuration](#3-client-configuration) - [4. Adding Custom Tools](#4-adding-custom-tools) - [5. Distributed Mode (A2A Protocol)](#5-distributed-mode-a2a-protocol) - [6. Testing](#6-testing) - [7. Architecture](#7-architecture) - [8. RAG & Conversation Memory](#8-rag--conversation-memory) - [9. Persistent Memory & Proactive Agents](#9-persistent-memory--proactive-agents) - [10. Intent Patterns & Troubleshooting](#10-intent-patterns--troubleshooting) - [License](#license) --- ## Prerequisites * Python 3.12+ * 16GB+ RAM recommended * Ollama installed --- ## 1. Quick Start ### Install Dependencies ```bash cd mcp-platform python3 -m venv .venv source .venv/bin/activate # Linux/macOS .venv\Scripts\activate # Windows PowerShell pip install -r requirements.txt ``` > **WSL2 note:** creating `.venv` inside `/mnt/c/` fails because NTFS does not support the Unix symlinks that venvs require. Create the venv in the Linux filesystem instead: > ```bash > python3 -m venv /home/$USER/.virtualenvs/mcp_platform > source /home/$USER/.virtualenvs/mcp_platform/bin/activate > pip install -r requirements.txt > ``` ### LLM Backend ```bash curl -fsSL https://ollama.com/install.sh | sh OLLAMA_HOST=0.0.0.0:11434 ollama serve ollama pull qwen2.5:14b-instruct-q4_K_M # primary inference (recommended — any tool-calling model works) ollama pull qwen2.5:0.5b # routing classifier (fast pre-flight intent detection) ollama pull bge-large # RAG document embeddings ollama pull qwen3-vl:8b-instruct # vision / image analysis ``` > **GGUF alternative:** local GGUF files (e.g. from Hugging Face) work too — download the file and run `:gguf add ` in the prompt. No config editing needed. > > **sentence-transformers models** (memory embeddings + RAG reranker) download automatically on first use — no manual pull needed. ### Start the Client ```bash python client.py ``` Access web UI at: `http://localhost:9000/client/ui/index.html` --- ## 2. Using MCP Servers with Other Clients Add to your MCP client config (e.g., `claude_desktop_config.json`): ```json { "mcpServers": { "code_assistant": { "command": "/path/to/mcp-platform/.venv/bin/python", "args": ["/path/to/mcp-platform/servers/code_assistant/server.py"] } } } ``` **Windows paths:** `"command": "C:\\path\\to\\mcp-platform\\.venv\\Scripts\\python.exe"` **Available servers:** - `code_assistant` - AI-powered code analysis, generation, and refactoring (12 tools) - `code_review` - Code review, search, and bug fixing (3 tools) - `code_runner` - Python/bash execution sandbox (4 tools) - `discord` - Discord channel notifications via webhook (2 tools) ⚠️ *Requires `DISCORD_WEBHOOK_URL`* - `github` - GitHub repo clone, browse, and cleanup (4 tools) ⚠️ *Requires `GITHUB_TOKEN` for private repos* - `google` - Gmail + Google Calendar (13 tools) ⚠️ *Requires Google setup (Apps Script or OAuth — see [Google Setup](#google-setup))* - `image` - Image search, analysis, and AI generation (6 tools) ⚠️ *Requires `SERPER_API_KEY` for search; generation is free* - `location` - Weather, time, location (3 tools) — uses Open-Meteo (free, no key); falls back to OpenWeatherMap if `OPENWEATHER_API_KEY` is set - `plex` - Media library + ML recommendations (18 tools) ⚠️ *Requires `PLEX_URL`, `PLEX_TOKEN`* - `rag` - Vector search and management (8 tools) ⚠️ *Requires Ollama + `bge-large`* - `system` - System info and processes (3 tools) - `text` - Text processing and web search (8 tools) - `trilium` - Trilium notes integration (11 tools) ⚠️ *Requires `TRILIUM_URL`, `TRILIUM_TOKEN`* --- ## 3. Client Configuration ### Environment Variables Create `.env` in project root: ```bash # === LLM Backend === OLLAMA_BASE_URL=http://127.0.0.1:11434 # Use 127.0.0.1 for local; LAN IP requires OLLAMA_HOST=0.0.0.0 on the server OLLAMA_VISION_MODEL=qwen3-vl:8b-instruct MAX_MESSAGE_HISTORY=30 LLM_MESSAGE_WINDOW=15 # Sliding window of messages sent to LLM; older turns fall into Conversation RAG LLM_TEMPERATURE=0.3 OLLAMA_NUM_CTX=8192 # KV cache / context window size OLLAMA_NUM_PREDICT=4096 # Max tokens the LLM will generate per response OLLAMA_REPEAT_PENALTY=1.1 # Penalise token repetition (1.0 = disabled) IMAGE_MODEL=flux # Model used for AI image generation # === GGUF Configuration === GGUF_GPU_LAYERS=-1 GGUF_CONTEXT_SIZE=4096 GGUF_BATCH_SIZE=512 # === API Keys === PLEX_URL=http://localhost:32400 PLEX_TOKEN=your_token_here TRILIUM_URL=http://localhost:8888 TRILIUM_TOKEN=your_token_here SHASHIN_BASE_URL=http://localhost:6624/ SHASHIN_API_KEY=your_key_here SERPER_API_KEY=your_key_here OLLAMA_TOKEN=your_token_here LANGSEARCH_API_KEY=your_key_here # fallback search when Ollama weekly limit is reached OPENWEATHER_API_KEY=your_key_here # fallback weather when Open-Meteo is unavailable DISCORD_WEBHOOK_URL=your_webhook_url_here # === Google Apps Script (alternative to OAuth for Gmail/Calendar) === # Paste PASTE_INTO_GOOGLE_APPS_SCRIPT.js into script.google.com, deploy as a Web App, # then set the URL with your SECRET_KEY appended as ?key=... # When set, ALL Google tools use the script instead of OAuth. GOOGLE_APPS_SCRIPT_URL=https://script.google.com/macros/s/.../exec?key= # === A2A Protocol === A2A_ENDPOINTS=http://localhost:8010 A2A_EXPOSED_TOOLS= # === Performance Tuning === CONCURRENT_LIMIT=3 EMBEDDING_BATCH_SIZE=50 DB_FLUSH_BATCH_SIZE=50 # === Tool Control === DISABLED_TOOLS=plex:* # === Location === DEFAULT_CITY=Vancouver DEFAULT_STATE=BC DEFAULT_COUNTRY=Canada DEFAULT_TIMEZONE=America/Vancouver ``` ### Recommended Setup ```bash ollama pull qwen2.5:14b-instruct-q4_K_M # primary inference — any tool-calling model works; 14b q4 is a good default ollama pull qwen2.5:0.5b # routing classifier — small/fast; set LLM_ROUTING_MODEL=qwen2.5:0.5b in .env ollama pull bge-large # required for RAG ollama pull qwen3-vl:8b-instruct # required for image tools # sentence-transformers models (memory embeddings + reranker) auto-download on first use ``` > **GGUF files:** download any GGUF (e.g. from Hugging Face) and run `:gguf add ` in the prompt — no config editing needed. Minimal `.env` to get started: ```env OLLAMA_VISION_MODEL=qwen3-vl:8b-instruct DISABLED_TOOLS=plex:*,image_tools:shashin_analyze,shashin_random,shashin_search OLLAMA_TOKEN= SERPER_API_KEY= ``` ### Feature Requirements | Feature | Required env vars | Additional setup | |---------|-------------------|------------------| | Gmail + Google Calendar | — | Google setup — Apps Script (simpler) or OAuth (see [Google Setup](#google-setup)) | | Discord notifications | `DISCORD_WEBHOOK_URL` | Create webhook in Discord channel settings | | RAG ingestion & search | — | Ollama running + `bge-large` pulled | | Plex media library | `PLEX_URL`, `PLEX_TOKEN` | Plex Media Server running | | Web search (primary) | `OLLAMA_TOKEN` | Ollama account + API key | | Web search (fallback) | `LANGSEARCH_API_KEY` | LangSearch account — [dashboard](https://langsearch.com/dashboard). Used automatically when Ollama's weekly limit is reached or returns empty. | | Image search | `SERPER_API_KEY` | Serper account + API key | | AI image generation | — | Free via Pollinations.ai — no key required | | Trilium notes | `TRILIUM_URL`, `TRILIUM_TOKEN` | Trilium server running | | Shashin photo gallery | `SHASHIN_BASE_URL`, `SHASHIN_API_KEY` | Shashin server running | | A2A distributed mode | `A2A_ENDPOINTS` | Remote A2A server running | ### Available Commands ``` :jobs - List all scheduled jobs :jobs pause