midnight-mcp
MCP server that gives AI assistants access to Midnight blockchain—search contracts, analyze code, and explore documentation.
README
Midnight MCP Server
MCP server that gives AI assistants access to Midnight blockchain—search contracts, analyze code, and explore documentation.
This project extends the Midnight Network with additional developer tooling.
Requirements
- Node.js 20+ (LTS recommended)
Check your version: node --version
<details> <summary><strong>Using nvm?</strong> Click for Claude Desktop setup</summary>
If you use nvm, Claude Desktop may not see your nvm-managed Node. Use this config instead:
{
"mcpServers": {
"midnight": {
"command": "/bin/sh",
"args": [
"-c",
"source ~/.nvm/nvm.sh && nvm use 20 >/dev/null 2>&1 && npx -y midnight-mcp@latest"
]
}
}
}
</details>
Quick Start
Claude Desktop
Add to your claude_desktop_config.json:
{
"mcpServers": {
"midnight": {
"command": "npx",
"args": ["-y", "midnight-mcp@latest"]
}
}
}
Config file locations:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
Cursor
One-click install:
Or manually add to .cursor/mcp.json:
{
"mcpServers": {
"midnight": {
"command": "npx",
"args": ["-y", "midnight-mcp@latest"]
}
}
}
VS Code Copilot
Add to .vscode/mcp.json or use Command Palette: MCP: Add Server → "command (stdio)" → npx -y midnight-mcp@latest
Windsurf
Add to ~/.codeium/windsurf/mcp_config.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,@latestensures 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
What's Included
29 Tools
| Category | Tools | Description |
|---|---|---|
| Search | search-compact, search-typescript, search-docs, fetch-docs |
Semantic search + live docs fetching |
| Analysis | analyze-contract, explain-circuit, extract-contract-structure, compile-contract |
Static analysis + real compilation |
| Repository | get-file, list-examples, get-latest-updates |
Access files and examples |
| Versioning | get-version-info, check-breaking-changes, get-migration-guide, get-file-at-version, compare-syntax, get-latest-syntax |
Version tracking and migration |
| AI Generation | generate-contract, review-contract, document-contract |
AI-powered code generation (requires sampling) |
| Compound | upgrade-check, get-repo-context |
Multi-step operations (saves 50-70% tokens) |
| Health | health-check, get-status, check-version |
Server status and version checking |
| Discovery | list-tool-categories, list-category-tools, suggest-tool |
Explore available tools and get recommendations |
All tools are prefixed with midnight- (e.g., midnight-search-compact).
Real Contract Compilation
The midnight-compile-contract tool validates Compact code using a hosted compiler service:
✅ Compilation successful (Compiler v0.29.0) in 2841ms
- Fast mode (
skipZk=true): Syntax validation in ~1-2 seconds - Full mode (
fullCompile=true): 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).
MCP Capabilities
| Capability | Feature |
|---|---|
| Tools | 29 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) |
9 Embedded Resources
Quick references available offline:
- Compact syntax guide (v0.16-0.21)
- SDK API reference
- OpenZeppelin contracts
- Tokenomics overview
- Wallet integration
- Common errors & solutions
Static Analysis
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.21 |
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. |
5 Prompts
create-contract— Generate new contractsreview-contract— Security and code reviewexplain-concept— Learn Midnight conceptscompare-approaches— Compare implementation patternsdebug-contract— Troubleshoot issues
Indexed Repositories
The API indexes 115+ Midnight repositories from the entire Midnight ecosystem:
| Category | Count | Key Repositories |
|---|---|---|
| Compact Language | 6 | compact, compact-lsp, compact-tree-sitter, compact-zed |
| SDKs & APIs | 5 | midnight-js, midnight-sdk, midnight-wallet, midnight-dapp-connector |
| Core Infrastructure | 9 | midnight-node, midnight-indexer, midnight-ledger, midnight-zk |
| ZK & Cryptography | 6 | midnight-trusted-setup, fri, galois_recursion, pluto_eris |
| Documentation | 5 | midnight-docs, midnight-improvement-proposals, midnight-architecture |
| Examples & Templates | 18 | example-counter, example-bboard, example-kitties, example-zkloan |
| Identity | 5 | midnight-did, midnight-did-resolver, midnight-verifiable-credentials |
| Developer Tools | 5 | setup-compact-action, midnight-dev-utils, midnight-local-dev |
| Solutions & Apps | 7 | midnight-solutions, midnight-website-next, nightcap, ocp |
| Glacier Drop | 15 | midnight-glacier-drop-tools, gd-claim-api, gd-claim-portal |
| Partners & Community | 20 | OpenZeppelin, BrickTowers, MeshJS, PaimaStudios, hackathon winners, Olanetsoft |
| 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.
Advanced Configuration
HTTP Mode
Run as an HTTP server for web integrations or remote deployment:
# 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
CLI Options
npx midnight-mcp --help
Options:
--stdio Use stdio transport (default, for Claude Desktop)
--http Use HTTP transport with SSE support
--port <number> HTTP port (default: 3000)
--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.
Local Mode
Run everything locally for privacy or offline use:
{
"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.
GitHub Token
Add "GITHUB_TOKEN": "ghp_..." for higher GitHub API rate limits (60 → 5000 requests/hour).
Developer Setup
git clone https://github.com/Olanetsoft/midnight-mcp.git && cd midnight-mcp
npm install && npm run build && npm test
# Lint & format
npm run lint # ESLint (typescript-eslint)
npm run lint:fix # Auto-fix lint issues
npm run format # Prettier
The hosted API runs on Cloudflare Workers + Vectorize. See api/README.md for backend details.
Links
License
MIT
Stargazers ⭐️
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。