midnight-mcp 0.1.23 → 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/README.md CHANGED
@@ -15,11 +15,13 @@ MCP server that gives AI assistants access to Midnight blockchain—search contr
15
15
  ```json
16
16
  {
17
17
  "mcpServers": {
18
- "midnight": { "command": "npx", "args": ["-y", "midnight-mcp"] }
18
+ "midnight": { "command": "npx", "args": ["-y", "midnight-mcp@latest"] }
19
19
  }
20
20
  }
21
21
  ```
22
22
 
23
+ > **💡 Tip:** Using `@latest` ensures you always get the newest version with all features. If tools seem missing, run `rm -rf ~/.npm/_npx` and restart Claude Desktop.
24
+
23
25
  **Cursor** — One-click install:
24
26
 
25
27
  [![Install MCP Server](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=midnight&config=eyJjb21tYW5kIjoibnB4IC15IG1pZG5pZ2h0LW1jcCJ9)
@@ -73,19 +75,23 @@ Restart your editor after adding the config. **No API keys required.**
73
75
 
74
76
  ## Features
75
77
 
76
- **23 Tools** — Search, analyze, version tracking, AI generation, compound operations
77
-
78
- | Category | Tools |
79
- | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
80
- | Search | `midnight-search-compact`, `midnight-search-typescript`, `midnight-search-docs` |
81
- | Analysis | `midnight-analyze-contract`, `midnight-explain-circuit` |
82
- | Repository | `midnight-get-file`, `midnight-list-examples`, `midnight-get-latest-updates` |
83
- | Versioning | `midnight-get-version-info`, `midnight-check-breaking-changes`, `midnight-get-migration-guide`, `midnight-get-file-at-version`, `midnight-compare-syntax`, `midnight-get-latest-syntax` |
84
- | AI Generation | `midnight-generate-contract`, `midnight-review-contract`, `midnight-document-contract` _(requires sampling)_ |
85
- | Compound | `midnight-upgrade-check`, `midnight-get-repo-context` _(saves 50-70% tokens)_ |
86
- | Discovery | `midnight-list-tool-categories`, `midnight-list-category-tools`, `midnight-health-check`, `midnight-get-status` |
87
-
88
- > **Tip:** Use compound tools (`midnight-upgrade-check`, `midnight-get-repo-context`) for efficient multi-step operations in a single call.
78
+ **24 Tools** — Search, analyze, validate, version tracking, AI generation, compound operations
79
+
80
+ | Category | Tools |
81
+ | -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
82
+ | Search | `midnight-search-compact`, `midnight-search-typescript`, `midnight-search-docs` |
83
+ | Analysis | `midnight-analyze-contract`, `midnight-explain-circuit` |
84
+ | **Validation** | `midnight-validate-contract` ⭐, `midnight-extract-contract-structure` |
85
+ | Repository | `midnight-get-file`, `midnight-list-examples`, `midnight-get-latest-updates` |
86
+ | Versioning | `midnight-get-version-info`, `midnight-check-breaking-changes`, `midnight-get-migration-guide`, `midnight-get-file-at-version`, `midnight-compare-syntax`, `midnight-get-latest-syntax` |
87
+ | AI Generation | `midnight-generate-contract`, `midnight-review-contract`, `midnight-document-contract` _(requires sampling)_ |
88
+ | Compound | `midnight-upgrade-check`, `midnight-get-repo-context` _(saves 50-70% tokens)_ |
89
+ | Health | `midnight-health-check`, `midnight-get-status`, `midnight-check-version` 🔄 |
90
+ | Discovery | `midnight-list-tool-categories`, `midnight-list-category-tools` |
91
+
92
+ > **⭐ Key Tool:** `midnight-validate-contract` compiles code using the **real Compact compiler** - essential for verifying contracts actually work before deployment.
93
+ >
94
+ > **🔄 New:** `midnight-check-version` tells you if you're running the latest version with update instructions.
89
95
 
90
96
  **9 Embedded Resources** — Quick references available offline: Compact syntax, SDK API, OpenZeppelin contracts, tokenomics, wallet integration, common errors
91
97
 
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: "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,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(result, null, 2),
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("Server created successfully");
461
+ logger.info(`Server v${CURRENT_VERSION} created successfully`);
407
462
  return server;
408
463
  }
