midnight-mcp 0.1.24 → 0.1.25
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 +58 -3
- package/dist/tools/health.js +1 -1
- package/package.json +1 -1
package/dist/server.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Get update warning if outdated (to include in responses)
|
|
4
|
+
*/
|
|
5
|
+
export declare function getUpdateWarning(): string | null;
|
|
2
6
|
/**
|
|
3
7
|
* Clear all subscriptions (useful for server restart/testing)
|
|
4
8
|
*/
|
package/dist/server.js
CHANGED
|
@@ -8,11 +8,52 @@ import { allResources, getDocumentation, getCode, getSchema, } from "./resources
|
|
|
8
8
|
import { promptDefinitions, generatePrompt } from "./prompts/index.js";
|
|
9
9
|
import { registerSamplingCallback } from "./services/index.js";
|
|
10
10
|
// Server information - version should match package.json
|
|
11
|
+
const CURRENT_VERSION = "0.1.25";
|
|
11
12
|
const SERVER_INFO = {
|
|
12
13
|
name: "midnight-mcp",
|
|
13
|
-
version:
|
|
14
|
+
version: CURRENT_VERSION,
|
|
14
15
|
description: "MCP Server for Midnight Blockchain Development",
|
|
15
16
|
};
|
|
17
|
+
// Version check state
|
|
18
|
+
let versionCheckResult = {
|
|
19
|
+
isOutdated: false,
|
|
20
|
+
latestVersion: CURRENT_VERSION,
|
|
21
|
+
updateMessage: null,
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Check for updates against npm registry (runs at startup)
|
|
25
|
+
*/
|
|
26
|
+
async function checkForUpdates() {
|
|
27
|
+
try {
|
|
28
|
+
const controller = new AbortController();
|
|
29
|
+
const timeoutId = setTimeout(() => controller.abort(), 5000); // 5s timeout
|
|
30
|
+
const response = await fetch("https://registry.npmjs.org/midnight-mcp/latest", { signal: controller.signal });
|
|
31
|
+
clearTimeout(timeoutId);
|
|
32
|
+
if (!response.ok)
|
|
33
|
+
return;
|
|
34
|
+
const data = (await response.json());
|
|
35
|
+
const latestVersion = data.version;
|
|
36
|
+
if (latestVersion !== CURRENT_VERSION) {
|
|
37
|
+
versionCheckResult = {
|
|
38
|
+
isOutdated: true,
|
|
39
|
+
latestVersion,
|
|
40
|
+
updateMessage: `⚠️ UPDATE AVAILABLE: v${latestVersion} (you have v${CURRENT_VERSION}). ` +
|
|
41
|
+
`Run: rm -rf ~/.npm/_npx && restart Claude Desktop. ` +
|
|
42
|
+
`Or update config to use: "midnight-mcp@latest"`,
|
|
43
|
+
};
|
|
44
|
+
logger.warn(`Outdated version detected: v${CURRENT_VERSION} -> v${latestVersion}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
// Silently ignore version check failures (offline, timeout, etc.)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Get update warning if outdated (to include in responses)
|
|
53
|
+
*/
|
|
54
|
+
export function getUpdateWarning() {
|
|
55
|
+
return versionCheckResult.updateMessage;
|
|
56
|
+
}
|
|
16
57
|
// Resource subscriptions tracking
|
|
17
58
|
const resourceSubscriptions = new Set();
|
|
18
59
|
/**
|
|
@@ -128,11 +169,21 @@ function registerToolHandlers(server) {
|
|
|
128
169
|
}
|
|
129
170
|
try {
|
|
130
171
|
const result = await tool.handler(args);
|
|
172
|
+
// Include update warning for key tools if outdated
|
|
173
|
+
const updateWarning = getUpdateWarning();
|
|
174
|
+
const shouldWarn = updateWarning &&
|
|
175
|
+
(name === "midnight-health-check" ||
|
|
176
|
+
name === "midnight-get-status" ||
|
|
177
|
+
name === "midnight-analyze-contract" ||
|
|
178
|
+
name === "midnight-list-tool-categories");
|
|
179
|
+
const responseData = shouldWarn
|
|
180
|
+
? { ...result, _updateAvailable: updateWarning }
|
|
181
|
+
: result;
|
|
131
182
|
return {
|
|
132
183
|
content: [
|
|
133
184
|
{
|
|
134
185
|
type: "text",
|
|
135
|
-
text: JSON.stringify(
|
|
186
|
+
text: JSON.stringify(responseData, null, 2),
|
|
136
187
|
},
|
|
137
188
|
],
|
|
138
189
|
};
|
|
@@ -391,6 +442,10 @@ function setupSampling(server) {
|
|
|
391
442
|
*/
|
|
392
443
|
export async function initializeServer() {
|
|
393
444
|
logger.info("Initializing Midnight MCP Server...");
|
|
445
|
+
// Check for updates in background (non-blocking)
|
|
446
|
+
checkForUpdates().catch(() => {
|
|
447
|
+
// Ignore errors - version check is best-effort
|
|
448
|
+
});
|
|
394
449
|
// Initialize vector store
|
|
395
450
|
try {
|
|
396
451
|
await vectorStore.initialize();
|
|
@@ -403,7 +458,7 @@ export async function initializeServer() {
|
|
|
403
458
|
}
|
|
404
459
|
// Create and return server
|
|
405
460
|
const server = createServer();
|
|
406
|
-
logger.info(
|
|
461
|
+
logger.info(`Server v${CURRENT_VERSION} created successfully`);
|
|
407
462
|
return server;
|
|
408
463
|
}
|
|
409
464
|
/**
|
package/dist/tools/health.js
CHANGED
|
@@ -5,7 +5,7 @@ import { z } from "zod";
|
|
|
5
5
|
import { getHealthStatus, getQuickHealthStatus, getRateLimitStatus, formatRateLimitStatus, } from "../utils/index.js";
|
|
6
6
|
import { searchCache, fileCache, metadataCache } from "../utils/cache.js";
|
|
7
7
|
// Current version - should match package.json
|
|
8
|
-
const CURRENT_VERSION = "0.1.
|
|
8
|
+
const CURRENT_VERSION = "0.1.25";
|
|
9
9
|
// Schema definitions
|
|
10
10
|
export const HealthCheckInputSchema = z.object({
|
|
11
11
|
detailed: z
|