midnight-mcp 0.1.17 → 0.1.18

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.
@@ -61,6 +61,14 @@ const CATEGORY_INFO = {
61
61
  "One-shot operations",
62
62
  ],
63
63
  },
64
+ validation: {
65
+ description: "Pre-compilation contract validation using the Compact compiler",
66
+ useCases: [
67
+ "Validate contract syntax",
68
+ "Catch errors before deployment",
69
+ "Get detailed error diagnostics",
70
+ ],
71
+ },
64
72
  };
65
73
  const listCategoriesOutputSchema = {
66
74
  type: "object",
@@ -258,6 +266,7 @@ export const metaTools = [
258
266
  "generation",
259
267
  "health",
260
268
  "compound",
269
+ "validation",
261
270
  ],
262
271
  description: "Category to list tools for",
263
272
  },
@@ -3,6 +3,7 @@
3
3
  * Business logic for repository-related MCP tools
4
4
  */
5
5
  import type { GetFileInput, ListExamplesInput, GetLatestUpdatesInput, GetVersionInfoInput, CheckBreakingChangesInput, GetMigrationGuideInput, GetFileAtVersionInput, CompareSyntaxInput, GetLatestSyntaxInput, UpgradeCheckInput, FullRepoContextInput } from "./schemas.js";
6
+ export { validateContract, extractContractStructure } from "./validation.js";
6
7
  /**
7
8
  * Resolve repository name alias to owner/repo
8
9
  */
@@ -7,6 +7,8 @@ import { releaseTracker } from "../../pipeline/releases.js";
7
7
  import { logger, DEFAULT_REPOSITORIES, SelfCorrectionHints, } from "../../utils/index.js";
8
8
  import { REPO_ALIASES, EXAMPLES } from "./constants.js";
9
9
  import { EMBEDDED_DOCS } from "../../resources/content/docs-content.js";
10
+ // Re-export validation handlers from validation.ts
11
+ export { validateContract, extractContractStructure } from "./validation.js";
10
12
  /**
11
13
  * Resolve repository name alias to owner/repo
12
14
  */
@@ -2,8 +2,8 @@
2
2
  * Repository module exports
3
3
  * Barrel file for repository-related tools
4
4
  */
5
- export { GetFileInputSchema, ListExamplesInputSchema, GetLatestUpdatesInputSchema, GetVersionInfoInputSchema, CheckBreakingChangesInputSchema, GetMigrationGuideInputSchema, GetFileAtVersionInputSchema, CompareSyntaxInputSchema, GetLatestSyntaxInputSchema, type GetFileInput, type ListExamplesInput, type GetLatestUpdatesInput, type GetVersionInfoInput, type CheckBreakingChangesInput, type GetMigrationGuideInput, type GetFileAtVersionInput, type CompareSyntaxInput, type GetLatestSyntaxInput, } from "./schemas.js";
5
+ export { GetFileInputSchema, ListExamplesInputSchema, GetLatestUpdatesInputSchema, GetVersionInfoInputSchema, CheckBreakingChangesInputSchema, GetMigrationGuideInputSchema, GetFileAtVersionInputSchema, CompareSyntaxInputSchema, GetLatestSyntaxInputSchema, ValidateContractInputSchema, ExtractContractStructureInputSchema, type GetFileInput, type ListExamplesInput, type GetLatestUpdatesInput, type GetVersionInfoInput, type CheckBreakingChangesInput, type GetMigrationGuideInput, type GetFileAtVersionInput, type CompareSyntaxInput, type GetLatestSyntaxInput, type ValidateContractInput, type ExtractContractStructureInput, } from "./schemas.js";
6
6
  export { REPO_ALIASES, EXAMPLES, type ExampleDefinition } from "./constants.js";
7
- export { resolveRepo, getFile, listExamples, getLatestUpdates, getVersionInfo, checkBreakingChanges, getMigrationGuide, getFileAtVersion, compareSyntax, getLatestSyntax, } from "./handlers.js";
7
+ export { resolveRepo, getFile, listExamples, getLatestUpdates, getVersionInfo, checkBreakingChanges, getMigrationGuide, getFileAtVersion, compareSyntax, getLatestSyntax, validateContract, extractContractStructure, } from "./handlers.js";
8
8
  export { repositoryTools } from "./tools.js";
9
9
  //# sourceMappingURL=index.d.ts.map
@@ -3,11 +3,11 @@
3
3
  * Barrel file for repository-related tools
