midnight-mcp 0.1.33 → 0.1.34
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.
- package/dist/server.d.ts +4 -0
- package/dist/server.js +12 -1
- package/package.json +1 -1
package/dist/server.d.ts
CHANGED
|
@@ -8,6 +8,10 @@ export declare function getUpdateWarning(): string | null;
|
|
|
8
8
|
* Clear all subscriptions (useful for server restart/testing)
|
|
9
9
|
*/
|
|
10
10
|
export declare function clearSubscriptions(): void;
|
|
11
|
+
/**
|
|
12
|
+
* Mark server as connected (safe to send notifications)
|
|
13
|
+
*/
|
|
14
|
+
export declare function setServerConnected(connected: boolean): void;
|
|
11
15
|
/**
|
|
12
16
|
* Send a log message to the MCP client
|
|
13
17
|
* This allows clients to see server logs for debugging
|
package/dist/server.js
CHANGED
|
@@ -101,12 +101,21 @@ const resourceTemplates = [
|
|
|
101
101
|
let mcpLogLevel = "info";
|
|
102
102
|
// Server instance for sending notifications
|
|
103
103
|
let serverInstance = null;
|
|
104
|
+
// Track if server is connected (can send notifications)
|
|
105
|
+
let isConnected = false;
|
|
106
|
+
/**
|
|
107
|
+
* Mark server as connected (safe to send notifications)
|
|
108
|
+
*/
|
|
109
|
+
export function setServerConnected(connected) {
|
|
110
|
+
isConnected = connected;
|
|
111
|
+
}
|
|
104
112
|
/**
|
|
105
113
|
* Send a log message to the MCP client
|
|
106
114
|
* This allows clients to see server logs for debugging
|
|
107
115
|
*/
|
|
108
116
|
export function sendLogToClient(level, loggerName, data) {
|
|
109
|
-
if
|
|
117
|
+
// Only send if server exists AND is connected
|
|
118
|
+
if (!serverInstance || !isConnected)
|
|
110
119
|
return;
|
|
111
120
|
// Map levels to numeric values for comparison
|
|
112
121
|
const levelValues = {
|
|
@@ -667,6 +676,8 @@ export async function startServer() {
|
|
|
667
676
|
const server = await initializeServer();
|
|
668
677
|
const transport = new StdioServerTransport();
|
|
669
678
|
await server.connect(transport);
|
|
679
|
+
// Now safe to send notifications
|
|
680
|
+
setServerConnected(true);
|
|
670
681
|
logger.info("Midnight MCP Server running on stdio");
|
|
671
682
|
}
|
|
672
683
|
//# sourceMappingURL=server.js.map
|