midnight-mcp 0.1.8 → 0.1.10

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,113 +10,89 @@ MCP server that gives AI assistants access to Midnight blockchain—search contr
10
10
 
11
11
  ## Quick Start
12
12
 
13
- ### Claude Desktop
14
-
15
- Add to your `claude_desktop_config.json`:
13
+ **Claude Desktop** — Add to `claude_desktop_config.json`:
16
14
 
17
15
  ```json
18
16
  {
19
17
  "mcpServers": {
20
- "midnight": {
21
- "command": "npx",
22
- "args": ["-y", "midnight-mcp"]
23
- }
18
+ "midnight": { "command": "npx", "args": ["-y", "midnight-mcp"] }
24
19
  }
25
20
  }
26
21
  ```
27
22
 
28
- <details>
29
- <summary><strong>Config file locations</strong></summary>
30
-
31
- - **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
32
- - **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
33
- - **Linux**: `~/.config/Claude/claude_desktop_config.json`
34
-
35
- </details>
36
-
37
- ### Cursor
38
-
39
- **Click the button to auto install the MCP for Cursor**
23
+ **Cursor** — One-click install:
40
24
 
41
25
  [![Install MCP Server](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=midnight&config=eyJjb21tYW5kIjoibnB4IC15IG1pZG5pZ2h0LW1jcCJ9)
42
26
 
43
- ---
44
-
45
- **Manual setup instructions are below if you need them:**
27
+ <details>
28
+ <summary><strong>Other Editors (Windsurf, VS Code Copilot, Manual Setup)</strong></summary>
46
29
 
47
- Add to Cursor's MCP settings (Settings → MCP → Add Server):
30
+ **Windsurf** — Add to `~/.codeium/windsurf/mcp_config.json`:
48
31
 
49
32
  ```json
50
33
  {
51
34
  "mcpServers": {
52
- "midnight": {
53
- "command": "npx",
54
- "args": ["-y", "midnight-mcp"]
55
- }
35
+ "midnight": { "command": "npx", "args": ["-y", "midnight-mcp"] }
56
36
  }
57
37
  }
58
38
  ```
59
39
 
60
- Or add to `.cursor/mcp.json` in your project:
40
+ **VS Code Copilot** — Add to `.vscode/mcp.json` or use Command Palette: `MCP: Add Server` → "command (stdio)" → `npx -y midnight-mcp`
61
41
 
62
42
  ```json
63
43
  {
64
44
  "mcpServers": {
65
- "midnight": {
66
- "command": "npx",
67
- "args": ["-y", "midnight-mcp"]
68
- }
45
+ "midnight": { "command": "npx", "args": ["-y", "midnight-mcp"] }
69
46
  }
70
47
  }
71
48
  ```
72
49
 
73
- ### Windsurf
74
-
75
- Add to `~/.codeium/windsurf/mcp_config.json`:
50
+ **Cursor Manual** — Settings → MCP → Add Server, or add to `.cursor/mcp.json`:
76
51
 
77
52
  ```json
78
53
  {
79
54
  "mcpServers": {
80
- "midnight": {
81
- "command": "npx",
82
- "args": ["-y", "midnight-mcp"]
83
- }
55
+ "midnight": { "command": "npx", "args": ["-y", "midnight-mcp"] }
84
56
  }
85
57
  }
86
58
  ```
87
59
 
88
- ### VS Code Copilot
60
+ **Config file locations (Claude Desktop):**
89
61
 
90
- Add to your VS Code settings (`.vscode/mcp.json` in your workspace or user settings):
62
+ - macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
63
+ - Windows: `%APPDATA%\Claude\claude_desktop_config.json`
64
+ - Linux: `~/.config/Claude/claude_desktop_config.json`
91
65
 
92
- ```json
93
- {
94
- "mcpServers": {
95
- "midnight": {
96
- "command": "npx",
97
- "args": ["-y", "midnight-mcp"]
98
- }
99
- }
100
- }
101
- ```
66
+ </details>
102
67
 
103
- Or via Command Palette: `MCP: Add Server` select "command (stdio)" → enter `npx -y midnight-mcp`
68
+ Restart your editor after adding the config. **No API keys required.**
69
+
70
+ > **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.
104
71
 
105
72
  ---
106
73
 
107
- Restart your editor after adding the config. All features work out of the box—no API keys or setup required.
74
+ ## Features
108
75
 
109
- ---
76
+ **23 Tools** — Search, analyze, version tracking, AI generation, compound operations
110
77
 
111
- ## How It Works
78
+ | Category | Tools |
79
+ | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
80
+ | Search | `midnight-search-compact`, `midnight-search-typescript`, `midnight-search-docs` |
81
+ | Analysis | `midnight-analyze-contract`, `midnight-explain-circuit` |
82
+ | Repository | `midnight-get-file`, `midnight-list-examples`, `midnight-get-latest-updates` |
83
+ | 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` |
84
+ | AI Generation | `midnight-generate-contract`, `midnight-review-contract`, `midnight-document-contract` _(requires sampling)_ |
85
+ | Compound | `midnight-upgrade-check`, `midnight-get-repo-context` _(saves 50-70% tokens)_ |
86
+ | Discovery | `midnight-list-tool-categories`, `midnight-list-category-tools`, `midnight-health-check`, `midnight-get-status` |
112
87
 
113
- By default, the MCP uses a **hosted API** for semantic search:
88
+ > **Tip:** Use compound tools (`midnight-upgrade-check`, `midnight-get-repo-context`) for efficient multi-step operations in a single call.
114
89
 
115
- - **Zero configuration** — just install and use
116
- - **Semantic search** works immediately
117
- - **No API keys** needed
90
+ **9 Embedded Resources** — Quick references available offline: Compact syntax, SDK API, OpenZeppelin contracts, tokenomics, wallet integration, common errors
118
91
 
119
- > **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.
92
+ **5 Prompts** `create-contract`, `review-contract`, `explain-concept`, `compare-approaches`, `debug-contract`
93
+
94
+ <details>
95
+ <summary><strong>Advanced Configuration</strong></summary>
120
96
 
121
97
  ### Local Mode (Optional)
122
98
 
@@ -138,171 +114,58 @@ Run everything locally for privacy or offline use:
138
114
  }
139
115
  ```
140
116
 
141
- Local mode requires ChromaDB (`docker run -d -p 8000:8000 chromadb/chroma`) and an OpenAI API key.
117
+ Requires ChromaDB (`docker run -d -p 8000:8000 chromadb/chroma`) and OpenAI API key.
142
118
 
143
119
  ### GitHub Token (Optional)
144
120
 
145
121
  Add `"GITHUB_TOKEN": "ghp_..."` for higher GitHub API rate limits (60 → 5000 requests/hour).
146
122
 
123
+ </details>
124
+
147
125
  ---
148
126
 
149
- ## Features
127
+ ## Indexed Repositories
128
+
129
+ The API indexes **22+ Midnight repositories**:
150
130
 
151
- ### Tools (19)
152
-
153
- | Tool | Description |
154
- | --------------------------------- | ------------------------------------------- |
155
- | `midnight-search-compact` | Search Compact contract code |
156
- | `midnight-search-typescript` | Search TypeScript SDK |
157
- | `midnight-search-docs` | Search documentation |
158
- | `midnight-analyze-contract` | Analyze contract structure and security |
159
- | `midnight-explain-circuit` | Explain circuits in plain language |
160
- | `midnight-get-file` | Get files from Midnight repos |
161
- | `midnight-list-examples` | List example contracts |
162
- | `midnight-get-latest-updates` | Recent repo changes |
163
- | `midnight-get-version-info` | Get version and release info |
164
- | `midnight-check-breaking-changes` | Check for breaking changes |
165
- | `midnight-get-migration-guide` | Migration guides between versions |
166
- | `midnight-get-file-at-version` | Get file at specific version |
167
- | `midnight-compare-syntax` | Compare files between versions |
168
- | `midnight-get-latest-syntax` | Latest syntax reference |
169
- | `midnight-health-check` | Check server health status |
170
- | `midnight-get-status` | Get rate limits and cache stats |
171
- | `midnight-generate-contract` | AI-generate contracts from natural language |
172
- | `midnight-review-contract` | AI-powered security review of contracts |
173
- | `midnight-document-contract` | AI-generate documentation for contracts |
174
-
175
- > **Note:** The AI-powered tools require a client with [MCP Sampling](https://spec.modelcontextprotocol.io/specification/client/sampling/) support (e.g., Claude Desktop). Without sampling, these tools will return a helpful message instead.
176
-
177
- ### Resource Templates (4)
178
-
179
- Dynamic access to any resource using URI templates:
180
-
181
- | Template | Description |
182
- | --------------------------------------- | ------------------------------ |
183
- | `midnight://code/{owner}/{repo}/{path}` | Any code file from any repo |
184
- | `midnight://docs/{section}/{topic}` | Documentation by section/topic |
185
- | `midnight://examples/{category}/{name}` | Example contracts by category |
186
- | `midnight://schema/{type}` | JSON schemas (AST, tx, proofs) |
187
-
188
- ### Embedded Resources (9)
189
-
190
- Curated documentation that's always available without network calls:
191
-
192
- | URI | Description |
193
- | --------------------------------------- | --------------------------------------- |
194
- | `midnight://docs/compact-reference` | Compact syntax quick reference |
195
- | `midnight://docs/sdk-api` | TypeScript SDK API reference |
196
- | `midnight://docs/openzeppelin` | OpenZeppelin Compact contracts overview |
197
- | `midnight://docs/openzeppelin/token` | FungibleToken standard |
198
- | `midnight://docs/openzeppelin/access` | Access control patterns |
199
- | `midnight://docs/openzeppelin/security` | Security patterns (Pausable) |
200
- | `midnight://docs/tokenomics` | NIGHT/DUST tokenomics summary |
201
- | `midnight://docs/wallet-integration` | DApp Connector API guide |
202
- | `midnight://docs/common-errors` | Common errors & troubleshooting |
203
-
204
- > **Note:** For comprehensive docs (glossary, Zswap, Kachina, etc.), use the `midnight-search-docs` tool which queries the full indexed documentation.
205
-
206
- ### Prompts (5)
207
-
208
- - `midnight:create-contract` — Create new contracts
209
- - `midnight:review-contract` — Security review
210
- - `midnight:explain-concept` — Learn Midnight concepts
211
- - `midnight:compare-approaches` — Compare implementation approaches
212
- - `midnight:debug-contract` — Debug issues
131
+ | Category | Repositories |
132
+ | ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
133
+ | Core | `compact`, `midnight-js`, `midnight-wallet`, `midnight-docs` |
134
+ | Examples | `example-counter`, `example-bboard`, `example-dex`, `create-mn-app` |
135
+ | Infrastructure | `midnight-indexer`, `midnight-node-docker`, `midnight-dapp-connector-api` |
136
+ | Partner Libraries | `OpenZeppelin/compact-contracts`, `OpenZeppelin/midnight-apps` |
137
+ | Official Partners | `bricktowers/midnight-seabattle`, `bricktowers/midnight-identity`, `bricktowers/midnight-rwa`, `MeshJS/midnight-starter-template`, `midnames/core` |
213
138
 
214
139
  ---
215
140
 
216
141
  ## Developer Setup
217
142
 
218
- For contributors:
219
-
220
143
  ```bash
221
- git clone https://github.com/Olanetsoft/midnight-mcp.git
222
- cd midnight-mcp
223
- npm install
224
- npm run build
225
- npm test
144
+ git clone https://github.com/Olanetsoft/midnight-mcp.git && cd midnight-mcp
145
+ npm install && npm run build && npm test
226
146
  ```
227
147
 
228
- ### Testing with Local API
148
+ <details>
149
+ <summary><strong>API Backend & Local Development</strong></summary>
150
+
151
+ The hosted API runs on Cloudflare Workers + Vectorize. See [api/README.md](./api/README.md).
229
152
 
230
- To test against a local API server instead of production:
153
+ **Testing with Local API:**
231
154
 
232
155
  ```bash
233
156
  # Terminal 1: Start local API
234
- cd api
235
- npm install
236
- npm run dev # Starts at http://localhost:8787
157
+ cd api && npm install && npm run dev
237
158
 
238
159
  # Terminal 2: Run MCP with local API
239
160
  MIDNIGHT_API_URL=http://localhost:8787 npm start
240
161
  ```
241
162
 
242
- ### API Backend
243
-
244
- The hosted API runs on Cloudflare Workers + Vectorize. See [api/README.md](./api/README.md) for deployment and development instructions.
245
-
246
- ### Search Quality
247
-
248
- The API indexes **16 Midnight repositories** including core infrastructure, SDK, examples, and developer tools:
249
-
250
- | Repository | Description |
251
- | -------------------------------- | ---------------------------------------------- |
252
- | `compact` | Compact language compiler and standard library |
253
- | `midnight-js` | TypeScript SDK |
254
- | `midnight-docs` | Official documentation |
255
- | `example-counter` | Simple counter DApp example |
256
- | `example-bboard` | Bulletin board DApp example |
257
- | `example-dex` | DEX DApp example |
258
- | `create-mn-app` | Project scaffolding CLI |
259
- | `midnight-wallet` | Wallet implementation |
260
- | `midnight-indexer` | Blockchain indexer |
261
- | `midnight-node-docker` | Node Docker setup |
262
- | `midnight-dapp-connector-api` | Wallet connector API |
263
- | `compact-tree-sitter` | Syntax highlighting support |
264
- | `setup-compact-action` | GitHub Action for CI/CD |
265
- | `midnight-awesome-dapps` | Curated DApp list |
266
- | `contributor-hub` | Contributor resources |
267
- | `OpenZeppelin/compact-contracts` | OpenZeppelin Compact library |
268
-
269
- Search quality techniques:
163
+ </details>
270
164
 
271
- - **Optimized chunking** — 1000-char chunks with 200-char overlap for precise, contextual results
272
- - **Hybrid search** — Combines vector similarity with keyword boosting (up to 20% boost for exact matches)
273
- - **Incremental indexing** — Daily updates via tarball download + batch embeddings (~5 min)
165
+ ## Links
274
166
 
275
- View live metrics at the [Dashboard](https://midnight-mcp-api.midnightmcp.workers.dev/dashboard).
167
+ - [Midnight Docs](https://docs.midnight.network) [MCP Spec](https://modelcontextprotocol.io) • [Midnight GitHub](https://github.com/midnightntwrk)
276
168
 
277
169
  ## License
278
170
 
279
171
  MIT
280
-
281
- ## Changelog
282
-
283
- ### v0.1.7
284
-
285
- - Added `setup-compact-action` repository to indexed sources
286
- - New aliases: `setup-compact`, `compact-action`, `tree-sitter`
287
-
288
- ### v0.1.6
289
-
290
- - Fixed bug where tools crashed with "Cannot read properties of undefined" when repo param was omitted
291
-
292
- ### v0.1.5
293
-
294
- - Added `common-errors` embedded resource with verified troubleshooting guide
295
- - Added comprehensive search tool tests
296
- - Refactored to follow MCP best practices (tools over embedded knowledge)
297
-
298
- ### v0.1.4
299
-
300
- - Initial stable release with 19 tools, 9 embedded resources, 5 prompts
301
- - Hosted API with zero-config semantic search
302
- - Support for Claude Desktop, Cursor, and Windsurf
303
-
304
- ## Links
305
-
306
- - [Midnight Docs](https://docs.midnight.network)
307
- - [MCP Spec](https://modelcontextprotocol.io)
308
- - [Midnight GitHub](https://github.com/midnightntwrk)
@@ -397,6 +397,7 @@ export const analyzeTools = [
397
397
  readOnlyHint: true,
398
398
  idempotentHint: true,
399
399
  title: "Analyze Compact Contract",
400
+ category: "analyze",
400
401
  },
401
402
  handler: analyzeContract,
402
403
  },
@@ -418,6 +419,7 @@ export const analyzeTools = [
418
419
  readOnlyHint: true,
419
420
  idempotentHint: true,
420
421
  title: "Explain Circuit",
422
+ category: "analyze",
421
423
  },
422
424
  handler: explainCircuit,
423
425
  },
@@ -182,6 +182,7 @@ EXAMPLE USAGE:
182
182
  idempotentHint: false,
183
183
  openWorldHint: true,
184
184
  longRunningHint: true,
185
+ category: "generation",
185
186
  },
186
187
  handler: handleGenerateContract,
187
188
  },
@@ -223,6 +224,7 @@ OUTPUT INCLUDES:
223
224
  idempotentHint: true,
224
225
  openWorldHint: true,
225
226
  longRunningHint: true,
227
+ category: "generation",
226
228
  },
227
229
  handler: handleReviewContract,
228
230
  },
@@ -268,6 +270,7 @@ MARKDOWN INCLUDES:
268
270
  idempotentHint: true,
269
271
  openWorldHint: true,
270
272
  longRunningHint: true,
273
+ category: "generation",
271
274
  },
