Protokoll #15970

ID15970
Zeitstempel2025-12-25 16:58:17.500650
Clientroot
IP145.224.72.140
Modellclaude-sonnet-4-20250514
Statuscompleted
Tokens2,351 (Input: 522, Output: 1,829)
Dauer116 ms
Request-Zeit2025-12-25 16:58:17.500650
Response-Zeit2025-12-25 16:58:17.616339

Request

{
    "event": "PreToolUse",
    "tool_name": "Edit",
    "tool_input": {
        "file_path": "\/var\/www\/mcp-servers\/mcp-docs\/tools\/docs_tools\/docs_hierarchy.py",
        "old_string": "\"\"\"Hierarchy operations for documentation management.\"\"\"\n\nimport json\nimport sys\nimport time\nfrom typing import Optional\n\nsys.path.insert(0, \"\/opt\/mcp-servers\/mcp-docs\")\nfrom domain.dokumentation import LogEntry\nfrom infrastructure.docs_repository import get_repository\nfrom infrastructure.protokoll_logger import get_logger\n\nfrom .constants import MS_PER_SECOND\n\n\ndef register_hierarchy_tools(mcp) -> None:\n    \"\"\"\n    Register hierarchy documentation tools with the MCP server.\n\n    Args:\n        mcp: The MCP server instance to register tools with\n    \"\"\"\n\n    @mcp.tool()\n    def docs_hierarchy() -> dict:\n        \"\"\"\n        Retrieve the complete documentation tree.\n\n        Returns:\n            Dict containing hierarchical tree of all documents\n        \"\"\"",
        "new_string": "\"\"\"Hierarchy operations for documentation management.\"\"\"\n\nimport json\nimport sys\nimport time\nfrom typing import Optional\n\nsys.path.insert(0, \"\/opt\/mcp-servers\/mcp-docs\")\nfrom domain.dokumentation import LogEntry\nfrom infrastructure.docs_repository import get_repository\nfrom infrastructure.protokoll_logger import get_logger\n\nfrom .constants import MS_PER_SECOND\n\n\ndef _log_operation(\n    logger,\n    tool_name: str,\n    request_data: dict,\n    start_time: float,\n    status: str = \"success\",\n    error: Optional[str] = None\n) -> None:\n    \"\"\"Log an operation with timing information.\"\"\"\n    logger.log(LogEntry(\n        tool_name=tool_name,\n        request=json.dumps(request_data),\n        status=status,\n        error_message=error,\n        duration_ms=int((time.time() - start_time) * MS_PER_SECOND)\n    ))\n\n\ndef register_hierarchy_tools(mcp) -> None:\n    \"\"\"Register hierarchy documentation tools with the MCP server.\"\"\"\n\n    @mcp.tool()\n    def docs_hierarchy() -> dict:\n        \"\"\"Retrieve the complete documentation tree.\"\"\""
    }
}

Response

