midnight-mcp 0.1.27 → 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 +97 -84
- package/dist/server.js +5 -5
- package/dist/tools/meta.js +2 -10
- package/dist/tools/repository/handlers.d.ts +1 -1
- package/dist/tools/repository/handlers.js +1 -1
- package/dist/tools/repository/index.d.ts +2 -2
- package/dist/tools/repository/index.js +2 -2
- package/dist/tools/repository/schemas.d.ts +0 -22
- package/dist/tools/repository/schemas.js +0 -20
- package/dist/tools/repository/tools.js +9 -112
- package/dist/tools/repository/validation.d.ts +2 -533
- package/dist/tools/repository/validation.js +3 -741
- package/dist/types/mcp.d.ts +1 -1
- package/package.json +1 -1
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
|
-
|
|
13
|
+
### Claude Desktop
|
|
14
|
+
|
|
15
|
+
Add to your `claude_desktop_config.json`:
|
|
14
16
|
|
|
15
17
|
```json
|
|
16
18
|
{
|
|
17
19
|
"mcpServers": {
|
|
18
|
-
"midnight": {
|
|
20
|
+
"midnight": {
|
|
21
|
+
"command": "npx",
|
|
22
|
+
"args": ["-y", "midnight-mcp@latest"]
|
|
23
|
+
}
|
|
19
24
|
}
|
|
20
25
|
}
|
|
21
26
|
```
|
|
22
27
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
34
|
+
### Cursor
|
|
28
35
|
|
|
29
|
-
|
|
36
|
+
One-click install:
|
|
30
37
|
|
|
31
|
-
|
|
32
|
-
<summary><strong>Other Editors (Windsurf, VS Code Copilot, Manual Setup)</strong></summary>
|
|
38
|
+
[](https://cursor.com/en-US/install-mcp?name=midnight&config=eyJjb21tYW5kIjoibnB4IC15IG1pZG5pZ2h0LW1jcEBsYXRlc3QifQ==)
|
|
33
39
|
|
|
34
|
-
|
|
40
|
+
Or manually add to `.cursor/mcp.json`:
|
|
35
41
|
|
|
36
42
|
```json
|
|
37
43
|
{
|
|
38
44
|
"mcpServers": {
|
|
39
|
-
"midnight": {
|
|
45
|
+
"midnight": {
|
|
46
|
+
"command": "npx",
|
|
47
|
+
"args": ["-y", "midnight-mcp@latest"]
|
|
48
|
+
}
|
|
40
49
|
}
|
|
41
50
|
}
|
|
42
51
|
```
|
|
43
52
|
|
|
44
|
-
|
|
53
|
+
### VS Code Copilot
|
|
45
54
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
59
|
+
Add to `~/.codeium/windsurf/mcp_config.json`:
|
|
55
60
|
|
|
56
61
|
```json
|
|
57
62
|
{
|
|
58
63
|
"mcpServers": {
|
|
59
|
-
"midnight": {
|
|
64
|
+
"midnight": {
|
|
65
|
+
"command": "npx",
|
|
66
|
+
"args": ["-y", "midnight-mcp@latest"]
|
|
67
|
+
}
|
|
60
68
|
}
|
|
61
69
|
}
|
|
62
70
|
```
|
|
63
71
|
|
|
64
|
-
**
|
|
72
|
+
**No API keys required.** Restart your editor after adding the config.
|
|
65
73
|
|
|
66
|
-
|
|
67
|
-
- Windows: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
68
|
-
- Linux: `~/.config/Claude/claude_desktop_config.json`
|
|
74
|
+
### Automatic Updates
|
|
69
75
|
|
|
70
|
-
|
|
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
|
-
|
|
78
|
+
```diff
|
|
79
|
+
- "args": ["-y", "midnight-mcp"]
|
|
80
|
+
+ "args": ["-y", "midnight-mcp@latest"]
|
|
81
|
+
```
|
|
73
82
|
|
|
74
|
-
|
|
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
|
-
##
|
|
91
|
+
## What's Included
|
|
79
92
|
|
|
80
|
-
|
|
93
|
+
### 25 Tools
|
|
81
94
|
|
|
82
|
-
| Category
|
|
83
|
-
|
|
|
84
|
-
| Search
|
|
85
|
-
| Analysis
|
|
86
|
-
| **
|
|
87
|
-
|
|
|
88
|
-
|
|
|
89
|
-
|
|
|
90
|
-
|
|
|
91
|
-
|
|
|
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
|
-
|
|
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
|
-
|
|
108
|
+
### 9 Embedded Resources
|
|
99
109
|
|
|
100
|
-
|
|
110
|
+
Quick references available offline:
|
|
101
111
|
|
|
102
|
-
|
|
103
|
-
|
|
112
|
+
- Compact syntax guide
|
|
113
|
+
- SDK API reference
|
|
114
|
+
- OpenZeppelin contracts
|
|
115
|
+
- Tokenomics overview
|
|
116
|
+
- Wallet integration
|
|
117
|
+
- Common errors & solutions
|
|
104
118
|
|
|
105
|
-
###
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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)
|
|
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.
|
|
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
|
-
"
|
|
181
|
-
"midnight-extract-contract-structure -
|
|
182
|
-
"
|
|
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: "
|
|
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
|
};
|
package/dist/tools/meta.js
CHANGED
|
@@ -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",
|
|
@@ -142,6 +134,7 @@ function getToolsByCategory() {
|
|
|
142
134
|
...repositoryTools,
|
|
143
135
|
...healthTools,
|
|
144
136
|
...generationTools,
|
|
137
|
+
...metaTools,
|
|
145
138
|
];
|
|
146
139
|
const byCategory = new Map();
|
|
147
140
|
for (const tool of allTools) {
|
|
@@ -230,7 +223,7 @@ function generateCategorySuggestion(category) {
|
|
|
230
223
|
export const metaTools = [
|
|
231
224
|
{
|
|
232
225
|
name: "midnight-list-tool-categories",
|
|
233
|
-
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
|
|
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.",
|
|
234
227
|
inputSchema: {
|
|
235
228
|
type: "object",
|
|
236
229
|
properties: {
|
|
@@ -266,7 +259,6 @@ export const metaTools = [
|
|
|
266
259
|
"generation",
|
|
267
260
|
"health",
|
|
268
261
|
"compound",
|
|
269
|
-
"validation",
|
|
270
262
|
],
|
|
271
263
|
description: "Category to list tools for",
|
|
272
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 {
|
|
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 {
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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
|
-
//
|
|
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: "
|
|
464
|
-
"
|
|
465
|
-
"
|
|
466
|
-
"
|
|
467
|
-
"
|
|
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
|
|
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: "
|
|
469
|
+
category: "analyze",
|
|
573
470
|
},
|
|
574
471
|
handler: extractContractStructure,
|
|
575
472
|
},
|