MCP-Tasks Installation
Setup, Registrierung und Test des MCP-Tasks Servers.
Voraussetzungen
- Python 3.10+
- MariaDB/MySQL
- Claude Code CLI
- Ollama (optional, für tasks_execute)
1. Verzeichnis erstellen
mkdir -p /opt/mcp-servers/mcp-tasks
cd /opt/mcp-servers/mcp-tasks
2. Virtual Environment
python3 -m venv venv
source venv/bin/activate
pip install mcp pymysql python-dotenv requests pyyaml
3. Dateien erstellen
Siehe Architektur für vollständige Verzeichnisstruktur.
# Struktur
/opt/mcp-servers/mcp-tasks/
├── server.py # Hauptdatei
├── config.py # Konfiguration
├── .env # Credentials
├── requirements.txt
├── venv/
├── domain/
│ ├── __init__.py
│ └── contracts.py
├── infrastructure/
│ ├── __init__.py
│ ├── db_connection.py
│ ├── protokoll_logger.py
│ └── task_repository.py
├── tools/
│ ├── __init__.py
│ ├── task_tools.py
│ └── quality_tools.py
└── validators/
└── __init__.py
4. .env konfigurieren
# .env erstellen
nano .env
# Berechtigungen setzen
chmod 600 .env
.env Inhalt
# Datenbank für Task-Operationen (volle CRUD-Rechte)
DB_HOST=localhost
DB_PORT=3306
DB_NAME=ki_protokoll
DB_USER=claude_code
DB_PASSWORD=SECURE_PASSWORD_HERE
# Datenbank für Logging (nur INSERT)
LOG_DB_HOST=localhost
LOG_DB_NAME=ki_protokoll
LOG_DB_USER=mcp_logger
LOG_DB_PASSWORD=DIFFERENT_SECURE_PASSWORD_HERE
# Ollama (optional)
OLLAMA_HOST=http://localhost:11434
OLLAMA_MODEL=mistral
5. Datenbank vorbereiten
Task-Tabellen erstellen
-- Haupttabelle
CREATE TABLE IF NOT EXISTS tasks (
id INT AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(255) NOT NULL,
description TEXT,
type ENUM('human_task', 'ai_task', 'mixed') DEFAULT 'ai_task',
status ENUM('pending', 'in_progress', 'completed', 'failed', 'cancelled') DEFAULT 'pending',
parent_task_id INT DEFAULT NULL,
due_date DATETIME DEFAULT NULL,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (parent_task_id) REFERENCES tasks(id) ON DELETE SET NULL,
INDEX idx_status (status),
INDEX idx_type (type)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- Zuweisungen
CREATE TABLE IF NOT EXISTS task_assignments (
id INT AUTO_INCREMENT PRIMARY KEY,
task_id INT NOT NULL,
assignee VARCHAR(100) NOT NULL,
assignee_type ENUM('human', 'ollama', 'claude', 'anthropic_api') NOT NULL,
model_name VARCHAR(100) DEFAULT NULL,
notes TEXT,
assigned_at DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (task_id) REFERENCES tasks(id) ON DELETE CASCADE,
INDEX idx_task_id (task_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- Ergebnisse
CREATE TABLE IF NOT EXISTS task_results (
id INT AUTO_INCREMENT PRIMARY KEY,
task_id INT NOT NULL,
response TEXT NOT NULL,
executor VARCHAR(100) NOT NULL,
executor_type ENUM('human', 'ollama', 'claude', 'anthropic_api') NOT NULL,
model_name VARCHAR(100) DEFAULT NULL,
status ENUM('success', 'error', 'partial') DEFAULT 'success',
tokens_input INT DEFAULT 0,
tokens_output INT DEFAULT 0,
cost_usd DECIMAL(10,6) DEFAULT 0,
duration_ms INT DEFAULT 0,
error_message TEXT,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (task_id) REFERENCES tasks(id) ON DELETE CASCADE,
INDEX idx_task_id (task_id),
INDEX idx_executor_type (executor_type)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- Kommentare (optional)
CREATE TABLE IF NOT EXISTS task_comments (
id INT AUTO_INCREMENT PRIMARY KEY,
task_id INT NOT NULL,
author VARCHAR(100) NOT NULL,
content TEXT NOT NULL,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (task_id) REFERENCES tasks(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
DB-User Berechtigungen
-- claude_code: Volle CRUD-Rechte auf Task-Tabellen
GRANT SELECT, INSERT, UPDATE, DELETE ON ki_protokoll.tasks TO 'claude_code'@'localhost';
GRANT SELECT, INSERT, UPDATE, DELETE ON ki_protokoll.task_assignments TO 'claude_code'@'localhost';
GRANT SELECT, INSERT, UPDATE, DELETE ON ki_protokoll.task_results TO 'claude_code'@'localhost';
GRANT SELECT, INSERT, UPDATE, DELETE ON ki_protokoll.task_comments TO 'claude_code'@'localhost';
-- mcp_logger: Nur INSERT auf mcp_log
GRANT INSERT ON ki_protokoll.mcp_log TO 'mcp_logger'@'localhost';
FLUSH PRIVILEGES;
6. Server testen
# Manuell starten
cd /opt/mcp-servers/mcp-tasks
source venv/bin/activate
python server.py
# Bei Erfolg: Server wartet auf stdio Input
# Strg+C zum Beenden
7. In Claude Code registrieren
User-Scope (Global)
Registrierung für alle Projekte:
claude mcp add mcp-tasks \
/opt/mcp-servers/mcp-tasks/venv/bin/python \
/opt/mcp-servers/mcp-tasks/server.py
Projekt-Scope (Lokal)
Registrierung nur für ein bestimmtes Projekt:
cd /var/www
claude mcp add mcp-tasks \
/opt/mcp-servers/mcp-tasks/venv/bin/python \
/opt/mcp-servers/mcp-tasks/server.py
8. Registrierung prüfen
# Liste aller MCP Server
claude mcp list
# Erwartete Ausgabe:
# mcp-tasks: connected
# In Claude Code Session
/mcp
9. Tools testen
# Task-Management
tasks_list()
tasks_statistics()
# Task erstellen und ausführen
tasks_create(title="Test-Task", type="ai_task")
tasks_execute(id=1, model="mistral")
# Quality-Checks
contracts_list()
quality_check(path="/var/www/dev.campus.systemische-tools.de/src")
Ollama-Integration
Für tasks_execute muss Ollama laufen:
# Ollama Status prüfen
ollama list
# Modell laden (falls nicht vorhanden)
ollama pull mistral
# Test
curl http://localhost:11434/api/tags
Troubleshooting
Server startet nicht
# Dependencies prüfen
pip list | grep -E "mcp|pymysql|dotenv"
# Python Version
python --version # Muss 3.10+ sein
# Import-Fehler finden
python -c "from tools.task_tools import register_task_tools"
Verbindungsfehler
# .env prüfen (ohne Passwörter anzuzeigen)
cat .env | grep -v PASSWORD
# DB-Verbindung testen (über MCP)
tasks_list(limit=1)
Ollama-Fehler
# Ollama Status
systemctl status ollama
# API erreichbar?
curl http://localhost:11434/api/tags
# Modell vorhanden?
ollama list | grep mistral
Permission Denied
# .env Berechtigungen
ls -la .env # Muss 600 sein
# DB-Rechte prüfen (über MCP-DB)
db_select("SHOW GRANTS FOR 'claude_code'@'localhost'")
Updates
# Dependencies aktualisieren
cd /opt/mcp-servers/mcp-tasks
source venv/bin/activate
pip install --upgrade mcp pymysql python-dotenv requests pyyaml
# Server wird beim nächsten Claude Code Start neu geladen
Deinstallation
# Aus Claude Code entfernen
claude mcp remove mcp-tasks
# Verzeichnis löschen (optional)
rm -rf /opt/mcp-servers/mcp-tasks
# Tabellen behalten oder löschen (optional)
DROP TABLE task_comments;
DROP TABLE task_results;
DROP TABLE task_assignments;
DROP TABLE tasks;
Verwandte Themen
- MCP-Tasks Übersicht
- Architektur
- Tools im Detail
- Ollama - Lokale KI-Modelle