4
4
  */
5
5
  // Schemas and types
6
- export { GetFileInputSchema, ListExamplesInputSchema, GetLatestUpdatesInputSchema, GetVersionInfoInputSchema, CheckBreakingChangesInputSchema, GetMigrationGuideInputSchema, GetFileAtVersionInputSchema, CompareSyntaxInputSchema, GetLatestSyntaxInputSchema, } from "./schemas.js";
6
+ export { GetFileInputSchema, ListExamplesInputSchema, GetLatestUpdatesInputSchema, GetVersionInfoInputSchema, CheckBreakingChangesInputSchema, GetMigrationGuideInputSchema, GetFileAtVersionInputSchema, CompareSyntaxInputSchema, GetLatestSyntaxInputSchema, ValidateContractInputSchema, ExtractContractStructureInputSchema, } from "./schemas.js";
7
7
  // Constants
8
8
  export { REPO_ALIASES, EXAMPLES } from "./constants.js";
9
9
  // Handlers
10
- export { resolveRepo, getFile, listExamples, getLatestUpdates, getVersionInfo, checkBreakingChanges, getMigrationGuide, getFileAtVersion, compareSyntax, getLatestSyntax, } from "./handlers.js";
10
+ export { resolveRepo, getFile, listExamples, getLatestUpdates, getVersionInfo, checkBreakingChanges, getMigrationGuide, getFileAtVersion, compareSyntax, getLatestSyntax, validateContract, extractContractStructure, } from "./handlers.js";
11
11
  // Tools
12
12
  export { repositoryTools } from "./tools.js";
13
13
  //# sourceMappingURL=index.js.map
@@ -122,6 +122,43 @@ export declare const FullRepoContextInputSchema: z.ZodObject<{
122
122
  includeExamples?: boolean | undefined;
123
123
  includeSyntax?: boolean | undefined;
124
124
  }>;
125
+ export declare const ValidateContractInputSchema: z.ZodEffects<z.ZodObject<{
126
+ code: z.ZodOptional<z.ZodString>;
127
+ filePath: z.ZodOptional<z.ZodString>;
128
+ filename: z.ZodDefault<z.ZodOptional<z.ZodString>>;
129
+ }, "strip", z.ZodTypeAny, {
130
+ filename: string;
131
+ code?: string | undefined;
132
+ filePath?: string | undefined;
133
+ }, {
134
+ code?: string | undefined;
135
+ filePath?: string | undefined;
136
+ filename?: string | undefined;
137
+ }>, {
138
+ filename: string;
139
+ code?: string | undefined;
140
+ filePath?: string | undefined;
141
+ }, {
142
+ code?: string | undefined;
143
+ filePath?: string | undefined;
144
+ filename?: string | undefined;
145
+ }>;
146
+ export declare const ExtractContractStructureInputSchema: z.ZodEffects<z.ZodObject<{
147
+ code: z.ZodOptional<z.ZodString>;
148
+ filePath: z.ZodOptional<z.ZodString>;
149
+ }, "strip", z.ZodTypeAny, {
150
+ code?: string | undefined;
151
+ filePath?: string | undefined;
152
+ }, {
153
+ code?: string | undefined;
154
+ filePath?: string | undefined;
155
+ }>, {
156
+ code?: string | undefined;
157
+ filePath?: string | undefined;
158
+ }, {
159
+ code?: string | undefined;
160
+ filePath?: string | undefined;
161
+ }>;
125
162
  export type GetFileInput = z.infer<typeof GetFileInputSchema>;
126
163
  export type ListExamplesInput = z.infer<typeof ListExamplesInputSchema>;
127
164
  export type GetLatestUpdatesInput = z.infer<typeof GetLatestUpdatesInputSchema>;
@@ -133,4 +170,6 @@ export type CompareSyntaxInput = z.infer<typeof CompareSyntaxInputSchema>;
133
170
  export type GetLatestSyntaxInput = z.infer<typeof GetLatestSyntaxInputSchema>;
134
171
  export type UpgradeCheckInput = z.infer<typeof UpgradeCheckInputSchema>;
135
172
  export type FullRepoContextInput = z.infer<typeof FullRepoContextInputSchema>;
173
+ export type ValidateContractInput = z.infer<typeof ValidateContractInputSchema>;
174
+ export type ExtractContractStructureInput = z.infer<typeof ExtractContractStructureInputSchema>;
136
175
  //# sourceMappingURL=schemas.d.ts.map
