@bitsbound/mcp-server 1.0.4 → 1.0.6

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,130 @@
1
+ ////////////////////////////////////////
2
+ // # GOLDEN RULE!!!! HONOR ABOVE ALL!!!!
3
+ ////////////////////////////////////////
4
+ // NO NEW FILES!!!!!!!!!
5
+ ////////////////////////////////////////
6
+
7
+ /*
8
+ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
9
+ */
10
+ // ## REQUIREMENTS 'R'
11
+ /*
12
+ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
13
+ */
14
+
15
+
16
+ /*
17
+ §§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§
18
+ */
19
+ // ### DEFINITIONS, VALIDATIONS, AND TRANSFORMATIONS 'R_DVT'
20
+ /*
21
+ §§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§
22
+ */
23
+
24
+
25
+ /*
26
+ ######################################################################################################################################################################################################
27
+ */
28
+ // #### GLOBAL 'R_DVT_G' - Logger Definitions
29
+ /*
30
+ ######################################################################################################################################################################################################
31
+ */
32
+
33
+ type LogLevel = 'debug' | 'info' | 'warn' | 'error';
34
+
35
+ interface LogEntry {
36
+ readonly timestamp: string;
37
+ readonly level: LogLevel;
38
+ readonly component: string;
39
+ readonly message: string;
40
+ readonly data?: Record<string, unknown>;
41
+ }
42
+
43
+ // ══════════════════════════════════════════════════════════════════════════════════════════════════════════════════
44
+ // MCP Logger 'R_DVT_G_T_Logger' - Logs to stderr (MCP protocol uses stdout for messages)
45
+ // ══════════════════════════════════════════════════════════════════════════════════════════════════════════════════
46
+
47
+ class McpLogger {
48
+ private readonly component: string;
49
+ private readonly minLevel: LogLevel;
50
+ private readonly levelPriority: Record<LogLevel, number> = {
51
+ debug: 0,
52
+ info: 1,
53
+ warn: 2,
54
+ error: 3
55
+ };
56
+
57
+ constructor(component: string, minLevel: LogLevel = 'info') {
58
+ this.component = component;
59
+ this.minLevel = minLevel;
60
+ }
61
+
62
+ private shouldLog(level: LogLevel): boolean {
63
+ return this.levelPriority[level] >= this.levelPriority[this.minLevel];
64
+ }
65
+
66
+ private formatEntry(entry: LogEntry): string {
67
+ const dataStr = entry.data ? ` ${JSON.stringify(entry.data)}` : '';
68
+ return `[${entry.timestamp}] [${entry.level.toUpperCase()}] [${entry.component}] ${entry.message}${dataStr}`;
69
+ }
70
+
71
+ private log(level: LogLevel, message: string, data?: Record<string, unknown>): void {
72
+ if (!this.shouldLog(level)) return;
73
+
74
+ const entry: LogEntry = {
75
+ timestamp: new Date().toISOString(),
76
+ level,
77
+ component: this.component,
78
+ message,
79
+ data
80
+ };
81
+
82
+ // MCP protocol: stdout is for JSON-RPC messages, stderr is for logs
83
+ console.error(this.formatEntry(entry));
84
+ }
85
+
86
+ debug(message: string, data?: Record<string, unknown>): void {
87
+ this.log('debug', message, data);
88
+ }
89
+
90
+ info(message: string, data?: Record<string, unknown>): void {
91
+ this.log('info', message, data);
92
+ }
93
+
94
+ warn(message: string, data?: Record<string, unknown>): void {
95
+ this.log('warn', message, data);
96
+ }
97
+
98
+ error(message: string, data?: Record<string, unknown>): void {
99
+ this.log('error', message, data);
100
+ }
101
+
102
+ child(subComponent: string): McpLogger {
103
+ return new McpLogger(`${this.component}:${subComponent}`, this.minLevel);
104
+ }
105
+ }
106
+
107
+
108
+ /*
109
+ ######################################################################################################################################################################################################
110
+ */
111
+ // #### LOCAL 'R_DVT_L' - Logger Factory
112
+ /*
113
+ ######################################################################################################################################################################################################
114
+ */
115
+
116
+ // ══════════════════════════════════════════════════════════════════════════════════════════════════════════════════
117
+ // Logger Factory 'R_DVT_L_T_Factory' - Creates component-specific loggers
118
+ // ══════════════════════════════════════════════════════════════════════════════════════════════════════════════════
119
+
120
+ const logLevel = (process.env.LOG_LEVEL as LogLevel) || 'info';
121
+
122
+ export const createLogger = (component: string): McpLogger => {
123
+ return new McpLogger(`bitsbound-mcp:${component}`, logLevel);
124
+ };
125
+
126
+ export const serverLogger = createLogger('server');
127
+ export const toolLogger = createLogger('tools');
128
+ export const apiLogger = createLogger('api');
129
+
130
+ export type { McpLogger, LogLevel, LogEntry };