File tree 2 files changed +26
-24
lines changed
2 files changed +26
-24
lines changed Original file line number Diff line number Diff line change @@ -11,31 +11,8 @@ import {
11
11
import * as mysql2 from "mysql2/promise" ;
12
12
import * as dotenv from "dotenv" ;
13
13
import SqlParser , { AST } from 'node-sql-parser' ;
14
+ import { log } from './utils/index.js' ;
14
15
15
- // @INFO : Load environment variables from .env file
16
- dotenv . config ( )
17
-
18
- // Logging configuration
19
- const ENABLE_LOGGING = process . env . ENABLE_LOGGING === '1'
20
-
21
- type LogType = 'info' | 'error'
22
-
23
- function log ( type : LogType = 'info' , ...args : any [ ] ) : void {
24
- if ( ! ENABLE_LOGGING ) return
25
-
26
- switch ( type ) {
27
- case 'info' :
28
- console . info ( ...args )
29
- break
30
- case 'error' :
31
- console . error ( ...args )
32
- break
33
- default :
34
- console . log ( ...args )
35
- }
36
- }
37
-
38
- // Define interfaces for schema-specific permissions
39
16
interface SchemaPermissions {
40
17
[ schema : string ] : boolean
41
18
}
@@ -49,6 +26,12 @@ export interface ColumnRow {
49
26
data_type: string
50
27
}
51
28
29
+ // @INFO : Load environment variables from .env file
30
+ dotenv . config ( )
31
+
32
+ log ( 'info' , 'Starting MCP server...' )
33
+
34
+
52
35
// @INFO : Update the environment setup to ensure database is correctly set
53
36
if ( process . env . NODE_ENV === 'test' && ! process . env . MYSQL_DB ) {
54
37
process . env . MYSQL_DB = 'mcp_test_db' // @INFO : Ensure we have a database name for tests
Original file line number Diff line number Diff line change
1
+ type LogType = 'info' | 'error'
2
+
3
+ // @INFO : Enable logging if ENABLE_LOGGING is true
4
+ const ENABLE_LOGGING = [ "true" , "1" ] . includes ( process . env . ENABLE_LOGGING || 'false' )
5
+
6
+ export function log ( type : LogType = 'info' , ...args : any [ ] ) : void {
7
+ if ( ! ENABLE_LOGGING ) return
8
+
9
+ switch ( type ) {
10
+ case 'info' :
11
+ console . info ( ...args )
12
+ break
13
+ case 'error' :
14
+ console . error ( ...args )
15
+ break
16
+ default :
17
+ console . log ( ...args )
18
+ }
19
+ }
You can’t perform that action at this time.
0 commit comments