midnight-mcp 0.1.37 → 0.1.39

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
@@ -71,19 +71,28 @@ Add to `~/.codeium/windsurf/mcp_config.json`:
71
71
 
72
72
  **No API keys required.** Restart your editor after adding the config.
73
73
 
74
- ### Automatic Updates
74
+ ### Updating to Latest Version
75
75
 
76
- Using `midnight-mcp@latest` ensures you always get the newest version.
76
+ Using `midnight-mcp@latest` in your config ensures you get updates automatically on restart.
77
77
 
78
- **If you have an older version:** The AI agent will detect it and offer to update your config automatically—no manual steps required! Just approve the config edit and restart your editor.
79
-
80
- Or manually update your config:
78
+ **Already using an older version without `@latest`?** Update your config manually:
81
79
 
82
80
  ```diff
83
81
  - "args": ["-y", "midnight-mcp"]
84
82
  + "args": ["-y", "midnight-mcp@latest"]
85
83
  ```
86
84
 
85
+ **Then clear npm cache and restart:**
86
+
87
+ ```bash
88
+ # Clear npx cache (required to fetch new version)
89
+ rm -rf ~/.npm/_npx
90
+
91
+ # Restart your editor (Cmd+Q on Mac, then reopen)
92
+ ```
93
+
94
+ > **Note:** AI agents cannot auto-update your config because they run in a sandboxed environment without access to your local filesystem.
95
+
87
96
  ---
88
97
 
89
98
  ## What's Included
@@ -98,7 +107,7 @@ Or manually update your config:
98
107
  | **Versioning** | `get-version-info`, `check-breaking-changes`, `get-migration-guide`, `get-file-at-version`, `compare-syntax`, `get-latest-syntax` | Version tracking and migration |
99
108
  | **AI Generation** | `generate-contract`, `review-contract`, `document-contract` | AI-powered code generation _(requires sampling)_ |
100
109
  | **Compound** | `upgrade-check`, `get-repo-context` | Multi-step operations _(saves 50-70% tokens)_ |
101
- | **Health** | `health-check`, `get-status`, `check-version`, `auto-update-config` | Server status, version checking, auto-update |
110
+ | **Health** | `health-check`, `get-status`, `check-version` | Server status and version checking |
102
111
  | **Discovery** | `list-tool-categories`, `list-category-tools` | Explore available tools |
103
112
 
104
113
  All tools are prefixed with `midnight-` (e.g., `midnight-search-compact`).