272
275
  handler: handleDocumentContract,
273
276
  },
@@ -140,6 +140,7 @@ export const healthTools = [
140
140
  readOnlyHint: true,
141
141
  idempotentHint: true,
142
142
  title: "Health Check",
143
+ category: "health",
143
144
  },
144
145
  handler: healthCheck,
145
146
  },
@@ -155,6 +156,7 @@ export const healthTools = [
155
156
  readOnlyHint: true,
156
157
  idempotentHint: true,
157
158
  title: "Get Server Status",
159
+ category: "health",
158
160
  },
159
161
  handler: getStatus,
160
162
  },
@@ -7,6 +7,7 @@ export type { GetFileInput, ListExamplesInput, GetLatestUpdatesInput, } from "./
7
7
  export { healthTools, healthCheck, getStatus } from "./health.js";
8
8
  export type { HealthCheckInput, GetStatusInput } from "./health.js";
9
9
  export { generationTools, generationHandlers } from "./generation.js";
10
+ export { metaTools, listToolCategories, listCategoryTools } from "./meta.js";
10
11
  export type { ExtendedToolDefinition, ToolAnnotations, OutputSchema, } from "../types/index.js";
11
12
  import type { ExtendedToolDefinition } from "../types/index.js";
12
13
  export declare const allTools: ExtendedToolDefinition[];
