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

]]>