{
    "tool_response": {
        "filePath": "\/var\/www\/mcp-servers\/mcp-docs\/tools\/docs_tools\/docs_hierarchy.py",
        "oldString": "\"\"\"Hierarchy operations for documentation management.\"\"\"\n\nimport json\nimport sys\nimport time\nfrom typing import Optional\n\nsys.path.insert(0, \"\/opt\/mcp-servers\/mcp-docs\")\nfrom domain.dokumentation import LogEntry\nfrom infrastructure.docs_repository import get_repository\nfrom infrastructure.protokoll_logger import get_logger\n\nfrom .constants import MS_PER_SECOND\n\n\ndef register_hierarchy_tools(mcp) -> None:\n    \"\"\"\n    Register hierarchy documentation tools with the MCP server.\n\n    Args:\n        mcp: The MCP server instance to register tools with\n    \"\"\"\n\n    @mcp.tool()\n    def docs_hierarchy() -> dict:\n        \"\"\"\n        Retrieve the complete documentation tree.\n\n        Returns:\n            Dict containing hierarchical tree of all documents\n        \"\"\"",
        "newString": "\"\"\"Hierarchy operations for documentation management.\"\"\"\n\nimport json\nimport sys\nimport time\nfrom typing import Optional\n\nsys.path.insert(0, \"\/opt\/mcp-servers\/mcp-docs\")\nfrom domain.dokumentation import LogEntry\nfrom infrastructure.docs_repository import get_repository\nfrom infrastructure.protokoll_logger import get_logger\n\nfrom .constants import MS_PER_SECOND\n\n\ndef _log_operation(\n    logger,\n    tool_name: str,\n    request_data: dict,\n    start_time: float,\n    status: str = \"success\",\n    error: Optional[str] = None\n) -> None:\n    \"\"\"Log an operation with timing information.\"\"\"\n    logger.log(LogEntry(\n        tool_name=tool_name,\n        request=json.dumps(request_data),\n        status=status,\n        error_message=error,\n        duration_ms=int((time.time() - start_time) * MS_PER_SECOND)\n    ))\n\n\ndef register_hierarchy_tools(mcp) -> None:\n    \"\"\"Register hierarchy documentation tools with the MCP server.\"\"\"\n\n    @mcp.tool()\n    def docs_hierarchy() -> dict:\n        \"\"\"Retrieve the complete documentation tree.\"\"\"",
        "originalFile": "\"\"\"Hierarchy operations for documentation management.\"\"\"\n\nimport json\nimport sys\nimport time\nfrom typing import Optional\n\nsys.path.insert(0, \"\/opt\/mcp-servers\/mcp-docs\")\nfrom domain.dokumentation import LogEntry\nfrom infrastructure.docs_repository import get_repository\nfrom infrastructure.protokoll_logger import get_logger\n\nfrom .constants import MS_PER_SECOND\n\n\ndef register_hierarchy_tools(mcp) -> None:\n    \"\"\"\n    Register hierarchy documentation tools with the MCP server.\n\n    Args:\n        mcp: The MCP server instance to register tools with\n    \"\"\"\n\n    @mcp.tool()\n    def docs_hierarchy() -> dict:\n        \"\"\"\n        Retrieve the complete documentation tree.\n\n        Returns:\n            Dict containing hierarchical tree of all documents\n        \"\"\"\n        start_time = time.time()\n        logger = get_logger()\n        repo = get_repository()\n\n        try:\n            hierarchy = repo.get_hierarchy()\n\n            logger.log(LogEntry(\n                tool_name=\"docs_hierarchy\",\n                request=\"{}\",\n                status=\"success\",\n                duration_ms=int((time.time() - start_time) * MS_PER_SECOND)\n            ))\n\n            return {\n                \"success\": True,\n                \"hierarchy\": hierarchy\n            }\n\n        except Exception as e:\n            logger.log(LogEntry(\n                tool_name=\"docs_hierarchy\",\n                request=\"{}\",\n                status=\"error\",\n                error_message=str(e),\n                duration_ms=int((time.time() - start_time) * MS_PER_SECOND)\n            ))\n            return {\"success\": False, \"error\": str(e)}\n\n    @mcp.tool()\n    def docs_move(\n        id: int,\n        new_parent_id: Optional[int] = None,\n        new_sort_order: Optional[int] = None\n    ) -> dict:\n        \"\"\"\n        Move a document to a new parent.\n\n        Args:\n            id: Document ID (required)\n            new_parent_id: New parent ID (None for root)\n            new_sort_order: New sort order\n\n        Returns:\n            Dict containing updated document\n        \"\"\"\n        start_time = time.time()\n        logger = get_logger()\n        repo = get_repository()\n\n        try:\n            doc = repo.find_by_id(id)\n            if not doc:\n                return {\n                    \"success\": False,\n                    \"error\": f\"Document with ID {id} not found\"\n                }\n\n            success = repo.move(id, new_parent_id, new_sort_order)\n            if success:\n                updated_doc = repo.find_by_id(id)\n\n                logger.log(LogEntry(\n                    tool_name=\"docs_move\",\n                    request=json.dumps({\n                        \"id\": id,\n                        \"new_parent_id\": new_parent_id\n                    }),\n                    status=\"success\",\n                    duration_ms=int((time.time() - start_time) * MS_PER_SECOND)\n                ))\n\n                return {\n                    \"success\": True,\n                    \"doc\": updated_doc.to_dict_compact() if updated_doc else None,\n                    \"message\": f\"Document #{id} moved\"\n                }\n            else:\n                return {\"success\": False, \"error\": \"Move failed\"}\n\n        except Exception as e:\n            logger.log(LogEntry(\n                tool_name=\"docs_move\",\n                request=json.dumps({\"id\": id}),\n                status=\"error\",\n                error_message=str(e),\n                duration_ms=int((time.time() - start_time) * MS_PER_SECOND)\n            ))\n            return {\"success\": False, \"error\": str(e)}\n",
        "structuredPatch": [
            {
                "oldStart": 13,
                "oldLines": 22,
                "newStart": 13,
                "newLines": 30,
                "lines": [
                    " from .constants import MS_PER_SECOND",
                    " ",
                    " ",
                    "-def register_hierarchy_tools(mcp) -> None:",
                    "-    \"\"\"",
                    "-    Register hierarchy documentation tools with the MCP server.",
                    "+def _log_operation(",
                    "+    logger,",
                    "+    tool_name: str,",
                    "+    request_data: dict,",
                    "+    start_time: float,",
                    "+    status: str = \"success\",",
                    "+    error: Optional[str] = None",
                    "+) -> None:",
                    "+    \"\"\"Log an operation with timing information.\"\"\"",
                    "+    logger.log(LogEntry(",
                    "+        tool_name=tool_name,",
                    "+        request=json.dumps(request_data),",
                    "+        status=status,",
                    "+        error_message=error,",
                    "+        duration_ms=int((time.time() - start_time) * MS_PER_SECOND)",
                    "+    ))",
                    " ",
                    "-    Args:",
                    "-        mcp: The MCP server instance to register tools with",
                    "-    \"\"\"",
                    " ",
                    "+def register_hierarchy_tools(mcp) -> None:",
                    "+    \"\"\"Register hierarchy documentation tools with the MCP server.\"\"\"",
                    "+",
                    "     @mcp.tool()",
                    "     def docs_hierarchy() -> dict:",
                    "-        \"\"\"",
                    "-        Retrieve the complete documentation tree.",
                    "-",
                    "-        Returns:",
                    "-            Dict containing hierarchical tree of all documents",
                    "-        \"\"\"",
                    "+        \"\"\"Retrieve the complete documentation tree.\"\"\"",
                    "         start_time = time.time()",
                    "         logger = get_logger()",
                    "         repo = get_repository()"
                ]
            }
        ],
        "userModified": false,
        "replaceAll": false
    }
}
← Vorheriger Zur Liste Nächster →