Coverage for src/qdrant_loader_mcp_server/mcp/handlers/search/formatting.py: 95%
39 statements
« prev ^ index » next coverage.py v7.10.6, created at 2025-09-08 06:06 +0000
« prev ^ index » next coverage.py v7.10.6, created at 2025-09-08 06:06 +0000
1from __future__ import annotations
3from ...formatters import MCPFormatters
6def format_lightweight_attachment_text(
7 organized_results: dict[str, list], total_found: int
8) -> str:
9 if not organized_results:
10 return (
11 "📎 **Attachment Search Results**\n\nFound "
12 f"{total_found} attachments. Use the structured data below to navigate and retrieve specific files."
13 )
15 formatted = f"📎 **Attachment Search Results** ({total_found} attachments)\n\n"
16 formatters = MCPFormatters()
17 for group_name, results in organized_results.items():
18 formatted += f"📁 **{group_name}** ({len(results)} files)\n"
19 for result in results[:3]:
20 filename = formatters._extract_safe_filename(result)
21 file_type = formatters._extract_file_type_minimal(result)
22 formatted += f" 📄 {filename} ({file_type}) - Score: {result.score:.3f}\n"
23 if len(results) > 3:
24 formatted += f" ... and {len(results) - 3} more files\n"
25 formatted += "\n"
26 formatted += "💡 **Usage:** Use the structured attachment data to:\n"
27 formatted += "• Browse attachments by file type or source\n"
28 formatted += "• Get document IDs for specific file content retrieval\n"
29 formatted += "• Filter attachments by metadata (size, type, etc.)\n"
30 return formatted
33def format_lightweight_hierarchy_text(
34 organized_results: dict[str, list], total_found: int
35) -> str:
36 if not organized_results:
37 return (
38 "📋 **Hierarchy Search Results**\n\nFound "
39 f"{total_found} documents. Use the structured data below to navigate the hierarchy and retrieve specific documents."
40 )
42 formatted = f"📋 **Hierarchy Search Results** ({total_found} documents)\n\n"
43 formatters = MCPFormatters()
44 for group_name, results in organized_results.items():
45 clean_name = formatters._generate_clean_group_name(group_name, results)
46 formatted += f"📁 **{clean_name}** ({len(results)} documents)\n"
47 for result in results[:3]:
48 formatted += f" 📄 {result.source_title} (Score: {result.score:.3f})\n"
49 if len(results) > 3:
50 formatted += f" ... and {len(results) - 3} more documents\n"
51 formatted += "\n"
52 formatted += "💡 **Usage:** Use the structured hierarchy data to:\n"
53 formatted += "• Browse document groups and navigate hierarchy levels\n"
54 formatted += "• Get document IDs for specific content retrieval\n"
55 formatted += "• Understand document relationships and organization\n"
56 return formatted