midnight-mcp 0.1.28 → 0.1.30
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 +109 -84
- package/dist/server.d.ts +9 -1
- package/dist/server.js +183 -7
- package/dist/tools/meta.js +1 -10
- package/dist/tools/repository/handlers.d.ts +11 -3
- package/dist/tools/repository/handlers.js +36 -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/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/logger.d.ts +5 -0
- package/dist/utils/logger.js +16 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,99 +10,153 @@ 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
|
-
"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`
|
|
53
56
|
|
|
54
|
-
|
|
57
|
+
### Windsurf
|
|
58
|
+
|
|
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
|
|
92
|
+
|
|
93
|
+
### 25 Tools
|
|
79
94
|
|
|
80
|
-
|
|
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 |
|
|
81
105
|
|
|
82
|
-
|
|
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` |
|
|
106
|
+
All tools are prefixed with `midnight-` (e.g., `midnight-search-compact`).
|
|
93
107
|
|
|
94
|
-
|
|
95
|
-
>
|
|
96
|
-
> **🔄 New:** `midnight-check-version` tells you if you're running the latest version with update instructions.
|
|
108
|
+
### MCP Capabilities
|
|
97
109
|
|
|
98
|
-
|
|
110
|
+
| Capability | Feature |
|
|
111
|
+
| --------------- | ----------------------------------------------- |
|
|
112
|
+
| **Tools** | 25 tools with `listChanged` notifications |
|
|
113
|
+
| **Resources** | 9 embedded resources with subscription support |
|
|
114
|
+
| **Prompts** | 5 workflow prompts |
|
|
115
|
+
| **Logging** | Client-controllable log level |
|
|
116
|
+
| **Completions** | Autocomplete for prompt arguments |
|
|
117
|
+
| **Progress** | Real-time progress for compound tools |
|
|
118
|
+
| **Sampling** | AI-powered generation (when client supports it) |
|
|
99
119
|
|
|
100
|
-
|
|
120
|
+
### 9 Embedded Resources
|
|
101
121
|
|
|
102
|
-
|
|
103
|
-
<summary><strong>Advanced Configuration</strong></summary>
|
|
122
|
+
Quick references available offline:
|
|
104
123
|
|
|
105
|
-
|
|
124
|
+
- Compact syntax guide
|
|
125
|
+
- SDK API reference
|
|
126
|
+
- OpenZeppelin contracts
|
|
127
|
+
- Tokenomics overview
|
|
128
|
+
- Wallet integration
|
|
129
|
+
- Common errors & solutions
|
|
130
|
+
|
|
131
|
+
### 5 Prompts
|
|
132
|
+
|
|
133
|
+
- `create-contract` — Generate new contracts
|
|
134
|
+
- `review-contract` — Security and code review
|
|
135
|
+
- `explain-concept` — Learn Midnight concepts
|
|
136
|
+
- `compare-approaches` — Compare implementation patterns
|
|
137
|
+
- `debug-contract` — Troubleshoot issues
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## Indexed Repositories
|
|
142
|
+
|
|
143
|
+
The API indexes **39 Midnight repositories**:
|
|
144
|
+
|
|
145
|
+
| Category | Repositories |
|
|
146
|
+
| --------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
147
|
+
| **Core** | `compact`, `midnight-js`, `midnight-wallet`, `midnight-docs`, `midnight-node`, `midnight-indexer`, `midnight-ledger`, `midnight-zk` |
|
|
148
|
+
| **Examples** | `example-counter`, `example-bboard`, `example-dex`, `create-mn-app` |
|
|
149
|
+
| **Infrastructure** | `midnight-node-docker`, `midnight-dapp-connector-api`, `compact-tree-sitter`, `setup-compact-action` |
|
|
150
|
+
| **Partner Libraries** | `OpenZeppelin/compact-contracts`, `OpenZeppelin/midnight-apps` (LunarSwap) |
|
|
151
|
+
| **Official Partners** | `bricktowers/midnight-seabattle`, `bricktowers/midnight-identity`, `bricktowers/midnight-rwa`, `MeshJS/midnight-starter-template`, `midnames/core` |
|
|
152
|
+
| **Core Partner** | `PaimaStudios/midnight-game-2`, `PaimaStudios/midnight-wasm-prover`, `PaimaStudios/midnight-batcher`, `PaimaStudios/midnight-impact-rps-example` |
|
|
153
|
+
| **Hackathon Winners** | Sea Battle: `ErickRomeroDev/naval-battle-game_v2`, `eddex/midnight-sea-battle-hackathon` • Mini DApp: `statera-protocol`, `nel349/midnight-bank`, `Imdavyking/zkbadge` |
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## Advanced Configuration
|
|
158
|
+
|
|
159
|
+
### Local Mode
|
|
106
160
|
|
|
107
161
|
Run everything locally for privacy or offline use:
|
|
108
162
|
|
|
@@ -124,28 +178,10 @@ Run everything locally for privacy or offline use:
|
|
|
124
178
|
|
|
125
179
|
Requires ChromaDB (`docker run -d -p 8000:8000 chromadb/chroma`) and OpenAI API key.
|
|
126
180
|
|
|
127
|
-
### GitHub Token
|
|
181
|
+
### GitHub Token
|
|
128
182
|
|
|
129
183
|
Add `"GITHUB_TOKEN": "ghp_..."` for higher GitHub API rate limits (60 → 5000 requests/hour).
|
|
130
184
|
|
|
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
185
|
---
|
|
150
186
|
|
|
151
187
|
## Developer Setup
|
|
@@ -155,26 +191,15 @@ git clone https://github.com/Olanetsoft/midnight-mcp.git && cd midnight-mcp
|
|
|
155
191
|
npm install && npm run build && npm test
|
|
156
192
|
```
|
|
157
193
|
|
|
158
|
-
|
|
159
|
-
<summary><strong>API Backend & Local Development</strong></summary>
|
|
194
|
+
The hosted API runs on Cloudflare Workers + Vectorize. See [api/README.md](./api/README.md) for backend details.
|
|
160
195
|
|
|
161
|
-
|
|
162
|
-
|
|
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>
|
|
196
|
+
---
|
|
174
197
|
|
|
175
198
|
## Links
|
|
176
199
|
|
|
177
|
-
- [Midnight Docs](https://docs.midnight.network)
|
|
200
|
+
- [Midnight Docs](https://docs.midnight.network)
|
|
201
|
+
- [MCP Spec](https://modelcontextprotocol.io)
|
|
202
|
+
- [Midnight GitHub](https://github.com/midnightntwrk)
|
|
178
203
|
|
|
179
204
|
## License
|
|
180
205
|
|
package/dist/server.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
2
|
+
import { LoggingLevel } from "@modelcontextprotocol/sdk/types.js";
|
|
2
3
|
/**
|
|
3
4
|
* Get update warning if outdated (to include in responses)
|
|
4
5
|
*/
|
|
@@ -8,8 +9,15 @@ export declare function getUpdateWarning(): string | null;
|
|
|
8
9
|
*/
|
|
9
10
|
export declare function clearSubscriptions(): void;
|
|
10
11
|
/**
|
|
11
|
-
*
|
|
12
|
+
* Send a log message to the MCP client
|
|
13
|
+
* This allows clients to see server logs for debugging
|
|
12
14
|
*/
|
|
15
|
+
export declare function sendLogToClient(level: LoggingLevel, loggerName: string, data: unknown): void;
|
|
16
|
+
/**
|
|
17
|
+
* Send a progress notification to the MCP client
|
|
18
|
+
* Used for long-running operations like compound tools
|
|
19
|
+
*/
|
|
20
|
+
export declare function sendProgressNotification(progressToken: string | number, progress: number, total?: number, message?: string): void;
|
|
13
21
|
export declare function createServer(): Server;
|
|
14
22
|
/**
|
|
15
23
|
* Notify subscribers when a resource changes
|
package/dist/server.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
2
2
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
|
-
import { CallToolRequestSchema, ListToolsRequestSchema, ListResourcesRequestSchema, ReadResourceRequestSchema, ListPromptsRequestSchema, GetPromptRequestSchema, ListResourceTemplatesRequestSchema, SubscribeRequestSchema, UnsubscribeRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
4
|
-
import { logger, formatErrorResponse } from "./utils/index.js";
|
|
3
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, ListResourcesRequestSchema, ReadResourceRequestSchema, ListPromptsRequestSchema, GetPromptRequestSchema, ListResourceTemplatesRequestSchema, SubscribeRequestSchema, UnsubscribeRequestSchema, SetLevelRequestSchema, CompleteRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
4
|
+
import { logger, formatErrorResponse, setMCPLogCallback, } from "./utils/index.js";
|
|
5
5
|
import { vectorStore } from "./db/index.js";
|
|
6
6
|
import { allTools } from "./tools/index.js";
|
|
7
7
|
import { allResources, getDocumentation, getCode, getSchema, } from "./resources/index.js";
|
|
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.30";
|
|
12
12
|
const SERVER_INFO = {
|
|
13
13
|
name: "midnight-mcp",
|
|
14
14
|
version: CURRENT_VERSION,
|
|
@@ -97,6 +97,67 @@ const resourceTemplates = [
|
|
|
97
97
|
/**
|
|
98
98
|
* Create and configure the MCP server
|
|
99
99
|
*/
|
|
100
|
+
// Current MCP logging level (controlled by client)
|
|
101
|
+
let mcpLogLevel = "info";
|
|
102
|
+
// Server instance for sending notifications
|
|
103
|
+
let serverInstance = null;
|
|
104
|
+
/**
|
|
105
|
+
* Send a log message to the MCP client
|
|
106
|
+
* This allows clients to see server logs for debugging
|
|
107
|
+
*/
|
|
108
|
+
export function sendLogToClient(level, loggerName, data) {
|
|
109
|
+
if (!serverInstance)
|
|
110
|
+
return;
|
|
111
|
+
// Map levels to numeric values for comparison
|
|
112
|
+
const levelValues = {
|
|
113
|
+
debug: 0,
|
|
114
|
+
info: 1,
|
|
115
|
+
notice: 2,
|
|
116
|
+
warning: 3,
|
|
117
|
+
error: 4,
|
|
118
|
+
critical: 5,
|
|
119
|
+
alert: 6,
|
|
120
|
+
emergency: 7,
|
|
121
|
+
};
|
|
122
|
+
// Only send if level meets threshold
|
|
123
|
+
if (levelValues[level] < levelValues[mcpLogLevel])
|
|
124
|
+
return;
|
|
125
|
+
try {
|
|
126
|
+
serverInstance.notification({
|
|
127
|
+
method: "notifications/message",
|
|
128
|
+
params: {
|
|
129
|
+
level,
|
|
130
|
+
logger: loggerName,
|
|
131
|
+
data,
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
// Ignore notification errors
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Send a progress notification to the MCP client
|
|
141
|
+
* Used for long-running operations like compound tools
|
|
142
|
+
*/
|
|
143
|
+
export function sendProgressNotification(progressToken, progress, total, message) {
|
|
144
|
+
if (!serverInstance)
|
|
145
|
+
return;
|
|
146
|
+
try {
|
|
147
|
+
serverInstance.notification({
|
|
148
|
+
method: "notifications/progress",
|
|
149
|
+
params: {
|
|
150
|
+
progressToken,
|
|
151
|
+
progress,
|
|
152
|
+
...(total !== undefined && { total }),
|
|
153
|
+
...(message && { message }),
|
|
154
|
+
},
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
catch {
|
|
158
|
+
// Ignore notification errors
|
|
159
|
+
}
|
|
160
|
+
}
|
|
100
161
|
export function createServer() {
|
|
101
162
|
const server = new Server(SERVER_INFO, {
|
|
102
163
|
capabilities: {
|
|
@@ -110,8 +171,16 @@ export function createServer() {
|
|
|
110
171
|
prompts: {
|
|
111
172
|
listChanged: true,
|
|
112
173
|
},
|
|
174
|
+
logging: {},
|
|
175
|
+
completions: {},
|
|
113
176
|
},
|
|
114
177
|
});
|
|
178
|
+
// Store server instance for logging notifications
|
|
179
|
+
serverInstance = server;
|
|
180
|
+
// Wire up MCP logging - send logger output to client
|
|
181
|
+
setMCPLogCallback((level, loggerName, data) => {
|
|
182
|
+
sendLogToClient(level, loggerName, data);
|
|
183
|
+
});
|
|
115
184
|
// Register tool handlers
|
|
116
185
|
registerToolHandlers(server);
|
|
117
186
|
// Register resource handlers
|
|
@@ -120,10 +189,114 @@ export function createServer() {
|
|
|
120
189
|
registerPromptHandlers(server);
|
|
121
190
|
// Register subscription handlers
|
|
122
191
|
registerSubscriptionHandlers(server);
|
|
192
|
+
// Register logging handler
|
|
193
|
+
registerLoggingHandler(server);
|
|
194
|
+
// Register completions handler
|
|
195
|
+
registerCompletionsHandler(server);
|
|
123
196
|
// Setup sampling callback if available
|
|
124
197
|
setupSampling(server);
|
|
125
198
|
return server;
|
|
126
199
|
}
|
|
200
|
+
/**
|
|
201
|
+
* Register logging handler for MCP logging capability
|
|
202
|
+
*/
|
|
203
|
+
function registerLoggingHandler(server) {
|
|
204
|
+
server.setRequestHandler(SetLevelRequestSchema, async (request) => {
|
|
205
|
+
const { level } = request.params;
|
|
206
|
+
mcpLogLevel = level;
|
|
207
|
+
logger.info(`MCP log level set to: ${level}`);
|
|
208
|
+
sendLogToClient("info", "midnight-mcp", {
|
|
209
|
+
message: `Log level changed to ${level}`,
|
|
210
|
+
});
|
|
211
|
+
return {};
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
// Completion suggestions for prompt arguments
|
|
215
|
+
const COMPLETION_VALUES = {
|
|
216
|
+
"midnight:create-contract": {
|
|
217
|
+
contractType: [
|
|
218
|
+
"token",
|
|
219
|
+
"voting",
|
|
220
|
+
"credential",
|
|
221
|
+
"auction",
|
|
222
|
+
"escrow",
|
|
223
|
+
"custom",
|
|
224
|
+
],
|
|
225
|
+
privacyLevel: ["full", "partial", "public"],
|
|
226
|
+
complexity: ["beginner", "intermediate", "advanced"],
|
|
227
|
+
},
|
|
228
|
+
"midnight:review-contract": {
|
|
229
|
+
focusAreas: [
|
|
230
|
+
"security",
|
|
231
|
+
"performance",
|
|
232
|
+
"privacy",
|
|
233
|
+
"readability",
|
|
234
|
+
"gas-optimization",
|
|
235
|
+
],
|
|
236
|
+
},
|
|
237
|
+
"midnight:explain-concept": {
|
|
238
|
+
concept: [
|
|
239
|
+
"zk-proofs",
|
|
240
|
+
"circuits",
|
|
241
|
+
"witnesses",
|
|
242
|
+
"ledger",
|
|
243
|
+
"state-management",
|
|
244
|
+
"privacy-model",
|
|
245
|
+
"token-transfers",
|
|
246
|
+
"merkle-trees",
|
|
247
|
+
],
|
|
248
|
+
level: ["beginner", "intermediate", "advanced"],
|
|
249
|
+
},
|
|
250
|
+
"midnight:compare-approaches": {
|
|
251
|
+
approaches: [
|
|
252
|
+
"token-standards",
|
|
253
|
+
"state-management",
|
|
254
|
+
"privacy-patterns",
|
|
255
|
+
"circuit-design",
|
|
256
|
+
],
|
|
257
|
+
},
|
|
258
|
+
"midnight:debug-contract": {
|
|
259
|
+
errorType: [
|
|
260
|
+
"compilation",
|
|
261
|
+
"runtime",
|
|
262
|
+
"logic",
|
|
263
|
+
"privacy-leak",
|
|
264
|
+
"state-corruption",
|
|
265
|
+
],
|
|
266
|
+
},
|
|
267
|
+
};
|
|
268
|
+
/**
|
|
269
|
+
* Register completions handler for argument autocompletion
|
|
270
|
+
*/
|
|
271
|
+
function registerCompletionsHandler(server) {
|
|
272
|
+
server.setRequestHandler(CompleteRequestSchema, async (request) => {
|
|
273
|
+
const { ref, argument } = request.params;
|
|
274
|
+
if (ref.type !== "ref/prompt") {
|
|
275
|
+
return { completion: { values: [], hasMore: false } };
|
|
276
|
+
}
|
|
277
|
+
const promptName = ref.name;
|
|
278
|
+
const argName = argument.name;
|
|
279
|
+
const currentValue = argument.value?.toLowerCase() || "";
|
|
280
|
+
// Get completion values for this prompt/argument
|
|
281
|
+
const promptCompletions = COMPLETION_VALUES[promptName];
|
|
282
|
+
if (!promptCompletions) {
|
|
283
|
+
return { completion: { values: [], hasMore: false } };
|
|
284
|
+
}
|
|
285
|
+
const argValues = promptCompletions[argName];
|
|
286
|
+
if (!argValues) {
|
|
287
|
+
return { completion: { values: [], hasMore: false } };
|
|
288
|
+
}
|
|
289
|
+
// Filter by current input
|
|
290
|
+
const filtered = argValues.filter((v) => v.toLowerCase().includes(currentValue));
|
|
291
|
+
return {
|
|
292
|
+
completion: {
|
|
293
|
+
values: filtered.slice(0, 20),
|
|
294
|
+
total: filtered.length,
|
|
295
|
+
hasMore: filtered.length > 20,
|
|
296
|
+
},
|
|
297
|
+
};
|
|
298
|
+
});
|
|
299
|
+
}
|
|
127
300
|
/**
|
|
128
301
|
* Register tool handlers
|
|
129
302
|
*/
|
|
@@ -177,9 +350,9 @@ function registerToolHandlers(server) {
|
|
|
177
350
|
"🚨 ACTION REQUIRED": {
|
|
178
351
|
message: `You are using an OUTDATED version of midnight-mcp (v${CURRENT_VERSION}). Latest is v${versionCheckResult.latestVersion}.`,
|
|
179
352
|
missingFeatures: [
|
|
180
|
-
"
|
|
181
|
-
"midnight-extract-contract-structure -
|
|
182
|
-
"
|
|
353
|
+
"Latest tool improvements and bug fixes",
|
|
354
|
+
"midnight-extract-contract-structure - Static pattern analysis",
|
|
355
|
+
"Improved error detection and contract analysis",
|
|
183
356
|
],
|
|
184
357
|
userInstructions: {
|
|
185
358
|
step1: "Tell the user: 'Your Midnight MCP is outdated. Let me help you update it.'",
|
|
@@ -187,7 +360,7 @@ function registerToolHandlers(server) {
|
|
|
187
360
|
step3: "Ask them to restart Claude Desktop completely (Cmd+Q / Alt+F4)",
|
|
188
361
|
step4: "Or suggest updating config to use: midnight-mcp@latest",
|
|
189
362
|
},
|
|
190
|
-
importance: "
|
|
363
|
+
importance: "Update to get the latest features and improvements. Older versions may have bugs or missing functionality.",
|
|
191
364
|
},
|
|
192
365
|
result,
|
|
193
366
|
};
|
|
@@ -207,6 +380,9 @@ function registerToolHandlers(server) {
|
|
|
207
380
|
text: JSON.stringify(result, null, 2),
|
|
208
381
|
},
|
|
209
382
|
],
|
|
383
|
+
// Include structured content for machine-readable responses
|
|
384
|
+
// This allows clients to parse results without JSON.parse()
|
|
385
|
+
structuredContent: result,
|
|
210
386
|
};
|
|
211
387
|
}
|
|
212
388
|
catch (error) {
|
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",
|
|
@@ -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
|
|
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 {
|
|
6
|
+
export { extractContractStructure } from "./validation.js";
|
|
7
7
|
/**
|
|
8
8
|
* Resolve repository name alias to owner/repo
|
|
9
9
|
*/
|
|
@@ -191,7 +191,11 @@ export declare function getLatestSyntax(input: GetLatestSyntaxInput): Promise<{
|
|
|
191
191
|
* Combines: getVersionInfo + checkBreakingChanges + getMigrationGuide
|
|
192
192
|
* Reduces 3 tool calls to 1, saving ~60% tokens
|
|
193
193
|
*/
|
|
194
|
-
export declare function upgradeCheck(input: UpgradeCheckInput
|
|
194
|
+
export declare function upgradeCheck(input: UpgradeCheckInput & {
|
|
195
|
+
_meta?: {
|
|
196
|
+
progressToken?: string | number;
|
|
197
|
+
};
|
|
198
|
+
}): Promise<{
|
|
195
199
|
repository: string;
|
|
196
200
|
currentVersion: string;
|
|
197
201
|
version: {
|
|
@@ -219,7 +223,11 @@ export declare function upgradeCheck(input: UpgradeCheckInput): Promise<{
|
|
|
219
223
|
* Combines: getVersionInfo + getLatestSyntax + listExamples (filtered)
|
|
220
224
|
* Provides everything needed to start working with a repo
|
|
221
225
|
*/
|
|
222
|
-
export declare function getFullRepoContext(input: FullRepoContextInput
|
|
226
|
+
export declare function getFullRepoContext(input: FullRepoContextInput & {
|
|
227
|
+
_meta?: {
|
|
228
|
+
progressToken?: string | number;
|
|
229
|
+
};
|
|
230
|
+
}): Promise<{
|
|
223
231
|
repository: string;
|
|
224
232
|
quickStart: {
|
|
225
233
|
version: string;
|