@@ -88,4 +88,39 @@ export const FullRepoContextInputSchema = z.object({
88
88
  .describe("Include example code snippets"),
89
89
  includeSyntax: z.boolean().default(true).describe("Include syntax reference"),
90
90
  });
91
+ export const ValidateContractInputSchema = z
92
+ .object({
93
+ code: z
94
+ .string()
95
+ .optional()
96
+ .describe("The Compact contract source code to validate (provide this OR filePath)"),
97
+ filePath: z
98
+ .string()
99
+ .optional()
100
+ .describe("Path to a .compact file to validate (alternative to providing code directly)"),
101
+ filename: z
102
+ .string()
103
+ .optional()
104
+ .default("contract.compact")
105
+ .describe("Optional filename for the contract (default: contract.compact)"),
106
+ })
107
+ .refine((data) => (data.code !== undefined && data.code.trim() !== "") ||
108
+ data.filePath !== undefined, {
109
+ message: "Either 'code' or 'filePath' must be provided",
110
+ });
111
+ export const ExtractContractStructureInputSchema = z
112
+ .object({
113
+ code: z
114
+ .string()
115
+ .optional()
116
+ .describe("The Compact contract source code to analyze (provide this OR filePath)"),
117
+ filePath: z
118
+ .string()
119
+ .optional()
120
+ .describe("Path to a .compact file to analyze (alternative to providing code directly)"),
121
+ })
122
+ .refine((data) => (data.code !== undefined && data.code.trim() !== "") ||
123
+ data.filePath !== undefined, {
124
+ message: "Either 'code' or 'filePath' must be provided",
125
+ });
91
126
  //# sourceMappingURL=schemas.js.map
@@ -2,7 +2,7 @@
2
2
  * Repository tool definitions
3
3
  * MCP tool registration for repository-related operations
4
4
  */
5
- import { getFile, listExamples, getLatestUpdates, getVersionInfo, checkBreakingChanges, getMigrationGuide, getFileAtVersion, compareSyntax, getLatestSyntax, upgradeCheck, getFullRepoContext, } from "./handlers.js";
5
+ import { getFile, listExamples, getLatestUpdates, getVersionInfo, checkBreakingChanges, getMigrationGuide, getFileAtVersion, compareSyntax, getLatestSyntax, upgradeCheck, getFullRepoContext, validateContract, extractContractStructure, } from "./handlers.js";
6
6
  // Tool definitions for MCP
