Coverage for src/qdrant_loader_mcp_server/mcp/schemas/find_similar.py: 100%
3 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 typing import Any
4def get_find_similar_tool_schema() -> dict[str, Any]:
5 return {
6 "name": "find_similar_documents",
7 "description": "Find documents similar to a target document using multiple similarity metrics",
8 "annotations": {"read-only": True},
9 "inputSchema": {
10 "type": "object",
11 "properties": {
12 "target_query": {
13 "type": "string",
14 "description": "Query to find the target document",
15 "minLength": 1,
16 },
17 "comparison_query": {
18 "type": "string",
19 "description": "Query to get documents to compare against",
20 "minLength": 1,
21 },
22 "similarity_metrics": {
23 "type": "array",
24 "items": {
25 "type": "string",
26 "enum": [
27 "entity_overlap",
28 "topic_overlap",
29 "semantic_similarity",
30 "metadata_similarity",
31 "hierarchical_distance",
32 "content_features",
33 ],
34 },
35 "description": "Similarity metrics to use",
36 },
37 "max_similar": {
38 "type": "integer",
39 "description": "Maximum number of similar documents to return",
40 "default": 5,
41 },
42 "source_types": {
43 "type": "array",
44 "items": {"type": "string"},
45 "description": "Optional list of source types to filter by",
46 },
47 "project_ids": {
48 "type": "array",
49 "items": {"type": "string"},
50 "description": "Optional list of project IDs to filter by",
51 },
52 },
53 "required": ["target_query", "comparison_query"],
54 "additionalProperties": False,
55 },
56 "outputSchema": {
57 "type": "object",
58 "additionalProperties": False,
59 "properties": {
60 "similar_documents": {
61 "type": "array",
62 "items": {
63 "type": "object",
64 "properties": {
65 "document_id": {"type": "string"},
66 "title": {"type": "string"},
67 "similarity_score": {
68 "type": "number",
69 "minimum": 0,
70 "maximum": 1,
71 },
72 "similarity_metrics": {
73 "type": "object",
74 "properties": {
75 "entity_overlap": {
76 "type": "number",
77 "minimum": 0,
78 "maximum": 1,
79 },
80 "topic_overlap": {
81 "type": "number",
82 "minimum": 0,
83 "maximum": 1,
84 },
85 "semantic_similarity": {
86 "type": "number",
87 "minimum": 0,
88 "maximum": 1,
89 },
90 "metadata_similarity": {
91 "type": "number",
92 "minimum": 0,
93 "maximum": 1,
94 },
95 "hierarchical_distance": {
96 "type": "number",
97 "minimum": 0,
98 "maximum": 1,
99 },
100 "content_features": {
101 "type": "number",
102 "minimum": 0,
103 "maximum": 1,
104 },
105 },
106 "additionalProperties": False,
107 },
108 "similarity_reason": {"type": "string"},
109 "content_preview": {"type": "string"},
110 },
111 "required": [
112 "document_id",
113 "title",
114 "similarity_score",
115 ],
116 "additionalProperties": False,
117 },
118 },
119 "target_document": {
120 "type": "object",
121 "properties": {
122 "title": {"type": "string"},
123 "content_preview": {"type": "string"},
124 "source_type": {"type": "string"},
125 },
126 },
127 "similarity_summary": {
128 "type": "object",
129 "properties": {
130 "total_compared": {"type": "integer"},
131 "similar_found": {"type": "integer"},
132 "highest_similarity": {
133 "type": "number",
134 "minimum": 0,
135 "maximum": 1,
136 },
137 "metrics_used": {
138 "type": "array",
139 "items": {"type": "string"},
140 "minItems": 1,
141 "uniqueItems": True,
142 },
143 },
144 "required": [
145 "total_compared",
146 "similar_found",
147 "highest_similarity",
148 "metrics_used",
149 ],
150 "additionalProperties": False,
151 },
152 },
153 },
154 }