@@ -3,13 +3,16 @@ export { analyzeTools, analyzeContract, explainCircuit } from "./analyze.js";
3
3
  export { repositoryTools, getFile, listExamples, getLatestUpdates, } from "./repository.js";
4
4
  export { healthTools, healthCheck, getStatus } from "./health.js";
5
5
  export { generationTools, generationHandlers } from "./generation.js";
6
+ export { metaTools, listToolCategories, listCategoryTools } from "./meta.js";
6
7
  // Combined tool list for MCP server
7
8
  import { searchTools } from "./search.js";
8
9
  import { analyzeTools } from "./analyze.js";
9
10
  import { repositoryTools } from "./repository.js";
10
11
  import { healthTools } from "./health.js";
11
12
  import { generationTools } from "./generation.js";
13
+ import { metaTools } from "./meta.js";
12
14
  export const allTools = [
15
+ ...metaTools, // Discovery tools first for visibility
13
16
  ...searchTools,
14
17
  ...analyzeTools,
15
18
  ...repositoryTools,
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Meta-tools for progressive disclosure and tool discovery
3
+ * These tools help AI agents efficiently discover and use available capabilities
4
+ */
5
+ import type { ExtendedToolDefinition, OutputSchema, ToolCategory } from "../types/index.js";
6
+ interface ListCategoriesInput {
7
+ includeToolCounts?: boolean;
8
+ }
9
+ interface ListCategoryToolsInput {
10
+ category: ToolCategory;
11
+ includeSchemas?: boolean;
12
+ }
13
+ /**
14
+ * List available tool categories
15
+ * Use this first to understand what's available before drilling into specific tools
16
+ */
17
+ export declare function listToolCategories(_input: ListCategoriesInput): Promise<{
18
+ categories: {
19
+ name: string;
20
+ description: string;
21
+ toolCount: number;
22
+ useCases: string[];
23
+ }[];
24
+ totalTools: number;
25
+ recommendation: string;
26
+ tip: string;
27
+ }>;
28
+ /**
29
+ * List tools within a specific category
30
+ * Progressive disclosure: drill into a category to see its tools
31
+ */
32
+ export declare function listCategoryTools(input: ListCategoryToolsInput): Promise<{
33
+ error: string;
34
+ availableCategories: string[];
35
+ suggestion: string;
36
+ category?: undefined;
37
+ description?: undefined;
38
+ tools?: undefined;
39
+ } | {
40
+ category: ToolCategory;
41
+ description: string;
42
+ tools: {
43
+ inputSchema?: {
44
+ type: "object";
45
+ properties: Record<string, unknown>;
46
+ required?: string[];
47
+ } | undefined;
48
+ outputSchema?: OutputSchema | undefined;
49
+ name: string;
50
+ description: string;
51
+ title: string;
52
+ isCompound: boolean;
53
+ requiresSampling: boolean | undefined;
54
+ }[];
55
+ suggestion: string;
56
+ error?: undefined;
57
+ availableCategories?: undefined;
58
+ }>;
59
+ export declare const metaTools: ExtendedToolDefinition[];
60
+ export {};
61
+ //# sourceMappingURL=meta.d.ts.map