7
7
  export const repositoryTools = [
8
8
  {
@@ -353,5 +353,194 @@ export const repositoryTools = [
353
353
  },
354
354
  handler: getFullRepoContext,
355
355
  },
356
+ // ============================================================================
357
+ // VALIDATION TOOLS - Pre-compilation contract validation
358
+ // ============================================================================
359
+ {
360
+ name: "midnight-validate-contract",
361
+ description: "🔍 VALIDATION TOOL: Compile and validate a Compact contract BEFORE deployment. This runs the actual Compact compiler to check for syntax errors, type errors, and other issues. Use this after writing or modifying contract code to catch errors early. Requires the Compact CLI to be installed locally. Accepts either source code directly OR a file path to a .compact file.",
362
+ inputSchema: {
363
+ type: "object",
364
+ properties: {
365
+ code: {
366
+ type: "string",
367
+ description: "The Compact contract source code to validate (provide this OR filePath)",
368
+ },
369
+ filePath: {
370
+ type: "string",
371
+ description: "Path to a .compact file to validate (alternative to providing code directly)",
372
+ },
373
+ filename: {
374
+ type: "string",
375
+ description: "Optional filename for the contract when using code (default: contract.compact)",
376
+ },
377
+ },
378
+ required: [],
379
+ },
380
+ outputSchema: {
381
+ type: "object",
382
+ properties: {
383
+ success: {
384
+ type: "boolean",
385
+ description: "Whether the contract compiled successfully",
386
+ },
387
+ errorType: {
388
+ type: "string",
389
+ description: "Category of error: user_error, environment_error, system_error, compilation_error",
390
+ },
391
+ compilerInstalled: {
392
+ type: "boolean",
393
+ description: "Whether the Compact compiler is available",
394
+ },
395
+ compilerVersion: {
396
+ type: "string",
397
+ description: "Version of the Compact compiler",
398
+ },
399
+ message: { type: "string", description: "Summary message" },
400
+ errors: {
401
+ type: "array",
402
+ description: "List of compilation errors with line numbers",
403
+ items: {
404
+ type: "object",
405
+ properties: {
406
+ line: { type: "number" },
407
+ column: { type: "number" },
408
+ message: { type: "string" },
409
+ severity: { type: "string" },
410
+ context: { type: "string" },
411
+ },
412
+ },
413
+ },
414
+ userAction: {
415
+ type: "object",
416
+ description: "What the user needs to do to fix the problem",
417
+ properties: {
418
+ problem: { type: "string" },
419
+ solution: { type: "string" },
420
+ isUserFault: { type: "boolean" },
421
+ },
422
+ },
423
+ suggestions: {
424
+ type: "array",
425
+ description: "Suggestions for fixing errors",
426
+ items: { type: "string" },
427
+ },
428
+ commonFixes: {
429
+ type: "array",
430
+ description: "Common fix patterns",
431
+ items: {
432
+ type: "object",
433
+ properties: {
434
+ pattern: { type: "string" },
435
+ fix: { type: "string" },
436
+ },
437
+ },
438
+ },
439
+ installation: {
440
+ type: "object",
441
+ description: "Installation instructions if compiler not found",
442
+ },
443
+ },
444
+ },
445
+ annotations: {
446
+ readOnlyHint: false, // Creates temp files
447
+ idempotentHint: true, // Same input = same output
448
+ openWorldHint: true,
449
+ longRunningHint: true, // Compilation can take time
450
+ title: "🔍 Validate Contract",
451
+ category: "validation",
452
+ },
453
+ handler: validateContract,
454
+ },
455
+ {
456
+ name: "midnight-extract-contract-structure",
457
+ description: "📋 ANALYSIS TOOL: Extract the structure of a Compact contract - circuits, witnesses, ledger items, types, structs, and enums. Use this to understand what a contract does without reading all the code. Returns exported and internal definitions with line numbers. Accepts either source code directly OR a file path.",
458
+ inputSchema: {
459
+ type: "object",
460
+ properties: {
461
+ code: {
462
+ type: "string",
463
+ description: "The Compact contract source code to analyze (provide this OR filePath)",
464
+ },
465
+ filePath: {
466
+ type: "string",
467
+ description: "Path to a .compact file to analyze (alternative to providing code directly)",
468
+ },
469
+ },
470
+ required: [],
471
+ },
472
+ outputSchema: {
473
+ type: "object",
474
+ properties: {
475
+ success: { type: "boolean" },
476
+ filename: { type: "string" },
477
+ languageVersion: { type: "string" },
478
+ imports: { type: "array", items: { type: "string" } },
479
+ structure: {
480
+ type: "object",
481
+ properties: {
482
+ circuits: {
483
+ type: "array",
484
+ items: {
485
+ type: "object",
486
+ properties: {
487
+ name: { type: "string" },
488
+ params: { type: "array", items: { type: "string" } },
489
+ returnType: { type: "string" },
490
+ isExport: { type: "boolean" },
491
+ line: { type: "number" },
492
+ },
493
+ },
494
+ },
495
+ witnesses: {
496
+ type: "array",
497
+ items: {
498
+ type: "object",
499
+ properties: {
500
+ name: { type: "string" },
501
+ type: { type: "string" },
502
+ isExport: { type: "boolean" },
503
+ line: { type: "number" },
504
+ },
505
+ },
506
+ },
507
+ ledgerItems: {
508
+ type: "array",
509
+ items: {
510
+ type: "object",
511
+ properties: {
512
+ name: { type: "string" },
513
+ type: { type: "string" },
514
+ isExport: { type: "boolean" },
515
+ line: { type: "number" },
516
+ },
517
+ },
518
+ },
519
+ types: { type: "array" },
520
+ structs: { type: "array" },
521
+ enums: { type: "array" },
522
+ },
523
+ },
524
+ exports: {
525
+ type: "object",
526
+ description: "Names of all exported items",
527
+ },
528
+ stats: {
529
+ type: "object",
530
+ description: "Counts of each type of definition",
531
+ },
532
+ summary: { type: "string" },
533
+ message: { type: "string" },
534
+ },
535
+ },
536
+ annotations: {
537
+ readOnlyHint: true,
538
+ idempotentHint: true,
539
+ openWorldHint: false,
540
+ title: "📋 Extract Contract Structure",
541
+ category: "validation",
542
+ },
543
+ handler: extractContractStructure,
544
+ },
356
545
  ];
357
546
  //# sourceMappingURL=tools.js.map