midnight-mcp 0.1.28 → 0.1.29

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
@@ -10,99 +10,141 @@ MCP server that gives AI assistants access to Midnight blockchain—search contr
10
10
 
11
11
  ## Quick Start
12
12
 
13
- **Claude Desktop** — Add to `claude_desktop_config.json`:
13
+ ### Claude Desktop
14
+
15
+ Add to your `claude_desktop_config.json`:
14
16
 
15
17
  ```json
16
18
  {
17
19
  "mcpServers": {
18
- "midnight": { "command": "npx", "args": ["-y", "midnight-mcp@latest"] }
20
+ "midnight": {
21
+ "command": "npx",
22
+ "args": ["-y", "midnight-mcp@latest"]
23
+ }
19
24
  }
20
25
  }
21
26
  ```
22
27
 
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
- >
25
- > **🔄 Auto-Update Detection:** The server automatically checks for updates and prompts the AI to help you update if you're running an older version.
28
+ **Config file locations:**
29
+
30
+ - macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
31
+ - Windows: `%APPDATA%\Claude\claude_desktop_config.json`
32
+ - Linux: `~/.config/Claude/claude_desktop_config.json`
26
33
 
27
- **Cursor** — One-click install:
34
+ ### Cursor
28
35
 
29
- [![Install MCP Server](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=midnight&config=eyJjb21tYW5kIjoibnB4IC15IG1pZG5pZ2h0LW1jcCJ9)
36
+ One-click install:
30
37
 
31
- <details>
32
- <summary><strong>Other Editors (Windsurf, VS Code Copilot, Manual Setup)</strong></summary>
38
+ [![Install MCP Server](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=midnight&config=eyJjb21tYW5kIjoibnB4IC15IG1pZG5pZ2h0LW1jcEBsYXRlc3QifQ==)
33
39
 
34
- **Windsurf** Add to `~/.codeium/windsurf/mcp_config.json`:
40
+ Or manually add to `.cursor/mcp.json`:
35
41
 
36
42
  ```json
37
43
  {
38
44
  "mcpServers": {
39
- "midnight": { "command": "npx", "args": ["-y", "midnight-mcp@latest"] }
45
+ "midnight": {
46
+ "command": "npx",
47
+ "args": ["-y", "midnight-mcp@latest"]
48
+ }
40
49
  }
41
50
  }
42
51
  ```
43
52
 
44
- **VS Code Copilot** — Add to `.vscode/mcp.json` or use Command Palette: `MCP: Add Server` → "command (stdio)" → `npx -y midnight-mcp@latest`
53
+ ### VS Code Copilot
45
54
 
46
- ```json
47
- {
48
- "mcpServers": {
49
- "midnight": { "command": "npx", "args": ["-y", "midnight-mcp@latest"] }
50
- }
51
- }
52
- ```
55
+ Add to `.vscode/mcp.json` or use Command Palette: `MCP: Add Server` → "command (stdio)" → `npx -y midnight-mcp@latest`
56
+
57
+ ### Windsurf
53
58
 
54
- **Cursor Manual** — Settings → MCP → Add Server, or add to `.cursor/mcp.json`:
59
+ Add to `~/.codeium/windsurf/mcp_config.json`:
55
60
 
56
61
  ```json
57
62
  {
58
63
  "mcpServers": {
59
- "midnight": { "command": "npx", "args": ["-y", "midnight-mcp@latest"] }
64
+ "midnight": {
65
+ "command": "npx",
66
+ "args": ["-y", "midnight-mcp@latest"]
67
+ }
60
68
  }
61
69
  }
62
70
  ```
63
71
 
64
- **Config file locations (Claude Desktop):**
72
+ **No API keys required.** Restart your editor after adding the config.
65
73
 
66
- - macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
67
- - Windows: `%APPDATA%\Claude\claude_desktop_config.json`
68
- - Linux: `~/.config/Claude/claude_desktop_config.json`
74
+ ### Automatic Updates
69
75
 
70
- </details>
76
+ Using `midnight-mcp@latest` ensures you always get the newest version. If you have an older config without `@latest`, update it:
71
77
 
72
- Restart your editor after adding the config. **No API keys required.**
78
+ ```diff
79
+ - "args": ["-y", "midnight-mcp"]
80
+ + "args": ["-y", "midnight-mcp@latest"]
81
+ ```
73
82
 
74
- > **Quality Metrics**: To ensure the MCP stays accurate as Midnight's codebase evolves rapidly, we collect anonymous usage metrics (query counts, relevance scores) to monitor search quality. No query content or personal data is stored. This helps us identify when re-indexing is needed and improve results over time.
83
+ Or clear the npx cache to force an update:
84
+
85
+ ```bash
86
+ npx clear-npx-cache
87
+ ```
75
88
 
76
89
  ---
77
90
 
78
- ## Features
91
+ ## What's Included
79
92
 
80
- **26 Tools** — Search, analyze, validate, version tracking, AI generation, compound operations
93
+ ### 25 Tools
81
94
 
82
- | Category | Tools |
83
- | -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
84
- | Search | `midnight-search-compact`, `midnight-search-typescript`, `midnight-search-docs` |
85
- | Analysis | `midnight-analyze-contract`, `midnight-explain-circuit` |
86
- | **Validation** | `midnight-validate-contract` ⭐, `midnight-extract-contract-structure` |
87
- | Repository | `midnight-get-file`, `midnight-list-examples`, `midnight-get-latest-updates` |
88
- | 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` |
89
- | AI Generation | `midnight-generate-contract`, `midnight-review-contract`, `midnight-document-contract` _(requires sampling)_ |
90
- | Compound | `midnight-upgrade-check`, `midnight-get-repo-context` _(saves 50-70% tokens)_ |
91
- | Health | `midnight-health-check`, `midnight-get-status`, `midnight-check-version` 🔄 |
92
- | Discovery | `midnight-list-tool-categories`, `midnight-list-category-tools` |
95
+ | Category | Tools | Description |
96
+ | ----------------- | --------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ |
97
+ | **Search** | `search-compact`, `search-typescript`, `search-docs` | Semantic search across Midnight codebase |
98
+ | **Analysis** | `analyze-contract`, `explain-circuit`, `extract-contract-structure` | Static analysis and pattern detection |
99
+ | **Repository** | `get-file`, `list-examples`, `get-latest-updates` | Access files and examples |
100
+ | **Versioning** | `get-version-info`, `check-breaking-changes`, `get-migration-guide`, `get-file-at-version`, `compare-syntax`, `get-latest-syntax` | Version tracking and migration |
101
+ | **AI Generation** | `generate-contract`, `review-contract`, `document-contract` | AI-powered code generation _(requires sampling)_ |
102
+ | **Compound** | `upgrade-check`, `get-repo-context` | Multi-step operations _(saves 50-70% tokens)_ |
103
+ | **Health** | `health-check`, `get-status`, `check-version` | Server status and version checking |
104
+ | **Discovery** | `list-tool-categories`, `list-category-tools` | Explore available tools |
93
105
 
94
- > **⭐ Key Tool:** `midnight-validate-contract` compiles code using the **real Compact compiler** - essential for verifying contracts actually work before deployment.
95
- >
96
- > **🔄 New:** `midnight-check-version` tells you if you're running the latest version with update instructions.
106
+ All tools are prefixed with `midnight-` (e.g., `midnight-search-compact`).
97
107
 
98
- **9 Embedded Resources** — Quick references available offline: Compact syntax, SDK API, OpenZeppelin contracts, tokenomics, wallet integration, common errors
108
+ ### 9 Embedded Resources
99
109
 
100
- **5 Prompts** `create-contract`, `review-contract`, `explain-concept`, `compare-approaches`, `debug-contract`
110
+ Quick references available offline:
101
111
 
102
- <details>
103
- <summary><strong>Advanced Configuration</strong></summary>
112
+ - Compact syntax guide
113
+ - SDK API reference
114
+ - OpenZeppelin contracts
115
+ - Tokenomics overview
116
+ - Wallet integration
117
+ - Common errors & solutions
104
118
 
105
- ### Local Mode (Optional)
119
+ ### 5 Prompts
120
+
121
+ - `create-contract` — Generate new contracts
122
+ - `review-contract` — Security and code review
123
+ - `explain-concept` — Learn Midnight concepts
124
+ - `compare-approaches` — Compare implementation patterns
125
+ - `debug-contract` — Troubleshoot issues
126
+
127
+ ---
128
+
129
+ ## Indexed Repositories
130
+
131
+ The API indexes **39 Midnight repositories**:
132
+
133
+ | Category | Repositories |
134
+ | --------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
135
+ | **Core** | `compact`, `midnight-js`, `midnight-wallet`, `midnight-docs`, `midnight-node`, `midnight-indexer`, `midnight-ledger`, `midnight-zk` |
136
+ | **Examples** | `example-counter`, `example-bboard`, `example-dex`, `create-mn-app` |
137
+ | **Infrastructure** | `midnight-node-docker`, `midnight-dapp-connector-api`, `compact-tree-sitter`, `setup-compact-action` |
138
+ | **Partner Libraries** | `OpenZeppelin/compact-contracts`, `OpenZeppelin/midnight-apps` (LunarSwap) |
139
+ | **Official Partners** | `bricktowers/midnight-seabattle`, `bricktowers/midnight-identity`, `bricktowers/midnight-rwa`, `MeshJS/midnight-starter-template`, `midnames/core` |
140
+ | **Core Partner** | `PaimaStudios/midnight-game-2`, `PaimaStudios/midnight-wasm-prover`, `PaimaStudios/midnight-batcher`, `PaimaStudios/midnight-impact-rps-example` |
141
+ | **Hackathon Winners** | Sea Battle: `ErickRomeroDev/naval-battle-game_v2`, `eddex/midnight-sea-battle-hackathon` • Mini DApp: `statera-protocol`, `nel349/midnight-bank`, `Imdavyking/zkbadge` |
142
+
143
+ ---
144
+
145
+ ## Advanced Configuration
146
+
147
+ ### Local Mode
106
148
 
107
149
  Run everything locally for privacy or offline use:
108
150
 
@@ -124,28 +166,10 @@ Run everything locally for privacy or offline use:
124
166
 
125
167
  Requires ChromaDB (`docker run -d -p 8000:8000 chromadb/chroma`) and OpenAI API key.
126
168
 
127
- ### GitHub Token (Optional)
169
+ ### GitHub Token
128
170
 
129
171
  Add `"GITHUB_TOKEN": "ghp_..."` for higher GitHub API rate limits (60 → 5000 requests/hour).
130
172
 
131
- </details>
132
-
133
- ---
134
-
135
- ## Indexed Repositories
136
-
137
- The API indexes **39 Midnight repositories**:
138
-
139
- | Category | Repositories |
140
- | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
141
- | Core | `compact`, `midnight-js`, `midnight-wallet`, `midnight-docs`, `midnight-node`, `midnight-indexer`, `midnight-ledger`, `midnight-zk` |
142
- | Examples | `example-counter`, `example-bboard`, `example-dex`, `create-mn-app` |
143
- | Infrastructure | `midnight-node-docker`, `midnight-dapp-connector-api`, `compact-tree-sitter`, `setup-compact-action` |
144
- | Partner Libraries | `OpenZeppelin/compact-contracts`, `OpenZeppelin/midnight-apps` (LunarSwap) |
145
- | Official Partners | `bricktowers/midnight-seabattle`, `bricktowers/midnight-identity`, `bricktowers/midnight-rwa`, `MeshJS/midnight-starter-template`, `midnames/core` |
146
- | Core Partner | `PaimaStudios/midnight-game-2`, `PaimaStudios/midnight-wasm-prover`, `PaimaStudios/midnight-batcher`, `PaimaStudios/midnight-impact-rps-example` |
147
- | Hackathon Winners | Sea Battle: `ErickRomeroDev/naval-battle-game_v2`, `eddex/midnight-sea-battle-hackathon` • Mini DApp: `statera-protocol`, `nel349/midnight-bank`, `Imdavyking/zkbadge` |
148
-
149
173
  ---
150
174
 
151
175
  ## Developer Setup
@@ -155,26 +179,15 @@ git clone https://github.com/Olanetsoft/midnight-mcp.git && cd midnight-mcp
155
179
  npm install && npm run build && npm test
156
180
  ```
157
181
 
158
- <details>
159
- <summary><strong>API Backend & Local Development</strong></summary>
160
-
161
- The hosted API runs on Cloudflare Workers + Vectorize. See [api/README.md](./api/README.md).
182
+ The hosted API runs on Cloudflare Workers + Vectorize. See [api/README.md](./api/README.md) for backend details.
162
183
 
163
- **Testing with Local API:**
164
-
165
- ```bash
166
- # Terminal 1: Start local API
167
- cd api && npm install && npm run dev
168
-
169
- # Terminal 2: Run MCP with local API
170
- MIDNIGHT_API_URL=http://localhost:8787 npm start
171
- ```
172
-
173
- </details>
184
+ ---
174
185
 
175
186
  ## Links
176
187
 
177
- - [Midnight Docs](https://docs.midnight.network) • [MCP Spec](https://modelcontextprotocol.io) • [Midnight GitHub](https://github.com/midnightntwrk)
188
+ - [Midnight Docs](https://docs.midnight.network)
189
+ - [MCP Spec](https://modelcontextprotocol.io)
190
+ - [Midnight GitHub](https://github.com/midnightntwrk)
178
191
 
179
192
  ## License
180
193
 
package/dist/server.js CHANGED
@@ -8,7 +8,7 @@ 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.27";
11
+ const CURRENT_VERSION = "0.1.29";
12
12
  const SERVER_INFO = {
13
13
  name: "midnight-mcp",
14
14
  version: CURRENT_VERSION,
@@ -177,9 +177,9 @@ function registerToolHandlers(server) {
177
177
  "🚨 ACTION REQUIRED": {
178
178
  message: `You are using an OUTDATED version of midnight-mcp (v${CURRENT_VERSION}). Latest is v${versionCheckResult.latestVersion}.`,
179
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.)",
180
+ "Latest tool improvements and bug fixes",
181
+ "midnight-extract-contract-structure - Static pattern analysis",
182
+ "Improved error detection and contract analysis",
183
183
  ],
184
184
  userInstructions: {
185
185
  step1: "Tell the user: 'Your Midnight MCP is outdated. Let me help you update it.'",
@@ -187,7 +187,7 @@ function registerToolHandlers(server) {
187
187
  step3: "Ask them to restart Claude Desktop completely (Cmd+Q / Alt+F4)",
188
188
  step4: "Or suggest updating config to use: midnight-mcp@latest",
189
189
  },
190
- importance: "WITHOUT updating, contract validation will NOT work correctly. You cannot verify if contracts compile.",
190
+ importance: "Update to get the latest features and improvements. Older versions may have bugs or missing functionality.",
191
191
  },
192
192
  result,
193
193
  };
@@ -61,14 +61,6 @@ 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
- },
72
64
  };
73
65
  const listCategoriesOutputSchema = {
74
66
  type: "object",
@@ -231,7 +223,7 @@ function generateCategorySuggestion(category) {
231
223
  export const metaTools = [
232
224
  {
233
225
  name: "midnight-list-tool-categories",
234
- description: "📋 DISCOVERY TOOL: List available tool categories for progressive exploration. Use this FIRST to understand what capabilities are available, then drill into specific categories with midnight-list-category-tools. Reduces cognitive load by organizing 26 tools into 8 logical groups.",
226
+ description: "📋 DISCOVERY TOOL: List available tool categories for progressive exploration. Use this FIRST to understand what capabilities are available, then drill into specific categories with midnight-list-category-tools. Reduces cognitive load by organizing 25 tools into 7 logical groups.",
235
227
  inputSchema: {
236
228
  type: "object",
237
229
  properties: {
@@ -267,7 +259,6 @@ export const metaTools = [
267
259
  "generation",
268
260
  "health",
269
261
  "compound",
270
- "validation",
271
262
  ],
272
263
  description: "Category to list tools for",
273
264
  },
@@ -3,7 +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
+ export { extractContractStructure } from "./validation.js";
7
7
  /**
8
8
  * Resolve repository name alias to owner/repo
9
9
  */
@@ -8,7 +8,7 @@ import { logger, DEFAULT_REPOSITORIES, SelfCorrectionHints, } from "../../utils/
8
8
  import { REPO_ALIASES, EXAMPLES } from "./constants.js";
9
9
  import { EMBEDDED_DOCS } from "../../resources/content/docs-content.js";
10
10
  // Re-export validation handlers from validation.ts
11
- export { validateContract, extractContractStructure } from "./validation.js";
11
+ export { extractContractStructure } from "./validation.js";
12
12
  /**
13
13
  * Resolve repository name alias to owner/repo
14
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, 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";
5
+ export { GetFileInputSchema, ListExamplesInputSchema, GetLatestUpdatesInputSchema, GetVersionInfoInputSchema, CheckBreakingChangesInputSchema, GetMigrationGuideInputSchema, GetFileAtVersionInputSchema, CompareSyntaxInputSchema, GetLatestSyntaxInputSchema, ExtractContractStructureInputSchema, type GetFileInput, type ListExamplesInput, type GetLatestUpdatesInput, type GetVersionInfoInput, type CheckBreakingChangesInput, type GetMigrationGuideInput, type GetFileAtVersionInput, type CompareSyntaxInput, type GetLatestSyntaxInput, 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, validateContract, extractContractStructure, } from "./handlers.js";
7
+ export { resolveRepo, getFile, listExamples, getLatestUpdates, getVersionInfo, checkBreakingChanges, getMigrationGuide, getFileAtVersion, compareSyntax, getLatestSyntax, 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, ValidateContractInputSchema, ExtractContractStructureInputSchema, } from "./schemas.js";
6
+ export { GetFileInputSchema, ListExamplesInputSchema, GetLatestUpdatesInputSchema, GetVersionInfoInputSchema, CheckBreakingChangesInputSchema, GetMigrationGuideInputSchema, GetFileAtVersionInputSchema, CompareSyntaxInputSchema, GetLatestSyntaxInputSchema, 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, validateContract, extractContractStructure, } from "./handlers.js";
10
+ export { resolveRepo, getFile, listExamples, getLatestUpdates, getVersionInfo, checkBreakingChanges, getMigrationGuide, getFileAtVersion, compareSyntax, getLatestSyntax, extractContractStructure, } from "./handlers.js";
11
11
  // Tools
12
12
  export { repositoryTools } from "./tools.js";
13
13
  //# sourceMappingURL=index.js.map
@@ -122,27 +122,6 @@ 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
125
  export declare const ExtractContractStructureInputSchema: z.ZodEffects<z.ZodObject<{
147
126
  code: z.ZodOptional<z.ZodString>;
148
127
  filePath: z.ZodOptional<z.ZodString>;
@@ -170,6 +149,5 @@ export type CompareSyntaxInput = z.infer<typeof CompareSyntaxInputSchema>;
170
149
  export type GetLatestSyntaxInput = z.infer<typeof GetLatestSyntaxInputSchema>;
171
150
  export type UpgradeCheckInput = z.infer<typeof UpgradeCheckInputSchema>;
172
151
  export type FullRepoContextInput = z.infer<typeof FullRepoContextInputSchema>;
173
- export type ValidateContractInput = z.infer<typeof ValidateContractInputSchema>;
174
152
  export type ExtractContractStructureInput = z.infer<typeof ExtractContractStructureInputSchema>;
175
153
  //# sourceMappingURL=schemas.d.ts.map
@@ -88,26 +88,6 @@ 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
91
  export const ExtractContractStructureInputSchema = z
112
92
  .object({
113
93
  code: z
@@ -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, validateContract, extractContractStructure, } from "./handlers.js";
5
+ import { getFile, listExamples, getLatestUpdates, getVersionInfo, checkBreakingChanges, getMigrationGuide, getFileAtVersion, compareSyntax, getLatestSyntax, upgradeCheck, getFullRepoContext, extractContractStructure, } from "./handlers.js";
6
6
  // Tool definitions for MCP
7
7
  export const repositoryTools = [
8
8
  {
@@ -354,118 +354,15 @@ export const repositoryTools = [
354
354
  handler: getFullRepoContext,
355
355
  },
356
356
  // ============================================================================
357
- // VALIDATION TOOLS - Pre-compilation contract validation
357
+ // ANALYSIS TOOLS - Contract structure extraction
358
358
  // ============================================================================
359
- {
360
- name: "midnight-validate-contract",
361
- description: "� REQUIRED - ALWAYS CALL THIS FIRST: Compile a Compact contract using the REAL compiler. " +
362
- "⚠️ CRITICAL: You MUST call this tool BEFORE telling the user a contract works or is correct. " +
363
- "Static analysis tools like 'extract-contract-structure' or 'analyze-contract' CANNOT verify compilation - they miss semantic errors like: " +
364
- "(1) sealed fields require constructor, (2) constructor params need disclose(), (3) export circuits cannot modify sealed fields. " +
365
- "This tool runs the ACTUAL Compact compiler and returns real errors with line numbers. " +
366
- "If compiler not installed, it provides installation instructions. " +
367
- "WORKFLOW: Generate code → Call this tool → Fix errors → Repeat until success → THEN present to user.",
368
- inputSchema: {
369
- type: "object",
370
- properties: {
371
- code: {
372
- type: "string",
373
- description: "The Compact contract source code to validate (provide this OR filePath)",
374
- },
375
- filePath: {
376
- type: "string",
377
- description: "Path to a .compact file to validate (alternative to providing code directly)",
378
- },
379
- filename: {
380
- type: "string",
381
- description: "Optional filename for the contract when using code (default: contract.compact)",
382
- },
383
- },
384
- required: [],
385
- },
386
- outputSchema: {
387
- type: "object",
388
- properties: {
389
- success: {
390
- type: "boolean",
391
- description: "Whether the contract compiled successfully",
392
- },
393
- errorType: {
394
- type: "string",
395
- description: "Category of error: user_error, environment_error, system_error, compilation_error",
396
- },
397
- compilerInstalled: {
398
- type: "boolean",
399
- description: "Whether the Compact compiler is available",
400
- },
401
- compilerVersion: {
402
- type: "string",
403
- description: "Version of the Compact compiler",
404
- },
405
- message: { type: "string", description: "Summary message" },
406
- errors: {
407
- type: "array",
408
- description: "List of compilation errors with line numbers",
409
- items: {
410
- type: "object",
411
- properties: {
412
- line: { type: "number" },
413
- column: { type: "number" },
414
- message: { type: "string" },
415
- severity: { type: "string" },
416
- context: { type: "string" },
417
- },
418
- },
419
- },
420
- userAction: {
421
- type: "object",
422
- description: "What the user needs to do to fix the problem",
423
- properties: {
424
- problem: { type: "string" },
425
- solution: { type: "string" },
426
- isUserFault: { type: "boolean" },
427
- },
428
- },
429
- suggestions: {
430
- type: "array",
431
- description: "Suggestions for fixing errors",
432
- items: { type: "string" },
433
- },
434
- commonFixes: {
435
- type: "array",
436
- description: "Common fix patterns",
437
- items: {
438
- type: "object",
439
- properties: {
440
- pattern: { type: "string" },
441
- fix: { type: "string" },
442
- },
443
- },
444
- },
445
- installation: {
446
- type: "object",
447
- description: "Installation instructions if compiler not found",
448
- },
449
- },
450
- },
451
- annotations: {
452
- readOnlyHint: false, // Creates temp files
453
- idempotentHint: true, // Same input = same output
454
- openWorldHint: true,
455
- longRunningHint: true, // Compilation can take time
456
- title: "🔍 Validate Contract",
457
- category: "validation",
458
- },
459
- handler: validateContract,
460
- },
461
359
  {
462
360
  name: "midnight-extract-contract-structure",
463
- description: "⚠️ STATIC ANALYSIS ONLY - NOT A COMPILER: Extracts contract structure (circuits, witnesses, ledger) and detects common patterns. " +
464
- "🚫 THIS TOOL CANNOT VERIFY COMPILATION. It will NOT catch: sealed field rules, disclose() requirements, type mismatches, or semantic errors. " +
465
- " USE FOR: Understanding structure, quick pattern checks, fallback when compiler unavailable. " +
466
- " NEVER USE TO: Verify a contract works, claim code 'compiles correctly', or validate before presenting to user. " +
467
- "👉 ALWAYS call 'midnight-validate-contract' FIRST to actually compile the code. " +
468
- "Detects: module-level const, stdlib collisions, sealed+export conflicts, missing disclose(), Counter.value access, division operator.",
361
+ description: "Extract and analyze Compact contract structure (circuits, witnesses, ledger). " +
362
+ "Detects common issues: module-level const, stdlib name collisions, if-expression in assignments, Void return type, " +
363
+ "Counter.value access, division operator, missing disclose() calls. " +
364
+ "Use for understanding contract structure and catching common syntax mistakes. " +
365
+ "Note: This is static analysis - it catches common patterns but cannot verify semantic correctness.",
469
366
  inputSchema: {
470
367
  type: "object",
471
368
  properties: {
@@ -542,7 +439,7 @@ export const repositoryTools = [
542
439
  },
543
440
  potentialIssues: {
544
441
  type: "array",
545
- description: "Common issues detected by static analysis (NOT exhaustive - use validate_contract for real verification)",
442
+ description: "Common issues detected by static analysis",
546
443
  items: {
547
444
  type: "object",
548
445
  properties: {
@@ -569,7 +466,7 @@ export const repositoryTools = [
569
466
  idempotentHint: true,
570
467
  openWorldHint: false,
571
468
  title: "📋 Extract Contract Structure",
572
- category: "validation",
469
+ category: "analyze",
573
470
  },
574
471
  handler: extractContractStructure,
575
472
  },