{
"tool_response": [
{
"type": "text",
"text": "{\n \"success\": true,\n \"doc\": {\n \"id\": 72,\n \"parent_id\": 66,\n \"slug\": \"mcp-docs-architektur\",\n \"path\": \"\/mcp\/mcp-docs\/mcp-docs-architektur\",\n \"title\": \"Architektur\",\n \"description\": null,\n \"content\": \"<nav class=\\\"breadcrumb\\\">\\n <a href=\\\"\/docs\\\">Dokumentation<\/a> » <a href=\\\"\/docs\/mcp\\\">MCP<\/a> » <a href=\\\"\/docs\/mcp\/mcp-docs\\\">MCP-Docs<\/a> » Architektur\\n<\/nav>\\n\\n<h1>MCP-Docs Architektur<\/h1>\\n<p class=\\\"doc-meta\\\"><strong>Erstellt:<\/strong> 2025-12-20 | <strong>Aktualisiert:<\/strong> 2025-12-20<\/p>\\n\\n<p>Verzeichnisstruktur und Komponenten des MCP-Docs Servers.<\/p>\\n\\n<h2>Verzeichnisstruktur<\/h2>\\n<pre><code>\/opt\/mcp-servers\/mcp-docs\/\\n├── server.py # Entry Point (FastMCP)\\n├── config.py # Konfiguration\\n├── .env # Credentials (DB_HOST, DB_USER, etc.)\\n├── requirements.txt # Dependencies (mcp, pymysql, python-dotenv)\\n├── venv\/ # Python Virtual Environment\\n│\\n├── domain\/\\n│ ├── __init__.py\\n│ └── dokumentation.py # Entities (Dokumentation, DocStatus, LogEntry)\\n│\\n├── infrastructure\/\\n│ ├── __init__.py\\n│ ├── db_connection.py # Datenbankverbindung (ki_system)\\n│ ├── protokoll_logger.py # Logging nach ki_protokoll.mcp_log\\n│ └── docs_repository.py # CRUD-Operationen\\n│\\n└── tools\/\\n ├── __init__.py\\n └── docs_tools.py # 9 MCP-Tools<\/code><\/pre>\\n\\n<h2>Layer-Architektur<\/h2>\\n<table>\\n <tr><th>Layer<\/th><th>Verantwortung<\/th><th>Dateien<\/th><\/tr>\\n <tr><td><strong>Tools<\/strong><\/td><td>MCP-Tool-Definitionen<\/td><td>tools\/docs_tools.py<\/td><\/tr>\\n <tr><td><strong>Domain<\/strong><\/td><td>Entities, Dataclasses<\/td><td>domain\/dokumentation.py<\/td><\/tr>\\n <tr><td><strong>Infrastructure<\/strong><\/td><td>DB, Logging, Repository<\/td><td>infrastructure\/*.py<\/td><\/tr>\\n<\/table>\\n\\n<h2>Komponenten<\/h2>\\n\\n<h3>server.py<\/h3>\\n<p>Entry Point mit FastMCP-Initialisierung:<\/p>\\n<pre><code>from mcp.server.fastmcp import FastMCP\\nfrom tools.docs_tools import register_docs_tools\\n\\nmcp = FastMCP(\\\"mcp-docs\\\", instructions=\\\"...\\\")\\nregister_docs_tools(mcp)\\n\\nif __name__ == \\\"__main__\\\":\\n mcp.run(transport=\\\"stdio\\\")<\/code><\/pre>\\n\\n<h3>domain\/dokumentation.py<\/h3>\\n<p>Dataclasses für Dokumentations-Entities:<\/p>\\n<pre><code>@dataclass\\nclass Dokumentation:\\n id: int\\n parent_id: Optional[int]\\n slug: str\\n path: str\\n title: str\\n description: Optional[str]\\n content: str\\n status: str # draft, published, archived\\n sort_order: int\\n depth: int\\n created_at: datetime\\n updated_at: datetime\\n\\n def to_dict(self) -> dict\\n def to_dict_compact(self) -> dict # ohne content<\/code><\/pre>\\n\\n<h3>infrastructure\/docs_repository.py<\/h3>\\n<p>CRUD-Operationen auf ki_system.dokumentation:<\/p>\\n<ul>\\n <li><code>find_by_id()<\/code>, <code>find_by_path()<\/code><\/li>\\n <li><code>find_all()<\/code> mit Filtern<\/li>\\n <li><code>find_children()<\/code> - Kind-Dokumente<\/li>\\n <li><code>get_hierarchy()<\/code> - Vollständiger Baum<\/li>\\n <li><code>get_breadcrumb()<\/code> - Pfad zum Dokument<\/li>\\n <li><code>create()<\/code>, <code>update()<\/code>, <code>delete()<\/code><\/li>\\n <li><code>move()<\/code> - Parent ändern<\/li>\\n <li><code>get_statistics()<\/code><\/li>\\n<\/ul>\\n\\n<h3>infrastructure\/db_connection.py<\/h3>\\n<p>Verbindung zur ki_system Datenbank:<\/p>\\n<pre><code>def get_connection():\\n return pymysql.connect(\\n host=os.getenv(\\\"DB_HOST\\\"),\\n database=\\\"ki_system\\\",\\n user=os.getenv(\\\"DB_USER\\\"),\\n password=os.getenv(\\\"DB_PASSWORD\\\"),\\n cursorclass=pymysql.cursors.DictCursor\\n )<\/code><\/pre>\\n\\n<h3>infrastructure\/protokoll_logger.py<\/h3>\\n<p>Logging nach ki_protokoll.mcp_log:<\/p>\\n<pre><code>def log_operation(tool: str, params: dict, result: dict):\\n # INSERT INTO mcp_log ...<\/code><\/pre>\\n\\n<h2>Datenbank-Schema<\/h2>\\n<pre><code>-- ki_system.dokumentation\\nCREATE TABLE dokumentation (\\n id INT AUTO_INCREMENT PRIMARY KEY,\\n parent_id INT DEFAULT NULL,\\n slug VARCHAR(100) NOT NULL,\\n path VARCHAR(500) NOT NULL,\\n title VARCHAR(255) NOT NULL,\\n description TEXT,\\n content LONGTEXT,\\n status ENUM('draft','published','archived') DEFAULT 'draft',\\n sort_order INT DEFAULT 0,\\n depth INT DEFAULT 0,\\n created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\\n updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\\n \\n UNIQUE KEY (path),\\n FOREIGN KEY (parent_id) REFERENCES dokumentation(id) ON DELETE SET NULL\\n);<\/code><\/pre>\\n\\n<h2>Hierarchie-Konzept<\/h2>\\n<table>\\n <tr><th>Feld<\/th><th>Beschreibung<\/th><th>Beispiel<\/th><\/tr>\\n <tr><td><code>parent_id<\/code><\/td><td>Verweis auf Eltern-Dokument<\/td><td>1 (oder NULL für Root)<\/td><\/tr>\\n <tr><td><code>depth<\/code><\/td><td>Tiefe im Baum<\/td><td>0=Root, 1=Kapitel, 2=Unterkapitel<\/td><\/tr>\\n <tr><td><code>path<\/code><\/td><td>Vollständiger URL-Pfad<\/td><td>\/server\/ssh<\/td><\/tr>\\n <tr><td><code>slug<\/code><\/td><td>URL-Segment<\/td><td>ssh<\/td><\/tr>\\n <tr><td><code>sort_order<\/code><\/td><td>Sortierung innerhalb Parent<\/td><td>1, 2, 3...<\/td><\/tr>\\n<\/table>\\n\\n<h2>Datenfluss<\/h2>\\n<pre><code>Claude Code\\n ↓ MCP Tool Call\\nFastMCP (server.py)\\n ↓ docs_get()\\ndocs_tools.py\\n ↓ Repository\\ndocs_repository.py\\n ↓ SQL + Logging\\nki_system.dokumentation + ki_protokoll.mcp_log<\/code><\/pre>\\n\\n<h2>Besonderheiten<\/h2>\\n<ul>\\n <li><strong>Zwei Datenbanken:<\/strong> Daten in ki_system, Logging in ki_protokoll<\/li>\\n <li><strong>Pfad-Berechnung:<\/strong> Automatisch aus Parent-Pfad + Slug<\/li>\\n <li><strong>Depth-Berechnung:<\/strong> Parent-Depth + 1<\/li>\\n <li><strong>Token-Optimierung:<\/strong> <code>to_dict_compact()<\/code> ohne Content<\/li>\\n<\/ul>\",\n \"status\": \"published\",\n \"sort_order\": 2,\n \"depth\": 2,\n \"created_at\": \"2025-12-20T13:03:42\",\n \"updated_at\": \"2025-12-27T15:58:19\"\n }\n}"
}
]
}