@berthojoris/mcp-mysql-server 1.15.0 → 1.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,163 @@
1
+ import { SecurityLayer } from "../security/securityLayer";
2
+ /**
3
+ * Smart Data Discovery Agent
4
+ * Finds relevant tables/columns using semantic search and pattern matching
5
+ * Discovers hidden relationships automatically
6
+ */
7
+ export declare class SmartDiscoveryTools {
8
+ private db;
9
+ private security;
10
+ constructor(security: SecurityLayer);
11
+ /**
12
+ * Validate database access - ensures only the connected database can be accessed
13
+ */
14
+ private validateDatabaseAccess;
15
+ /**
16
+ * Smart search across database objects (tables, columns, data patterns)
17
+ */
18
+ smartSearch(params: {
19
+ search_term: string;
20
+ search_type?: "column" | "table" | "data_pattern" | "relationship" | "all";
21
+ similarity_threshold?: number;
22
+ include_sample_data?: boolean;
23
+ max_results?: number;
24
+ database?: string;
25
+ }): Promise<{
26
+ status: string;
27
+ data?: {
28
+ search_term: string;
29
+ search_type: string;
30
+ results: {
31
+ tables: Array<{
32
+ name: string;
33
+ relevance_score: number;
34
+ match_reason: string;
35
+ column_count: number;
36
+ row_estimate: number;
37
+ matching_columns?: string[];
38
+ }>;
39
+ columns: Array<{
40
+ table_name: string;
41
+ column_name: string;
42
+ data_type: string;
43
+ relevance_score: number;
44
+ match_reason: string;
45
+ sample_values?: any[];
46
+ }>;
47
+ data_patterns: Array<{
48
+ table_name: string;
49
+ column_name: string;
50
+ pattern_type: string;
51
+ description: string;
52
+ sample_matches?: any[];
53
+ }>;
54
+ relationships: Array<{
55
+ from_table: string;
56
+ from_column: string;
57
+ to_table: string;
58
+ to_column: string;
59
+ relationship_type: string;
60
+ confidence: number;
61
+ }>;
62
+ };
63
+ total_matches: number;
64
+ search_time_ms: number;
65
+ };
66
+ error?: string;
67
+ }>;
68
+ /**
69
+ * Find similar columns across tables (potential join candidates)
70
+ */
71
+ findSimilarColumns(params: {
72
+ column_name?: string;
73
+ table_name?: string;
74
+ include_data_comparison?: boolean;
75
+ max_results?: number;
76
+ database?: string;
77
+ }): Promise<{
78
+ status: string;
79
+ data?: {
80
+ reference_column?: {
81
+ table: string;
82
+ column: string;
83
+ data_type: string;
84
+ };
85
+ similar_columns: Array<{
86
+ table_name: string;
87
+ column_name: string;
88
+ data_type: string;
89
+ similarity_score: number;
90
+ similarity_type: string;
91
+ data_overlap_percentage?: number;
92
+ }>;
93
+ potential_joins: Array<{
94
+ table1: string;
95
+ column1: string;
96
+ table2: string;
97
+ column2: string;
98
+ confidence: number;
99
+ reason: string;
100
+ }>;
101
+ };
102
+ error?: string;
103
+ }>;
104
+ /**
105
+ * Discover data relationships and patterns
106
+ */
107
+ discoverDataPatterns(params: {
108
+ table_name: string;
109
+ pattern_types?: Array<"unique" | "null" | "duplicate" | "format" | "range">;
110
+ max_columns?: number;
111
+ database?: string;
112
+ }): Promise<{
113
+ status: string;
114
+ data?: {
115
+ table_name: string;
116
+ patterns: Array<{
117
+ column_name: string;
118
+ pattern_type: string;
119
+ description: string;
120
+ metrics?: Record<string, any>;
121
+ recommendations?: string[];
122
+ }>;
123
+ summary: {
124
+ columns_analyzed: number;
125
+ patterns_found: number;
126
+ data_quality_score: number;
127
+ };
128
+ };
129
+ error?: string;
130
+ }>;
131
+ /**
132
+ * Tokenize a string into searchable tokens
133
+ */
134
+ private tokenize;
135
+ /**
136
+ * Calculate relevance score between search tokens and target
137
+ */
138
+ private calculateRelevanceScore;
139
+ /**
140
+ * Get a human-readable match reason
141
+ */
142
+ private getMatchReason;
143
+ /**
144
+ * Calculate name similarity using Levenshtein-like approach
145
+ */
146
+ private calculateNameSimilarity;
147
+ /**
148
+ * Normalize column name for comparison
149
+ */
150
+ private normalizeColumnName;
151
+ /**
152
+ * Get similarity type description
153
+ */
154
+ private getSimilarityType;
155
+ /**
156
+ * Calculate data overlap between two columns
157
+ */
158
+ private calculateDataOverlap;
159
+ /**
160
+ * Discover implicit relationships based on naming conventions
161
+ */
162
+ private discoverImplicitRelationships;
163
+ }