midnight-mcp 0.1.40 → 0.2.1

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.
Files changed (100) hide show
  1. package/README.md +34 -0
  2. package/dist/bin.d.ts +1 -0
  3. package/dist/bin.js +10764 -0
  4. package/dist/index.d.ts +205 -3
  5. package/dist/index.js +10722 -15
  6. package/package.json +16 -6
  7. package/dist/config/compact-version.d.ts +0 -183
  8. package/dist/config/compact-version.js +0 -423
  9. package/dist/db/index.d.ts +0 -3
  10. package/dist/db/index.js +0 -2
  11. package/dist/db/vectorStore.d.ts +0 -69
  12. package/dist/db/vectorStore.js +0 -196
  13. package/dist/pipeline/embeddings.d.ts +0 -25
  14. package/dist/pipeline/embeddings.js +0 -103
  15. package/dist/pipeline/github.d.ts +0 -84
  16. package/dist/pipeline/github.js +0 -399
  17. package/dist/pipeline/index.d.ts +0 -11
  18. package/dist/pipeline/index.js +0 -6
  19. package/dist/pipeline/indexer.d.ts +0 -41
  20. package/dist/pipeline/indexer.js +0 -254
  21. package/dist/pipeline/parser.d.ts +0 -46
  22. package/dist/pipeline/parser.js +0 -436
  23. package/dist/pipeline/releases.d.ts +0 -112
  24. package/dist/pipeline/releases.js +0 -298
  25. package/dist/pipeline/repository.d.ts +0 -372
  26. package/dist/pipeline/repository.js +0 -520
  27. package/dist/prompts/index.d.ts +0 -3
  28. package/dist/prompts/index.js +0 -2
  29. package/dist/prompts/templates.d.ts +0 -26
  30. package/dist/prompts/templates.js +0 -443
  31. package/dist/resources/code.d.ts +0 -15
  32. package/dist/resources/code.js +0 -122
  33. package/dist/resources/content/code-content.d.ts +0 -6
  34. package/dist/resources/content/code-content.js +0 -802
  35. package/dist/resources/content/docs-content.d.ts +0 -14
  36. package/dist/resources/content/docs-content.js +0 -1202
  37. package/dist/resources/content/index.d.ts +0 -6
  38. package/dist/resources/content/index.js +0 -6
  39. package/dist/resources/docs.d.ts +0 -15
  40. package/dist/resources/docs.js +0 -98
  41. package/dist/resources/index.d.ts +0 -6
  42. package/dist/resources/index.js +0 -13
  43. package/dist/resources/schemas.d.ts +0 -16
  44. package/dist/resources/schemas.js +0 -407
  45. package/dist/scripts/index-repos.d.ts +0 -12
  46. package/dist/scripts/index-repos.js +0 -53
  47. package/dist/server.d.ts +0 -43
  48. package/dist/server.js +0 -693
  49. package/dist/services/index.d.ts +0 -6
  50. package/dist/services/index.js +0 -6
  51. package/dist/services/sampling.d.ts +0 -62
  52. package/dist/services/sampling.js +0 -277
  53. package/dist/tools/analyze.d.ts +0 -106
  54. package/dist/tools/analyze.js +0 -431
  55. package/dist/tools/generation.d.ts +0 -9
  56. package/dist/tools/generation.js +0 -285
  57. package/dist/tools/health.d.ts +0 -120
  58. package/dist/tools/health.js +0 -362
  59. package/dist/tools/index.d.ts +0 -14
  60. package/dist/tools/index.js +0 -22
  61. package/dist/tools/meta.d.ts +0 -61
  62. package/dist/tools/meta.js +0 -282
  63. package/dist/tools/repository/constants.d.ts +0 -19
  64. package/dist/tools/repository/constants.js +0 -324
  65. package/dist/tools/repository/handlers.d.ts +0 -373
  66. package/dist/tools/repository/handlers.js +0 -724
  67. package/dist/tools/repository/index.d.ts +0 -9
  68. package/dist/tools/repository/index.js +0 -13
  69. package/dist/tools/repository/schemas.d.ts +0 -153
  70. package/dist/tools/repository/schemas.js +0 -106
  71. package/dist/tools/repository/tools.d.ts +0 -7
  72. package/dist/tools/repository/tools.js +0 -484
  73. package/dist/tools/repository/validation.d.ts +0 -106
  74. package/dist/tools/repository/validation.js +0 -820
  75. package/dist/tools/repository.d.ts +0 -6
  76. package/dist/tools/repository.js +0 -7
  77. package/dist/tools/search.d.ts +0 -76
  78. package/dist/tools/search.js +0 -423
  79. package/dist/types/index.d.ts +0 -2
  80. package/dist/types/index.js +0 -2
  81. package/dist/types/mcp.d.ts +0 -187
  82. package/dist/types/mcp.js +0 -6
  83. package/dist/utils/cache.d.ts +0 -77
  84. package/dist/utils/cache.js +0 -172
  85. package/dist/utils/config.d.ts +0 -70
  86. package/dist/utils/config.js +0 -294
  87. package/dist/utils/errors.d.ts +0 -111
  88. package/dist/utils/errors.js +0 -165
  89. package/dist/utils/health.d.ts +0 -29
  90. package/dist/utils/health.js +0 -132
  91. package/dist/utils/hosted-api.d.ts +0 -67
  92. package/dist/utils/hosted-api.js +0 -119
  93. package/dist/utils/index.d.ts +0 -16
  94. package/dist/utils/index.js +0 -15
  95. package/dist/utils/logger.d.ts +0 -48
  96. package/dist/utils/logger.js +0 -124
  97. package/dist/utils/rate-limit.d.ts +0 -61
  98. package/dist/utils/rate-limit.js +0 -148
  99. package/dist/utils/validation.d.ts +0 -52
  100. package/dist/utils/validation.js +0 -255