package/dist/server.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
2
2
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
3
3
  import { CallToolRequestSchema, ListToolsRequestSchema, ListResourcesRequestSchema, ReadResourceRequestSchema, ListPromptsRequestSchema, GetPromptRequestSchema, ListResourceTemplatesRequestSchema, SubscribeRequestSchema, UnsubscribeRequestSchema, SetLevelRequestSchema, CompleteRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
4
- import { logger, formatErrorResponse, setMCPLogCallback, } from "./utils/index.js";
4
+ import { logger, formatErrorResponse, setMCPLogCallback, trackToolCall, } from "./utils/index.js";
5
5
  import { vectorStore } from "./db/index.js";
6
6
  import { allTools } from "./tools/index.js";
7
7
  import { allResources, getDocumentation, getCode, getSchema, } from "./resources/index.js";
@@ -329,12 +329,15 @@ function registerToolHandlers(server) {
329
329
  server.setRequestHandler(CallToolRequestSchema, async (request) => {
330
330
  const { name, arguments: args } = request.params;
331
331
  logger.info(`Tool called: ${name}`, { args });
332
+ const startTime = Date.now();
332
333
  const tool = allTools.find((t) => t.name === name);
333
334
  if (!tool) {
334
335
  const availableTools = allTools
335
336
  .map((t) => t.name)
336
337
  .slice(0, 5)
337
338
  .join(", ");
339
+ // Track failed tool call (unknown tool)
340
+ trackToolCall(name, false, Date.now() - startTime, CURRENT_VERSION);
338
341
  return {
339
342
  content: [
340
343
  {
@@ -351,27 +354,31 @@ function registerToolHandlers(server) {
351
354
  }
352
355
  try {
353
356
  const result = await tool.handler(args);
357
+ const durationMs = Date.now() - startTime;
358
+ // Track successful tool call (fire-and-forget, won't block response)
359
+ trackToolCall(name, true, durationMs, CURRENT_VERSION);
354
360
  // Include prominent update prompt in ALL responses when outdated
355
361
  const updateWarning = getUpdateWarning();
356
362
  if (updateWarning && versionCheckResult.isOutdated) {
357
- // Prepend urgent update notice with AUTO-UPDATE instructions
363
+ // Prepend update notice with MANUAL instructions (auto-update not possible in sandbox)
358
364
  const updatePrompt = {
359
- "🚨 AUTO-UPDATE AVAILABLE": {
360
- message: `You are using an OUTDATED version of midnight-mcp (v${CURRENT_VERSION}). Latest is v${versionCheckResult.latestVersion}.`,
361
- agentAction: {
362
- instruction: "YOU CAN AUTO-UPDATE FOR THE USER. Call the midnight-auto-update-config tool, then use your file editing capabilities to update their config automatically.",
363
- tool: "midnight-auto-update-config",
365
+ "🚨 UPDATE AVAILABLE": {
366
+ message: `You are using v${CURRENT_VERSION} but v${versionCheckResult.latestVersion} is available.`,
367
+ userAction: {
368
+ instruction: "Tell the user to update manually. Auto-update is NOT possible because you run in a sandboxed environment without access to local files.",
364
369
  steps: [
365
- "1. Call midnight-auto-update-config to get config file paths",
366
- "2. Read the user's config file (Claude Desktop, Cursor, VS Code, or Windsurf)",
367
- "3. Replace 'midnight-mcp' with 'midnight-mcp@latest' in the args array",
368
- "4. Save the file",
369
- "5. Tell user: 'I've updated your config! Please restart your editor to use the latest version.'",
370
+ "1. Edit config file to use 'midnight-mcp@latest' instead of 'midnight-mcp'",
371
+ "2. Run: rm -rf ~/.npm/_npx (to clear npm cache)",
372
+ "3. Restart the editor completely (Cmd+Q on Mac, then reopen)",
370
373
  ],
374
+ configLocations: {
375
+ claudeDesktop: "~/Library/Application Support/Claude/claude_desktop_config.json",
376
+ cursor: ".cursor/mcp.json",
377
+ vscode: ".vscode/mcp.json",
378
+ windsurf: "~/.codeium/windsurf/mcp_config.json",
379
+ },
371
380
  },
372
- fallbackInstructions: {
373
- ifAutoUpdateFails: "Ask user to manually update config to use midnight-mcp@latest",
374
- },
381
+ note: "If user already has @latest in config, they just need to clear cache (rm -rf ~/.npm/_npx) and restart.",
375
382
  },
376
383
  result,
377
384
  };
@@ -397,7 +404,10 @@ function registerToolHandlers(server) {
397
404
  };
398
405
  }
399
406
  catch (error) {
407
+ const durationMs = Date.now() - startTime;
400
408
  logger.error(`Tool error: ${name}`, { error: String(error) });
409
+ // Track failed tool call
410
+ trackToolCall(name, false, durationMs, CURRENT_VERSION);
401
411
  const errorResponse = formatErrorResponse(error, `tool:${name}`);
402
412
  return {
403
413
  content: [
@@ -332,9 +332,9 @@ export const healthTools = [
332
332
  },
333
333
  {
334
334
  name: "midnight-auto-update-config",
335
- description: "🔧 AUTO-UPDATE: Get config file paths so YOU (the AI agent) can automatically update the user's MCP config to use @latest. " +
336
- "This tool returns the exact file paths and search/replace instructions. " +
337
- "After calling this, use your file editing capabilities to update the config file automatically - NO USER ACTION REQUIRED except restart.",
335
+ description: "⚠️ DEPRECATED: Auto-update is NOT possible because AI agents run in sandboxed environments without access to local filesystems. " +
336
+ "Instead, tell users to manually update their config to use midnight-mcp@latest, then run: rm -rf ~/.npm/_npx && restart their editor. " +
337
+ "This tool only returns config file paths for reference.",
338
338
  inputSchema: {
339
339
  type: "object",
340
340
  properties: {},
@@ -59,4 +59,9 @@ export declare function getHostedApiStats(): Promise<{
59
59
  documentsIndexed: number;
60
60
  repositories: number;
61
61
  }>;
62
+ /**
63
+ * Track a tool call to the hosted API
64
+ * Fire-and-forget - doesn't block on response
65
+ */
66
+ export declare function trackToolCall(tool: string, success: boolean, durationMs?: number, version?: string): void;
62
67
  //# sourceMappingURL=hosted-api.d.ts.map
@@ -103,4 +103,17 @@ export async function checkHostedApiHealth() {
103
103
  export async function getHostedApiStats() {
104
104
  return apiRequest("/v1/stats");
105
105
  }
106
+ /**
107
+ * Track a tool call to the hosted API
108
+ * Fire-and-forget - doesn't block on response
109
+ */
110
+ export function trackToolCall(tool, success, durationMs, version) {
111
+ // Fire and forget - don't await, don't block
112
+ apiRequest("/v1/track/tool", {
113
+ method: "POST",
114
+ body: JSON.stringify({ tool, success, durationMs, version }),
115
+ }).catch(() => {
116
+ // Silently ignore tracking errors
117
+ });
118
+ }
106
119
  //# sourceMappingURL=hosted-api.js.map
@@ -11,6 +11,6 @@ export { updateRateLimitFromHeaders, updateRateLimit, getRateLimitStatus, should
11
11
  export type { RateLimitInfo, RateLimitStatus } from "./rate-limit.js";
12
12
  export { Cache, createCacheKey, searchCache, fileCache, metadataCache, pruneAllCaches, } from "./cache.js";
13
13
  export type { CacheOptions, CacheEntry, CacheStats } from "./cache.js";
14
- export { searchCompactHosted, searchTypeScriptHosted, searchDocsHosted, searchHosted, checkHostedApiHealth, getHostedApiStats, } from "./hosted-api.js";
14
+ export { searchCompactHosted, searchTypeScriptHosted, searchDocsHosted, searchHosted, checkHostedApiHealth, getHostedApiStats, trackToolCall, } from "./hosted-api.js";
15
15
  export type { HostedSearchResult, HostedSearchResponse, HostedSearchFilter, } from "./hosted-api.js";
16
16
  //# sourceMappingURL=index.d.ts.map
@@ -11,5 +11,5 @@ export { updateRateLimitFromHeaders, updateRateLimit, getRateLimitStatus, should
11
11
  // Caching utilities
12
12
  export { Cache, createCacheKey, searchCache, fileCache, metadataCache, pruneAllCaches, } from "./cache.js";
13
13
  // Hosted API client
14
- export { searchCompactHosted, searchTypeScriptHosted, searchDocsHosted, searchHosted, checkHostedApiHealth, getHostedApiStats, } from "./hosted-api.js";
14
+ export { searchCompactHosted, searchTypeScriptHosted, searchDocsHosted, searchHosted, checkHostedApiHealth, getHostedApiStats, trackToolCall, } from "./hosted-api.js";
15
15
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "midnight-mcp",
3
- "version": "0.1.37",
3
+ "version": "0.1.39",
4
4
  "description": "Model Context Protocol Server for Midnight Blockchain Development",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",