Coverage for src/qdrant_loader_mcp_server/mcp/formatters/__init__.py: 100%

42 statements  

« prev     ^ index     » next       coverage.py v7.10.6, created at 2025-09-08 06:06 +0000

1""" 

2MCP Formatters Package - Modular Response Formatting. 

3 

4This package provides comprehensive MCP response formatting through modular components: 

5- basic: Basic search result and attachment formatting 

6- intelligence: Analysis and intelligence result formatting 

7- lightweight: Efficient lightweight result construction 

8- structured: Complex structured data formatting 

9- utils: Shared utilities and helper functions 

10""" 

11 

12# Re-export the main MCPFormatters class for backward compatibility 

13from .basic import BasicResultFormatters 

14from .intelligence import IntelligenceResultFormatters 

15from .lightweight import LightweightResultFormatters 

16from .structured import StructuredResultFormatters 

17from .utils import FormatterUtils 

18 

19 

20# Compatibility wrapper to maintain existing API 

21class MCPFormatters: 

22 """ 

23 Unified formatter class maintaining backward compatibility. 

24 

25 Delegates to specialized formatter modules while preserving 

26 the original static method interface. 

27 """ 

28 

29 # Basic formatting methods 

30 format_search_result = staticmethod(BasicResultFormatters.format_search_result) 

31 format_attachment_search_result = staticmethod( 

32 BasicResultFormatters.format_attachment_search_result 

33 ) 

34 format_hierarchical_results = staticmethod( 

35 BasicResultFormatters.format_hierarchical_results 

36 ) 

37 

38 # Intelligence formatting methods 

39 format_relationship_analysis = staticmethod( 

40 IntelligenceResultFormatters.format_relationship_analysis 

41 ) 

42 format_similar_documents = staticmethod( 

43 IntelligenceResultFormatters.format_similar_documents 

44 ) 

45 format_conflict_analysis = staticmethod( 

46 IntelligenceResultFormatters.format_conflict_analysis 

47 ) 

48 format_complementary_content = staticmethod( 

49 IntelligenceResultFormatters.format_complementary_content 

50 ) 

51 format_document_clusters = staticmethod( 

52 IntelligenceResultFormatters.format_document_clusters 

53 ) 

54 

55 # Lightweight result methods 

56 create_lightweight_similar_documents_results = staticmethod( 

57 LightweightResultFormatters.create_lightweight_similar_documents_results 

58 ) 

59 create_lightweight_conflict_results = staticmethod( 

60 LightweightResultFormatters.create_lightweight_conflict_results 

61 ) 

62 create_lightweight_cluster_results = staticmethod( 

63 LightweightResultFormatters.create_lightweight_cluster_results 

64 ) 

65 create_lightweight_hierarchy_results = staticmethod( 

66 LightweightResultFormatters.create_lightweight_hierarchy_results 

67 ) 

68 create_lightweight_complementary_results = staticmethod( 

69 LightweightResultFormatters.create_lightweight_complementary_results 

70 ) 

71 create_lightweight_attachment_results = staticmethod( 

72 LightweightResultFormatters.create_lightweight_attachment_results 

73 ) 

74 

75 # Structured result methods 

76 create_structured_search_results = staticmethod( 

77 StructuredResultFormatters.create_structured_search_results 

78 ) 

79 create_structured_hierarchy_results = staticmethod( 

80 StructuredResultFormatters.create_structured_hierarchy_results 

81 ) 

82 create_structured_attachment_results = staticmethod( 

83 StructuredResultFormatters.create_structured_attachment_results 

84 ) 

85 

86 # Utility methods 

87 _extract_minimal_doc_fields = staticmethod( 

88 FormatterUtils.extract_minimal_doc_fields 

89 ) 

90 _extract_conflicting_statements = staticmethod( 

91 FormatterUtils.extract_conflicting_statements 

92 ) 

93 _generate_clean_group_name = staticmethod(FormatterUtils.generate_clean_group_name) 

94 _get_group_key = staticmethod(FormatterUtils.get_group_key) 

95 _count_siblings = staticmethod(FormatterUtils.count_siblings) 

96 _extract_synthetic_depth = staticmethod(FormatterUtils.extract_synthetic_depth) 

97 _extract_synthetic_parent_id = staticmethod( 

98 FormatterUtils.extract_synthetic_parent_id 

99 ) 

100 _extract_synthetic_parent_title = staticmethod( 

101 FormatterUtils.extract_synthetic_parent_title 

102 ) 

103 _extract_synthetic_breadcrumb = staticmethod( 

104 FormatterUtils.extract_synthetic_breadcrumb 

105 ) 

106 _extract_has_children = staticmethod(FormatterUtils.extract_has_children) 

107 _extract_children_count = staticmethod(FormatterUtils.extract_children_count) 

108 _extract_safe_filename = staticmethod(FormatterUtils.extract_safe_filename) 

109 _extract_file_type_minimal = staticmethod(FormatterUtils.extract_file_type_minimal) 

110 _organize_attachments_by_type = staticmethod( 

111 FormatterUtils.organize_attachments_by_type 

112 ) 

113 _get_attachment_group_key = staticmethod(FormatterUtils.get_attachment_group_key) 

114 _generate_friendly_group_name = staticmethod( 

115 FormatterUtils.generate_friendly_group_name 

116 ) 

117 _generate_conflict_resolution_suggestion = staticmethod( 

118 FormatterUtils.generate_conflict_resolution_suggestion 

119 ) 

120 _extract_affected_sections = staticmethod(FormatterUtils.extract_affected_sections) 

121 

122 

123__all__ = [ 

124 "MCPFormatters", 

125 "BasicResultFormatters", 

126 "IntelligenceResultFormatters", 

127 "LightweightResultFormatters", 

128 "StructuredResultFormatters", 

129 "FormatterUtils", 

130]