Model Context Protocol Server for Midnight Blockchain Development
npm install midnight-mcp




MCP server that gives AI assistants access to Midnight blockchain—search contracts, analyze code, and explore documentation.
- Node.js 20+ (LTS recommended)
Check your version: node --version
Using nvm? Click for Claude Desktop setup
If you use nvm, Claude Desktop may not see your nvm-managed Node. Use this config instead:
``json`
{
"mcpServers": {
"midnight": {
"command": "/bin/sh",
"args": [
"-c",
"source ~/.nvm/nvm.sh && nvm use 20 >/dev/null 2>&1 && npx -y midnight-mcp@latest"
]
}
}
}
Add to your claude_desktop_config.json:
`json`
{
"mcpServers": {
"midnight": {
"command": "npx",
"args": ["-y", "midnight-mcp@latest"]
}
}
}
Config file locations:
- macOS: ~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.json
- Windows: ~/.config/Claude/claude_desktop_config.json
- Linux:
One-click install:

Or manually add to .cursor/mcp.json:
`json`
{
"mcpServers": {
"midnight": {
"command": "npx",
"args": ["-y", "midnight-mcp@latest"]
}
}
}
Add to .vscode/mcp.json or use Command Palette: MCP: Add Server → "command (stdio)" → npx -y midnight-mcp@latest
Add to ~/.codeium/windsurf/mcp_config.json:
`json`
{
"mcpServers": {
"midnight": {
"command": "npx",
"args": ["-y", "midnight-mcp@latest"]
}
}
}
No API keys required. Restart your editor after adding the config.
> Why @latest? Unlike cached npx packages that never auto-update, @latest ensures you get new features and fixes on each restart. If upgrading from an older config without @latest, also clear your npx cache: rm -rf ~/.npm/_npx
---
| Category | Tools | Description |
| ----------------- | --------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ |
| Search | search-compact, search-typescript, search-docs, fetch-docs | Semantic search + live docs fetching |analyze-contract
| Analysis | , explain-circuit, extract-contract-structure, compile-contract | Static analysis + real compilation |get-file
| Repository | , list-examples, get-latest-updates | Access files and examples |get-version-info
| Versioning | , check-breaking-changes, get-migration-guide, get-file-at-version, compare-syntax, get-latest-syntax | Version tracking and migration |generate-contract
| AI Generation | , review-contract, document-contract | AI-powered code generation _(requires sampling)_ |upgrade-check
| Compound | , get-repo-context | Multi-step operations _(saves 50-70% tokens)_ |health-check
| Health | , get-status, check-version | Server status and version checking |list-tool-categories
| Discovery | , list-category-tools, suggest-tool | Explore available tools and get recommendations |
All tools are prefixed with midnight- (e.g., midnight-search-compact).
The midnight-compile-contract tool validates Compact code using a hosted compiler service:
``
✅ Compilation successful (Compiler v0.18.0) in 2841ms
- Fast mode (skipZk=true): Syntax validation in ~1-2 secondsfullCompile=true
- Full mode (): Complete ZK circuit generation in ~10-30 seconds
- Automatic fallback: Falls back to static analysis if the compiler service is unavailable
This catches semantic errors that static analysis misses (sealed fields, disclose rules, type mismatches).
| Capability | Feature |
| --------------- | ----------------------------------------------- |
| Tools | 28 tools with listChanged notifications |
| Resources | 9 embedded resources with subscription support |
| Prompts | 5 workflow prompts |
| Logging | Client-controllable log level |
| Completions | Autocomplete for prompt arguments |
| Progress | Real-time progress for compound tools |
| Sampling | AI-powered generation (when client supports it) |
Quick references available offline:
- Compact syntax guide (v0.16-0.18)
- SDK API reference
- OpenZeppelin contracts
- Tokenomics overview
- Wallet integration
- Common errors & solutions
extract-contract-structure catches common mistakes before compilation:
| Check | Severity | Description |
| ------------------------- | -------- | ------------------------------------------------------- |
| deprecated_ledger_block | P0 | Catches ledger { } → use export ledger field: Type; |invalid_void_type
| | P0 | Catches Void → use [] (empty tuple) |invalid_pragma_format
| | P0 | Catches old pragma → use >= 0.16 && <= 0.18 |unexported_enum
| | P1 | Enums need export for TypeScript access |module_level_const
| | P0 | Use pure circuit instead |
| + 10 more checks | P1-P2 | Overflow, division, assertions, etc. |
- create-contract — Generate new contractsreview-contract
- — Security and code reviewexplain-concept
- — Learn Midnight conceptscompare-approaches
- — Compare implementation patternsdebug-contract
- — Troubleshoot issues
---
The API indexes 102+ Midnight repositories from the entire Midnight ecosystem:
| Category | Count | Key Repositories |
| ------------------------ | ----- | -------------------------------------------------------------------------------- |
| Compact Language | 6 | compact, compact-lsp, compact-tree-sitter, compact-zed |midnight-js
| SDKs & APIs | 5 | , midnight-sdk, midnight-wallet, midnight-dapp-connector |midnight-node
| Core Infrastructure | 9 | , midnight-indexer, midnight-ledger, midnight-zk |midnight-trusted-setup
| ZK & Cryptography | 6 | , fri, galois_recursion, pluto_eris |midnight-docs
| Documentation | 5 | , midnight-improvement-proposals, midnight-architecture |example-counter
| Examples & Templates | 8 | , example-bboard, example-dex, example-DAO |midnight-did
| Identity | 5 | , midnight-did-resolver, midnight-verifiable-credentials |setup-compact-action
| Developer Tools | 4 | , upload-sarif-github-action, midnight-dev-utils |midnight-solutions
| Solutions & Apps | 7 | , midnight-website-next, nightcap, ocp |midnight-glacier-drop-tools
| Glacier Drop | 15 | , gd-claim-api, gd-claim-portal |
| Partners | 14 | OpenZeppelin, BrickTowers, MeshJS, PaimaStudios, hackathon winners |
| Other | 18+ | Contracts, bridges, token distribution, monitoring, QA tools, community projects |
All non-archived repositories from the midnightntwrk organization plus community partners. See api/README.md for the complete list.
---
Run as an HTTP server for web integrations or remote deployment:
`bash`Start HTTP server on port 3000
npx midnight-mcp --http --port 3000
Endpoints:
- /health - Health check/mcp
- - Streamable HTTP (MCP protocol)/sse
- - Server-Sent Events
`bash
npx midnight-mcp --help
Options:
--stdio Use stdio transport (default, for Claude Desktop)
--http Use HTTP transport with SSE support
--port
--json Output in JSON (default: YAML for better LLM efficiency)
--github-token GitHub token (overrides GITHUB_TOKEN env var)
-h, --help Show help
-v, --version Show version
`
> Why YAML by default? YAML is ~20-30% more token-efficient than JSON, which means AI assistants can process more context from tool responses.
Run everything locally for privacy or offline use:
`json`
{
"mcpServers": {
"midnight": {
"command": "npx",
"args": ["-y", "midnight-mcp@latest"],
"env": {
"MIDNIGHT_LOCAL": "true",
"OPENAI_API_KEY": "sk-...",
"CHROMA_URL": "http://localhost:8000"
}
}
}
}
Requires ChromaDB (docker run -d -p 8000:8000 chromadb/chroma) and OpenAI API key.
Add "GITHUB_TOKEN": "ghp_..." for higher GitHub API rate limits (60 → 5000 requests/hour).
---
`bash``
git clone https://github.com/Olanetsoft/midnight-mcp.git && cd midnight-mcp
npm install && npm run build && npm test
The hosted API runs on Cloudflare Workers + Vectorize. See api/README.md for backend details.
---
- Midnight Docs
- MCP Spec
- Midnight GitHub
MIT