409
464
  /**
@@ -11,8 +11,10 @@ export declare const HealthCheckInputSchema: z.ZodObject<{
11
11
  detailed?: boolean | undefined;
12
12
  }>;
13
13
  export declare const GetStatusInputSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
14
+ export declare const CheckVersionInputSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
14
15
  export type HealthCheckInput = z.infer<typeof HealthCheckInputSchema>;
15
16
  export type GetStatusInput = z.infer<typeof GetStatusInputSchema>;
17
+ export type CheckVersionInput = z.infer<typeof CheckVersionInputSchema>;
16
18
  /**
17
19
  * Perform health check on the MCP server
18
20
  */
@@ -64,5 +66,30 @@ export declare function getStatus(_input: GetStatusInput): Promise<{
64
66
  metadata: import("../utils/cache.js").CacheStats;
65
67
  };
66
68
  }>;
69
+ /**
70
+ * Check if current version is up to date with npm
71
+ */
72
+ export declare function checkVersion(_input: CheckVersionInput): Promise<{
73
+ currentVersion: string;
74
+ latestVersion: string;
75
+ isUpToDate: boolean;
76
+ error: string;
77
+ message?: undefined;
78
+ updateInstructions?: undefined;
79
+ newFeatures?: undefined;
80
+ } | {
81
+ currentVersion: string;
82
+ latestVersion: string;
83
+ isUpToDate: boolean;
84
+ message: string;
85
+ updateInstructions: {
86
+ step1: string;
87
+ step2: string;
88
+ step3: string;
89
+ alternative: string;
90
+ } | null;
91
+ newFeatures: string[] | null;
92
+ error?: undefined;
93
+ }>;
67
94
  export declare const healthTools: ExtendedToolDefinition[];
68
95
  //# sourceMappingURL=health.d.ts.map
@@ -4,6 +4,8 @@
4
4
  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
+ // Current version - should match package.json
8
+ const CURRENT_VERSION = "0.1.25";
7
9
  // Schema definitions
8
10
  export const HealthCheckInputSchema = z.object({
9
11
  detailed: z
@@ -13,6 +15,7 @@ export const HealthCheckInputSchema = z.object({
13
15
  .describe("Include detailed checks (slower but more comprehensive)"),
14
16
  });
15
17
  export const GetStatusInputSchema = z.object({});
18
+ export const CheckVersionInputSchema = z.object({});
16
19
  /**
17
20
  * Perform health check on the MCP server
18
21
  */
@@ -61,6 +64,56 @@ export async function getStatus(_input) {
61
64
  },
62
65
  };
63
66
  }
67
+ /**
68
+ * Check if current version is up to date with npm
69
+ */
70
+ export async function checkVersion(_input) {
71
+ try {
72
+ const response = await fetch("https://registry.npmjs.org/midnight-mcp/latest");
73
+ if (!response.ok) {
74
+ return {
75
+ currentVersion: CURRENT_VERSION,
76
+ latestVersion: "unknown",
77
+ isUpToDate: true, // Assume up to date if we can't check
78
+ error: "Could not fetch latest version from npm",
79
+ };
80
+ }
81
+ const data = (await response.json());
82
+ const latestVersion = data.version;
83
+ const isUpToDate = CURRENT_VERSION === latestVersion;
84
+ return {
85
+ currentVersion: CURRENT_VERSION,
86
+ latestVersion,
87
+ isUpToDate,
88
+ message: isUpToDate
89
+ ? "✅ You are running the latest version!"
90
+ : `⚠️ UPDATE AVAILABLE: v${latestVersion} (you have v${CURRENT_VERSION})`,
91
+ updateInstructions: isUpToDate
92
+ ? null
93
+ : {
94
+ step1: "Clear npx cache: rm -rf ~/.npm/_npx (macOS/Linux) or del /s /q %LocalAppData%\\npm-cache\\_npx (Windows)",
95
+ step2: "Restart Claude Desktop completely (Cmd+Q / Alt+F4, then reopen)",
96
+ step3: "Or update config to use: npx -y midnight-mcp@latest (forces latest)",
97
+ alternative: "You can also install globally: npm install -g midnight-mcp@latest",
98
+ },
99
+ newFeatures: isUpToDate
100
+ ? null
101
+ : [
102
+ "midnight-validate-contract - Compile with REAL Compact compiler",
103
+ "midnight-extract-contract-structure - Static analysis with 10 pre-compilation checks",
104
+ "Pre-compilation detection: division operator, Counter.value, overflow, disclose() requirements",
105
+ ],
106
+ };
107
+ }
108
+ catch (error) {
109
+ return {
110
+ currentVersion: CURRENT_VERSION,
111
+ latestVersion: "unknown",
112
+ isUpToDate: true,
113
+ error: `Failed to check version: ${error instanceof Error ? error.message : "Unknown error"}`,
114
+ };
115
+ }
116
+ }
64
117
  // Output schemas for health tools