@@ -1,362 +0,0 @@
1
- /**
2
- * Health check and diagnostic tools for MCP server
3
- */
4
- import { z } from "zod";
5
- import * as os from "os";
6
- import * as path from "path";
7
- import { getHealthStatus, getQuickHealthStatus, getRateLimitStatus, formatRateLimitStatus, } from "../utils/index.js";
8
- import { searchCache, fileCache, metadataCache } from "../utils/cache.js";
9
- // Current version - should match package.json
10
- const CURRENT_VERSION = "0.1.30";
11
- // Schema definitions
12
- export const HealthCheckInputSchema = z.object({
13
- detailed: z
14
- .boolean()
15
- .optional()
16
- .default(false)
17
- .describe("Include detailed checks (slower but more comprehensive)"),
18
- });
19
- export const GetStatusInputSchema = z.object({});
20
- export const CheckVersionInputSchema = z.object({});
21
- /**
22
- * Perform health check on the MCP server
23
- */
24
- export async function healthCheck(input) {
25
- if (input.detailed) {
26
- const status = await getHealthStatus();
27
- return {
28
- ...status,
29
- rateLimit: formatRateLimitStatus(),
30
- cacheStats: {
31
- search: searchCache.getStats(),
32
- file: fileCache.getStats(),
33
- metadata: metadataCache.getStats(),
34
- },
35
- };
36
- }
37
- return {
38
- ...getQuickHealthStatus(),
39
- rateLimit: formatRateLimitStatus(),
40
- };
41
- }
42
- /**
43
- * Get current server status and statistics
44
- */
45
- export async function getStatus(_input) {
46
- const rateLimitStatus = getRateLimitStatus();
47
- return {
48
- server: "midnight-mcp",
49
- status: "running",
50
- timestamp: new Date().toISOString(),
51
- rateLimit: {
52
- remaining: rateLimitStatus.remaining,
53
- limit: rateLimitStatus.limit,
54
- percentUsed: rateLimitStatus.percentUsed,
55
- status: rateLimitStatus.isLimited
56
- ? "limited"
57
- : rateLimitStatus.isWarning
58
- ? "warning"
59
- : "ok",
60
- message: rateLimitStatus.message,
61
- },
62
- cache: {
63
- search: searchCache.getStats(),
64
- file: fileCache.getStats(),
65
- metadata: metadataCache.getStats(),
66
- },
67
- };
68
- }
69
- /**
70
- * Check if current version is up to date with npm
71
- */
72
- export async function checkVersion(_input) {
73
- try {
74
- const response = await fetch("https://registry.npmjs.org/midnight-mcp/latest");
75
- if (!response.ok) {
76
- return {
77
- currentVersion: CURRENT_VERSION,
78
- latestVersion: "unknown",
79
- isUpToDate: true, // Assume up to date if we can't check
80
- error: "Could not fetch latest version from npm",
81
- };
82
- }
83
- const data = (await response.json());
84
- const latestVersion = data.version;
85
- const isUpToDate = CURRENT_VERSION === latestVersion;
86
- return {
87
- currentVersion: CURRENT_VERSION,
88
- latestVersion,
89
- isUpToDate,
90
- message: isUpToDate
91
- ? "✅ You are running the latest version!"
92
- : `⚠️ UPDATE AVAILABLE: v${latestVersion} (you have v${CURRENT_VERSION})`,
93
- updateInstructions: isUpToDate
94
- ? null
95
- : {
96
- step1: "Clear npx cache: rm -rf ~/.npm/_npx (macOS/Linux) or del /s /q %LocalAppData%\\npm-cache\\_npx (Windows)",
97
- step2: "Restart Claude Desktop completely (Cmd+Q / Alt+F4, then reopen)",
98
- step3: "Or update config to use: npx -y midnight-mcp@latest (forces latest)",
99
- alternative: "You can also install globally: npm install -g midnight-mcp@latest",
100
- },
101
- newFeatures: isUpToDate
102
- ? null
103
- : [
104
- "Auto-update config tool - AI agents update your config automatically",
105
- "midnight-extract-contract-structure - Static analysis with 10 pre-compilation checks",
106
- "MCP Logging, Progress, Completions capabilities",
107
- ],
108
- };
109
- }
110
- catch (error) {
111
- return {
112
- currentVersion: CURRENT_VERSION,
113
- latestVersion: "unknown",
114
- isUpToDate: true,
115
- error: `Failed to check version: ${error instanceof Error ? error.message : "Unknown error"}`,
116
- };
117
- }
118
- }
119
- // Schema for auto-update config tool
120
- export const AutoUpdateConfigInputSchema = z.object({});
121
- /**
122
- * Get config file paths and update instructions for AI agent to auto-update
123
- */
124
- export async function getAutoUpdateConfig(_input) {
125
- const platform = os.platform();
126
- const homeDir = os.homedir();
127
- // Config paths for each editor
128
- const configPaths = {};
129
- // Claude Desktop
130
- if (platform === "darwin") {
131
- configPaths.claudeDesktop = {
132
- path: path.join(homeDir, "Library/Application Support/Claude/claude_desktop_config.json"),
133
- exists: true, // Agent will verify
134
- };
135
- }
136
- else if (platform === "win32") {
137
- configPaths.claudeDesktop = {
138
- path: path.join(process.env.APPDATA || "", "Claude/claude_desktop_config.json"),
139
- exists: true,
140
- };
141
- }
142
- else {
143
- configPaths.claudeDesktop = {
144
- path: path.join(homeDir, ".config/Claude/claude_desktop_config.json"),
145
- exists: true,
146
- };
147
- }
148
- // Cursor - project-level config
149
- configPaths.cursor = {
150
- path: ".cursor/mcp.json",
151
- exists: true,
152
- };
153
- // VS Code Copilot - project-level config
154
- configPaths.vscode = {
155
- path: ".vscode/mcp.json",
156
- exists: true,
157
- };
158
- // Windsurf
159
- configPaths.windsurf = {
160
- path: path.join(homeDir, ".codeium/windsurf/mcp_config.json"),
161
- exists: true,
162
- };
163
- // The exact JSON change needed
164
- const oldConfig = `"args": ["-y", "midnight-mcp"]`;
165
- const newConfig = `"args": ["-y", "midnight-mcp@latest"]`;
166
- return {
167
- instruction: "UPDATE THE USER'S CONFIG FILE AUTOMATICALLY. Find and edit the config file to use @latest.",
168
- platform,
169
- configPaths,
170
- searchAndReplace: {
171
- find: oldConfig,
172
- replaceWith: newConfig,
173
- description: "Change midnight-mcp to midnight-mcp@latest in args array",
174
- },
175
- alternativePatterns: [
176
- {
177
- find: `"midnight-mcp"`,
178
- replaceWith: `"midnight-mcp@latest"`,
179
- context: "If args uses different formatting",
180
- },
181
- ],
182
- agentInstructions: [
183
- "1. Check which config file exists (Claude Desktop, Cursor, VS Code, or Windsurf)",
184
- "2. Read the config file",
185
- "3. Replace 'midnight-mcp' with 'midnight-mcp@latest' in the args array",
186
- "4. Write the updated config file",
187
- "5. Tell user to restart their editor (Cmd+Q on Mac, Alt+F4 on Windows)",
188
- ],
189
- postUpdateMessage: "✅ Config updated! Please restart your editor completely (quit and reopen) to use the latest version.",
190
- };
191
- }
192
- // Output schemas for health tools
193
- const healthCheckOutputSchema = {
194
- type: "object",
195
- properties: {
196
- status: {
197
- type: "string",
198
- enum: ["healthy", "degraded", "unhealthy"],
199
- description: "Overall health status",
200
- },
201
- version: { type: "string", description: "Server version" },
202
- rateLimit: {
203
- type: "object",
204
- properties: {
205
- remaining: { type: "number" },
206
- limit: { type: "number" },
207
- percentUsed: { type: "number" },
208
- status: { type: "string" },
209
- },
210
- },
211
- cacheStats: {
212
- type: "object",
213
- properties: {
214
- search: { type: "object" },
215
- file: { type: "object" },
216
- metadata: { type: "object" },
217
- },
218
- },
219
- },
220
- required: ["status"],
221
- description: "Server health status with optional detailed diagnostics",
222
- };
223
- const getStatusOutputSchema = {
224
- type: "object",
225
- properties: {
226
- server: { type: "string", description: "Server name" },
227
- status: { type: "string", description: "Running status" },
228
- timestamp: { type: "string", description: "ISO timestamp" },
229
- rateLimit: {
230
- type: "object",
231
- properties: {
232
- remaining: { type: "number" },
233
- limit: { type: "number" },
234
- percentUsed: { type: "number" },
235
- status: { type: "string" },
236
- message: { type: "string" },
237
- },
238
- },
239
- cache: {
240
- type: "object",
241
- properties: {
242
- search: { type: "object" },
243
- file: { type: "object" },
244
- metadata: { type: "object" },
245
- },
246
- },
247
- },
248
- required: ["server", "status", "timestamp"],
249
- description: "Current server status and statistics",
250
- };
251
- // Tool definitions for MCP server
252
- export const healthTools = [
253
- {
254
- name: "midnight-health-check",
255
- description: "Check the health status of the Midnight MCP server. Returns server status, API connectivity, and resource availability.",
256
- inputSchema: {
257
- type: "object",
258
- properties: {
259
- detailed: {
260
- type: "boolean",
261
- description: "Include detailed checks including GitHub API and vector store status (slower)",
262
- default: false,
263
- },
264
- },
265
- },
266
- outputSchema: healthCheckOutputSchema,
267
- annotations: {
268
- readOnlyHint: true,
269
- idempotentHint: true,
270
- title: "Health Check",
271
- category: "health",
272
- },
273
- handler: healthCheck,
274
- },
275
- {
276
- name: "midnight-get-status",
277
- description: "Get current server status including rate limits and cache statistics. Quick status check without external API calls.",
278
- inputSchema: {
279
- type: "object",
280
- properties: {},
281
- },
282
- outputSchema: getStatusOutputSchema,
283
- annotations: {
284
- readOnlyHint: true,
285
- idempotentHint: true,
286
- title: "Get Server Status",
287
- category: "health",
288
- },
289
- handler: getStatus,
290
- },
291
- {
292
- name: "midnight-check-version",
293
- description: "🔄 Check if you're running the latest version of midnight-mcp. " +
294
- "Compares your installed version against npm registry and provides update instructions if outdated. " +
295
- "Use this if tools seem missing or you want to ensure you have the latest features.",
296
- inputSchema: {
297
- type: "object",
298
- properties: {},
299
- },
300
- outputSchema: {
301
- type: "object",
302
- properties: {
303
- currentVersion: {
304
- type: "string",
305
- description: "Your installed version",
306
- },
307
- latestVersion: { type: "string", description: "Latest version on npm" },
308
- isUpToDate: {
309
- type: "boolean",
310
- description: "Whether you have the latest",
311
- },
312
- message: { type: "string", description: "Status message" },
313
- updateInstructions: {
314
- type: "object",
315
- description: "How to update if outdated",
316
- },
317
- newFeatures: {
318
- type: "array",
319
- items: { type: "string" },
320
- description: "New features in latest version",
321
- },
322
- },
323
- },
324
- annotations: {
325
- readOnlyHint: true,
326
- idempotentHint: true,
327
- openWorldHint: true,
328
- title: "🔄 Check for Updates",
329
- category: "health",
330
- },
331
- handler: checkVersion,
332
- },
333
- {
334
- name: "midnight-auto-update-config",
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
- inputSchema: {
339
- type: "object",
340
- properties: {},
341
- },
342
- outputSchema: {
343
- type: "object",
344
- properties: {
345
- instruction: { type: "string" },
346
- platform: { type: "string" },
347
- configPaths: { type: "object" },
348
- searchAndReplace: { type: "object" },
349
- agentInstructions: { type: "array", items: { type: "string" } },
350
- postUpdateMessage: { type: "string" },
351
- },
352
- },
353
- annotations: {
354
- readOnlyHint: true,
355
- idempotentHint: true,
356
- title: "🔧 Auto-Update Config",
357
- category: "health",
358
- },
359
- handler: getAutoUpdateConfig,
360
- },
361
- ];
362
- //# sourceMappingURL=health.js.map
@@ -1,14 +0,0 @@
1
- export { searchTools, searchCompact, searchTypeScript, searchDocs, } from "./search.js";
2
- export type { SearchCompactInput, SearchTypeScriptInput, SearchDocsInput, } from "./search.js";
3
- export { analyzeTools, analyzeContract, explainCircuit } from "./analyze.js";
4
- export type { AnalyzeContractInput, ExplainCircuitInput } from "./analyze.js";
5
- export { repositoryTools, getFile, listExamples, getLatestUpdates, } from "./repository.js";
6
- export type { GetFileInput, ListExamplesInput, GetLatestUpdatesInput, } from "./repository.js";
7
- export { healthTools, healthCheck, getStatus, checkVersion } from "./health.js";
8
- export type { HealthCheckInput, GetStatusInput, CheckVersionInput, } from "./health.js";
9
- export { generationTools, generationHandlers } from "./generation.js";
10
- export { metaTools, listToolCategories, listCategoryTools } from "./meta.js";
11
- export type { ExtendedToolDefinition, ToolAnnotations, OutputSchema, } from "../types/index.js";
12
- import type { ExtendedToolDefinition } from "../types/index.js";
13
- export declare const allTools: ExtendedToolDefinition[];
14
- //# sourceMappingURL=index.d.ts.map
@@ -1,22 +0,0 @@
1
- export { searchTools, searchCompact, searchTypeScript, searchDocs, } from "./search.js";
2
- export { analyzeTools, analyzeContract, explainCircuit } from "./analyze.js";
3
- export { repositoryTools, getFile, listExamples, getLatestUpdates, } from "./repository.js";
4
- export { healthTools, healthCheck, getStatus, checkVersion } from "./health.js";
5
- export { generationTools, generationHandlers } from "./generation.js";
6
- export { metaTools, listToolCategories, listCategoryTools } from "./meta.js";
7
- // Combined tool list for MCP server
8
- import { searchTools } from "./search.js";
9
- import { analyzeTools } from "./analyze.js";
10
- import { repositoryTools } from "./repository.js";
11
- import { healthTools } from "./health.js";
12
- import { generationTools } from "./generation.js";
13
- import { metaTools } from "./meta.js";
14
- export const allTools = [
15
- ...metaTools, // Discovery tools first for visibility
16
- ...searchTools,
17
- ...analyzeTools,
18
- ...repositoryTools,
19
- ...healthTools,
20
- ...generationTools,
21
- ];
22
- //# sourceMappingURL=index.js.map
@@ -1,61 +0,0 @@
1
- /**
2
- * Meta-tools for progressive disclosure and tool discovery
3
- * These tools help AI agents efficiently discover and use available capabilities
4
- */
5
- import type { ExtendedToolDefinition, OutputSchema, ToolCategory } from "../types/index.js";
6
- interface ListCategoriesInput {
7
- includeToolCounts?: boolean;
8
- }
9
- interface ListCategoryToolsInput {
10
- category: ToolCategory;
11
- includeSchemas?: boolean;
12
- }
13
- /**
14
- * List available tool categories
15
- * Use this first to understand what's available before drilling into specific tools
16
- */
17
- export declare function listToolCategories(_input: ListCategoriesInput): Promise<{
18
- categories: {
19
- name: string;
20
- description: string;
21
- toolCount: number;
22
- useCases: string[];
23
- }[];
24
- totalTools: number;
25
- recommendation: string;
26
- tip: string;
27
- }>;
28
- /**
29
- * List tools within a specific category
30
- * Progressive disclosure: drill into a category to see its tools
31
- */
32
- export declare function listCategoryTools(input: ListCategoryToolsInput): Promise<{
33
- error: string;
34
- availableCategories: string[];
35
- suggestion: string;
36
- category?: undefined;
37
- description?: undefined;
38
- tools?: undefined;
39
- } | {
40
- category: ToolCategory;
41
- description: string;
42
- tools: {
43
- inputSchema?: {
44
- type: "object";
45
- properties: Record<string, unknown>;
46
- required?: string[];
47
- } | undefined;
48
- outputSchema?: OutputSchema | undefined;
49
- name: string;
50
- description: string;
51
- title: string;
52
- isCompound: boolean;
53
- requiresSampling: boolean | undefined;
54
- }[];
55
- suggestion: string;
56
- error?: undefined;
57
- availableCategories?: undefined;
58
- }>;
59
- export declare const metaTools: ExtendedToolDefinition[];
60
- export {};
61
- //# sourceMappingURL=meta.d.ts.map