Coverage for src/qdrant_loader_mcp_server/mcp/schemas/cluster_documents.py: 100%

3 statements  

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

1from typing import Any 

2 

3 

4def get_cluster_documents_tool_schema() -> dict[str, Any]: 

5 return { 

6 "name": "cluster_documents", 

7 "description": "Cluster documents based on similarity and relationships", 

8 "annotations": {"read-only": True, "compute-intensive": True}, 

9 "inputSchema": { 

10 "type": "object", 

11 "properties": { 

12 "query": { 

13 "type": "string", 

14 "description": "Search query to get documents for clustering", 

15 "minLength": 1, 

16 }, 

17 "strategy": { 

18 "type": "string", 

19 "enum": [ 

20 "mixed_features", 

21 "entity_based", 

22 "topic_based", 

23 "project_based", 

24 "hierarchical", 

25 "adaptive", 

26 ], 

27 "description": "Clustering strategy to use (adaptive automatically selects the best strategy)", 

28 "default": "mixed_features", 

29 }, 

30 "max_clusters": { 

31 "type": "integer", 

32 "description": "Maximum number of clusters to create", 

33 "default": 10, 

34 "minimum": 1, 

35 "maximum": 1000, 

36 }, 

37 "min_cluster_size": { 

38 "type": "integer", 

39 "description": "Minimum size for a cluster", 

40 "default": 2, 

41 "minimum": 1, 

42 "maximum": 1000, 

43 }, 

44 "limit": { 

45 "type": "integer", 

46 "description": "Maximum number of documents to cluster", 

47 "default": 25, 

48 "minimum": 1, 

49 "maximum": 1000, 

50 }, 

51 "source_types": { 

52 "type": "array", 

53 "items": {"type": "string"}, 

54 "uniqueItems": True, 

55 "description": "Optional list of source types to filter by", 

56 }, 

57 "project_ids": { 

58 "type": "array", 

59 "items": {"type": "string"}, 

60 "uniqueItems": True, 

61 "description": "Optional list of project IDs to filter by", 

62 }, 

63 }, 

64 "required": ["query"], 

65 "additionalProperties": False, 

66 }, 

67 "outputSchema": { 

68 "type": "object", 

69 "properties": { 

70 "clusters": { 

71 "type": "array", 

72 "items": { 

73 "type": "object", 

74 "properties": { 

75 "cluster_id": {"type": "string"}, 

76 "cluster_name": {"type": "string"}, 

77 "cluster_theme": {"type": "string"}, 

78 "document_count": {"type": "integer"}, 

79 "cohesion_score": { 

80 "type": "number", 

81 "minimum": 0, 

82 "maximum": 1, 

83 }, 

84 "documents": { 

85 "type": "array", 

86 "items": { 

87 "type": "object", 

88 "properties": { 

89 "document_id": {"type": "string"}, 

90 "title": {"type": "string"}, 

91 "content_preview": {"type": "string"}, 

92 "source_type": {"type": "string"}, 

93 "cluster_relevance": { 

94 "type": "number", 

95 "minimum": 0, 

96 "maximum": 1, 

97 }, 

98 }, 

99 "required": [ 

100 "document_id", 

101 "title", 

102 "cluster_relevance", 

103 ], 

104 "additionalProperties": False, 

105 }, 

106 }, 

107 "cluster_keywords": { 

108 "type": "array", 

109 "items": {"type": "string"}, 

110 }, 

111 "cluster_summary": {"type": "string"}, 

112 }, 

113 "required": [ 

114 "cluster_id", 

115 "cluster_name", 

116 "document_count", 

117 "cohesion_score", 

118 "documents", 

119 ], 

120 "additionalProperties": False, 

121 }, 

122 }, 

123 "clustering_metadata": { 

124 "type": "object", 

125 "properties": { 

126 "total_documents": {"type": "integer"}, 

127 "clusters_created": {"type": "integer"}, 

128 "strategy": {"type": "string"}, 

129 "unclustered_documents": {"type": "integer"}, 

130 "clustering_quality": { 

131 "type": "number", 

132 "minimum": 0, 

133 "maximum": 1, 

134 }, 

135 "processing_time_ms": {"type": "integer"}, 

136 }, 

137 "required": [ 

138 "total_documents", 

139 "clusters_created", 

140 "strategy", 

141 ], 

142 "additionalProperties": False, 

143 }, 

144 "cluster_relationships": { 

145 "type": "array", 

146 "items": { 

147 "type": "object", 

148 "properties": { 

149 "cluster_1": {"type": "string"}, 

150 "cluster_2": {"type": "string"}, 

151 "relationship_type": {"type": "string"}, 

152 "relationship_strength": { 

153 "type": "number", 

154 "minimum": 0, 

155 "maximum": 1, 

156 }, 

157 }, 

158 "required": [ 

159 "cluster_1", 

160 "cluster_2", 

161 "relationship_strength", 

162 ], 

163 "additionalProperties": False, 

164 }, 

165 }, 

166 }, 

167 "required": ["clusters", "clustering_metadata"], 

168 "additionalProperties": False, 

169 }, 

170 }