MCP-Docs Server

Erstellt: 2025-12-20 | Aktualisiert: 2025-12-27

Model Context Protocol Server für Dokumentations-Management. Verwaltet die hierarchische Dokumentation in der Datenbank.

Version1.0.0
Transportstdio
RuntimePython 3.10+
Pfad/opt/mcp-servers/mcp-docs/
Datenbankki_dev.dokumentation
Loggingki_dev.mcp_log

Zweck

Kapitel

KapitelBeschreibung
ToolsAlle 9 MCP-Tools im Detail
ArchitekturVerzeichnisstruktur, Komponenten, Layer
InstallationSetup, Konfiguration, Registrierung

Schnellstart

# Registrierung in Claude Code
claude mcp add mcp-docs \
  /opt/mcp-servers/mcp-docs/venv/bin/python \
  /opt/mcp-servers/mcp-docs/server.py

# Status prüfen
claude mcp list

Verfügbare Tools (9)

ToolBeschreibung
docs_listDokumente auflisten mit Filtern
docs_getDokument nach ID oder Pfad abrufen
docs_createNeues Dokument erstellen
docs_updateDokument bearbeiten
docs_deleteDokument löschen
docs_movePosition im Baum ändern
docs_hierarchyKompletter Dokumentationsbaum
docs_searchVolltextsuche
docs_statisticsStatistiken abrufen

Beispiele

# Alle Dokumente auflisten (Token-sparend)
docs_list(compact=True)

# Dokument nach Pfad abrufen
docs_get(path="/server/ssh")

# Dokument mit Kindern und Breadcrumb
docs_get(id=1, include_children=True, include_breadcrumb=True)

# Volltextsuche
docs_search(query="SSH")

# Hierarchie anzeigen
docs_hierarchy()

# Statistiken
docs_statistics()

Token-Optimierung

Verwandte Themen

MCP-Docs Tools

Erstellt: 2025-12-20 | Aktualisiert: 2025-12-20

Alle 9 verfügbaren MCP-Tools für Dokumentations-Management.

Übersicht

ToolBeschreibung
docs_listDokumente auflisten mit Filtern
docs_getDokument nach ID oder Pfad abrufen
docs_createNeues Dokument erstellen
docs_updateDokument bearbeiten
docs_deleteDokument löschen
docs_movePosition im Baum ändern
docs_hierarchyKompletter Dokumentationsbaum
docs_searchVolltextsuche
docs_statisticsStatistiken abrufen

docs_list

Listet Dokumente mit optionalen Filtern auf.

ParameterTypDefaultBeschreibung
statusstring-Filter: draft, published, archived
parent_idint-Filter nach Parent-ID
searchstring-Volltextsuche in Titel/Beschreibung
compactboolTrueTrue = nur id/path/title/status (ohne Content)
limitint20Max. Ergebnisse (1-100)
# Alle veröffentlichten Dokumente (kompakt)
docs_list(status="published")

# Kinder eines Parents
docs_list(parent_id=1)

# Suche mit vollständigen Daten
docs_list(search="SSH", compact=False)

docs_get

Holt ein Dokument nach ID oder Pfad.

ParameterTypDefaultBeschreibung
idint-Dokument-ID
pathstring-Dokument-Pfad (alternativ zu ID)
include_childrenboolFalseKind-Dokumente einschließen
include_breadcrumbboolFalseBreadcrumb-Pfad einschließen
# Nach ID
docs_get(id=1)

# Nach Pfad mit Kindern
docs_get(path="/server/ssh", include_children=True)

# Mit Breadcrumb
docs_get(id=5, include_breadcrumb=True)

docs_create

Erstellt ein neues Dokument.

