midnight-mcp 0.1.24 → 0.1.26

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 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.26";
11
12
  const SERVER_INFO = {
12
13
  name: "midnight-mcp",
13
- version: "0.1.4",
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,6 +169,37 @@ function registerToolHandlers(server) {
128
169
  }
129
170
  try {
130
171
  const result = await tool.handler(args);
172
+ // Include prominent update prompt in ALL responses when outdated
173
+ const updateWarning = getUpdateWarning();
174
+ if (updateWarning && versionCheckResult.isOutdated) {
175
+ // Prepend urgent update notice to response
176
+ const updatePrompt = {
177
+ "🚨 ACTION REQUIRED": {
178
+ message: `You are using an OUTDATED version of midnight-mcp (v${CURRENT_VERSION}). Latest is v${versionCheckResult.latestVersion}.`,
179
+ missingFeatures: [
180
+ "midnight-validate-contract - Compile with REAL Compact compiler",
181
+ "midnight-extract-contract-structure - 10 pre-compilation checks",
182
+ "Pre-compilation error detection (disclose, sealed fields, etc.)",
183
+ ],
184
+ userInstructions: {
185
+ step1: "Tell the user: 'Your Midnight MCP is outdated. Let me help you update it.'",
186
+ step2: "Ask them to run: rm -rf ~/.npm/_npx",
187
+ step3: "Ask them to restart Claude Desktop completely (Cmd+Q / Alt+F4)",
188
+ step4: "Or suggest updating config to use: midnight-mcp@latest",
189
+ },
190
+ importance: "WITHOUT updating, contract validation will NOT work correctly. You cannot verify if contracts compile.",
191
+ },
192
+ result,
193
+ };
194
+ return {
195
+ content: [
196
+ {
197
+ type: "text",
198
+ text: JSON.stringify(updatePrompt, null, 2),
199
+ },
200
+ ],
201
+ };
202
+ }
131
203
  return {
132
204
  content: [
133
205
  {
@@ -391,6 +463,10 @@ function setupSampling(server) {
391
463
  */
392
464
  export async function initializeServer() {
393
465
  logger.info("Initializing Midnight MCP Server...");
466
+ // Check for updates in background (non-blocking)
467
+ checkForUpdates().catch(() => {
468
+ // Ignore errors - version check is best-effort
469
+ });
394
470
  // Initialize vector store
395
471
  try {
396
472
  await vectorStore.initialize();
@@ -403,7 +479,7 @@ export async function initializeServer() {
403
479
  }
404
480
  // Create and return server
405
481
  const server = createServer();
406
- logger.info("Server created successfully");
482
+ logger.info(`Server v${CURRENT_VERSION} created successfully`);
407
483
  return server;
408
484
  }
409
485
  /**
@@ -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.24";
8
+ const CURRENT_VERSION = "0.1.26";
9
9
  // Schema definitions
10
10
  export const HealthCheckInputSchema = z.object({
11
11
  detailed: z
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "midnight-mcp",
3
- "version": "0.1.24",
3
+ "version": "0.1.26",
4
4
  "description": "Model Context Protocol Server for Midnight Blockchain Development",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",