65
118
  const healthCheckOutputSchema = {
66
119
  type: "object",
@@ -160,5 +213,47 @@ export const healthTools = [
160
213
  },
161
214
  handler: getStatus,
162
215
  },
216
+ {
217
+ name: "midnight-check-version",
218
+ description: "🔄 Check if you're running the latest version of midnight-mcp. " +
219
+ "Compares your installed version against npm registry and provides update instructions if outdated. " +
220
+ "Use this if tools seem missing or you want to ensure you have the latest features like midnight-validate-contract.",
221
+ inputSchema: {
222
+ type: "object",
223
+ properties: {},
224
+ },
225
+ outputSchema: {
226
+ type: "object",
227
+ properties: {
228
+ currentVersion: {
229
+ type: "string",
230
+ description: "Your installed version",
231
+ },
232
+ latestVersion: { type: "string", description: "Latest version on npm" },
233
+ isUpToDate: {
234
+ type: "boolean",
235
+ description: "Whether you have the latest",
236
+ },
237
+ message: { type: "string", description: "Status message" },
238
+ updateInstructions: {
239
+ type: "object",
240
+ description: "How to update if outdated",
241
+ },
242
+ newFeatures: {
243
+ type: "array",
244
+ items: { type: "string" },
245
+ description: "New features in latest version",
246
+ },
247
+ },
248
+ },
249
+ annotations: {
250
+ readOnlyHint: true,
251
+ idempotentHint: true,
252
+ openWorldHint: true,
253
+ title: "🔄 Check for Updates",
254
+ category: "health",
255
+ },
256
+ handler: checkVersion,
257
+ },
163
258
  ];
164
259
  //# sourceMappingURL=health.js.map
@@ -4,8 +4,8 @@ export { analyzeTools, analyzeContract, explainCircuit } from "./analyze.js";
4
4
  export type { AnalyzeContractInput, ExplainCircuitInput } from "./analyze.js";
5
5
  export { repositoryTools, getFile, listExamples, getLatestUpdates, } from "./repository.js";
6
6
  export type { GetFileInput, ListExamplesInput, GetLatestUpdatesInput, } from "./repository.js";
7
- export { healthTools, healthCheck, getStatus } from "./health.js";
8
- export type { HealthCheckInput, GetStatusInput } from "./health.js";
7
+ export { healthTools, healthCheck, getStatus, checkVersion } from "./health.js";
8
+ export type { HealthCheckInput, GetStatusInput, CheckVersionInput, } from "./health.js";
9
9
  export { generationTools, generationHandlers } from "./generation.js";
10
10
  export { metaTools, listToolCategories, listCategoryTools } from "./meta.js";
11
11
  export type { ExtendedToolDefinition, ToolAnnotations, OutputSchema, } from "../types/index.js";
@@ -1,7 +1,7 @@
1
1
  export { searchTools, searchCompact, searchTypeScript, searchDocs, } from "./search.js";
2
2
  export { analyzeTools, analyzeContract, explainCircuit } from "./analyze.js";
3
3
  export { repositoryTools, getFile, listExamples, getLatestUpdates, } from "./repository.js";
4
- export { healthTools, healthCheck, getStatus } from "./health.js";
4
+ export { healthTools, healthCheck, getStatus, checkVersion } from "./health.js";
5
5
  export { generationTools, generationHandlers } from "./generation.js";
6
6
  export { metaTools, listToolCategories, listCategoryTools } from "./meta.js";
7
7
  // Combined tool list for MCP server
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "midnight-mcp",
3
- "version": "0.1.23",
3
+ "version": "0.1.25",
4
4
  "description": "Model Context Protocol Server for Midnight Blockchain Development",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",