ParameterTypDefaultBeschreibung
titlestringrequiredDokumenttitel
slugstringrequiredURL-Slug (eindeutig pro Parent)
contentstring""HTML-Inhalt
descriptionstring-Kurzbeschreibung
parent_idint-ID des Parent-Dokuments (NULL für Root)
statusstring"draft"draft, published, archived
sort_orderint0Sortierung innerhalb Parent
# Root-Dokument erstellen
docs_create(
    title="Neues Kapitel",
    slug="neues-kapitel",
    content="

Neues Kapitel

", status="published" ) # Unterkapitel erstellen docs_create( title="Unterseite", slug="unterseite", parent_id=1, content="

Unterseite

" )

docs_update

Aktualisiert ein Dokument.

ParameterTypDefaultBeschreibung
idintrequiredDokument-ID
titlestring-Neuer Titel
contentstring-Neuer Inhalt
descriptionstring-Neue Beschreibung
statusstring-Neuer Status
# Inhalt aktualisieren
docs_update(id=5, content="

Neuer Inhalt

") # Status ändern docs_update(id=5, status="archived")

docs_delete

Löscht ein Dokument.

ParameterTypBeschreibung
idintDokument-ID

Achtung: Kind-Dokumente werden zu Root-Dokumenten (parent_id=NULL).

docs_move

Verschiebt ein Dokument zu einem neuen Parent.

ParameterTypDefaultBeschreibung
idintrequiredDokument-ID
new_parent_idint-Neue Parent-ID (NULL für Root)
new_sort_orderint-Neue Sortierung
# Zu anderem Parent verschieben
docs_move(id=5, new_parent_id=10)

# Zu Root verschieben
docs_move(id=5, new_parent_id=None)

docs_hierarchy

Gibt den kompletten Dokumentationsbaum zurück.

docs_hierarchy()

Liefert verschachtelte Struktur mit allen Dokumenten und ihren Kindern.

docs_search

Volltextsuche in allen Dokumenten.

ParameterTypDefaultBeschreibung
querystringrequiredSuchbegriff
limitint20Max. Ergebnisse
# Suche nach Begriff
docs_search(query="SSH")

docs_statistics

Gibt Statistiken über alle Dokumente zurück.

docs_statistics()

Liefert: Anzahl nach Status, Tiefe, letzte Änderungen.

Dokumentation » MCP » MCP-Docs » Architektur

MCP-Docs Architektur

Erstellt: 2025-12-20 | Aktualisiert: 2025-12-31

Verzeichnisstruktur und Komponenten des MCP-Docs Servers.

Verzeichnisstruktur

/var/www/mcp-servers/mcp_docs/
├── server.py              # Entry Point (FastMCP)
├── config.py              # Konfiguration
├── .env                   # Credentials (DB_HOST, DB_USER, etc.)
├── requirements.txt       # Dependencies (mcp, pymysql, python-dotenv)
├── venv/                  # Python Virtual Environment
├── __pycache__/           # Python Cache
│
├── domain/
│   ├── __init__.py
│   └── dokumentation.py   # Entities (Dokumentation, DocStatus, LogEntry)
│
├── infrastructure/
│   ├── __init__.py
│   └── docs_repository.py # CRUD-Operationen (nutzt shared.db_connection)
│
└── tools/
    ├── __init__.py
    └── docs_tools/        # MCP-Tools Verzeichnis
        ├── __init__.py
        └── tools.py       # 9 MCP-Tools

Hinweis: Die Datenbankverbindung und Logging werden aus dem shared-Modul importiert (/var/www/mcp-servers/shared/), nicht lokal definiert.

Layer-Architektur

LayerVerantwortungDateien
ToolsMCP-Tool-Definitionentools/docs_tools/
DomainEntities, Dataclassesdomain/dokumentation.py
InfrastructureRepositoryinfrastructure/docs_repository.py
SharedDB-Connection, Logging/var/www/mcp-servers/shared/

Komponenten

server.py

Entry Point mit FastMCP-Initialisierung:

from mcp.server.fastmcp import FastMCP
from tools.docs_tools import register_docs_tools

mcp = FastMCP("mcp-docs", instructions="...")
register_docs_tools(mcp)

if __name__ == "__main__":
    mcp.run(transport="stdio")

domain/dokumentation.py

Dataclasses für Dokumentations-Entities:

@dataclass
class Dokumentation:
    id: int
    parent_id: Optional[int]
    slug: str
    path: str
    title: str
    description: Optional[str]
    content: str
    status: str  # draft, published, archived
    sort_order: int
    depth: int
    created_at: datetime
    updated_at: datetime

    def to_dict(self) -> dict
    def to_dict_compact(self) -> dict  # ohne content

infrastructure/docs_repository.py

CRUD-Operationen auf ki_dev.dokumentation:

Datenbank-Schema

-- ki_dev.dokumentation
CREATE TABLE 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
);

Hierarchie-Konzept

FeldBeschreibungBeispiel
parent_idVerweis auf Eltern-Dokument1 (oder NULL für Root)
depthTiefe im Baum0=Root, 1=Kapitel, 2=Unterkapitel
pathVollständiger URL-Pfad/server/ssh
slugURL-Segmentssh
sort_orderSortierung innerhalb Parent1, 2, 3...

Datenfluss

Claude Code
    ↓ MCP Tool Call
FastMCP (server.py)
    ↓ docs_get()
docs_tools.py
    ↓ Repository
docs_repository.py
    ↓ SQL (shared.db_connection)
ki_dev.dokumentation + ki_protokoll.mcp_log

Besonderheiten

]]>
Dokumentation » MCP » MCP-Docs » Installation

MCP-Docs Installation

Erstellt: 2025-12-20 | Aktualisiert: 2025-12-31

Setup, Konfiguration und Registrierung des MCP-Docs Servers.

Voraussetzungen

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

Tool nicht gefunden

# MCP-Server neu registrieren
claude mcp remove mcp-docs
claude mcp add mcp-docs ...

Berechtigungen

DB-UserDatenbankRechte
rootki_devSELECT, INSERT, UPDATE, DELETE auf dokumentation
rootki_protokollINSERT 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"
]]>