MCP-Docs Installation
Setup, Konfiguration und Registrierung des MCP-Docs Servers.
Voraussetzungen
- Python 3.10+
- MariaDB/MySQL mit ki_dev und ki_protokoll Datenbanken
- Claude Code CLI
Installation
1. Verzeichnis erstellen
mkdir -p /var/www/mcp-servers/mcp_docs
cd /var/www/mcp-servers/mcp_docs
2. Virtual Environment
python3 -m venv venv
source venv/bin/activate
pip install mcp pymysql python-dotenv
3. Environment-Datei
# .env
# Datenbank (ki_dev für Dokumentation, ki_protokoll für Logging)
DB_HOST=localhost
DB_PORT=3306
DB_USER=root
DB_PASSWORD=geheim
4. Datenbank-Tabelle
-- In ki_dev ausführen
CREATE TABLE IF NOT EXISTS dokumentation (
id INT AUTO_INCREMENT PRIMARY KEY,
parent_id INT DEFAULT NULL,
depth TINYINT UNSIGNED DEFAULT 0,
sort_order INT UNSIGNED DEFAULT 0,
slug VARCHAR(100) NOT NULL,
path VARCHAR(500) NOT NULL UNIQUE,
title VARCHAR(200) NOT NULL,
description VARCHAR(500),
content LONGTEXT NOT NULL,
content_format ENUM('html','markdown') DEFAULT 'html',
status ENUM('draft','published','archived') DEFAULT 'published',
version INT UNSIGNED DEFAULT 1,
created_by VARCHAR(100) DEFAULT 'system',
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_by VARCHAR(100),
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (parent_id) REFERENCES dokumentation(id) ON DELETE SET NULL
);
Registrierung in Claude Code
# MCP-Server registrieren
claude mcp add mcp-docs \
/var/www/mcp-servers/mcp_docs/venv/bin/python \
/var/www/mcp-servers/mcp_docs/server.py
# Registrierung prüfen
claude mcp list
Test
# In Claude Code Session
docs_list(compact=True)
docs_statistics()
docs_hierarchy()
Fehlerbehebung
Server startet nicht
# Manuell testen
/var/www/mcp-servers/mcp_docs/venv/bin/python \
/var/www/mcp-servers/mcp_docs/server.py
# Logs prüfen
tail -f ~/.claude/logs/mcp-*.log
Datenbankverbindung fehlgeschlagen
- .env Credentials prüfen
- DB-User Berechtigungen prüfen
- MariaDB-Service Status:
systemctl status mariadb
Tool nicht gefunden
# MCP-Server neu registrieren
claude mcp remove mcp-docs
claude mcp add mcp-docs ...
Berechtigungen
| DB-User | Datenbank | Rechte |
|---|---|---|
root | ki_dev | SELECT, INSERT, UPDATE, DELETE auf dokumentation |
root | ki_protokoll | INSERT auf mcp_log |
Konfiguration (config.py)
from pathlib import Path
from dotenv import load_dotenv
import os
load_dotenv(Path(__file__).parent / ".env")
# Datenbank-Konfiguration
DB_CONFIG = {
"host": os.getenv("DB_HOST", "localhost"),
"port": int(os.getenv("DB_PORT", 3306)),
"user": os.getenv("DB_USER"),
"password": os.getenv("DB_PASSWORD"),
}
# Dokumentation in ki_dev
DOCS_DATABASE = "ki_dev"
# Logging in ki_protokoll
LOG_DATABASE = "ki_protokoll"]]>