midnight-mcp
The Midnight MCP server gives AI assistants tools to search, analyze, compile, generate, and manage Midnight blockchain contracts, SDKs, and documentation.
🔍 Search & Discovery
Search Compact smart contract code, TypeScript SDK, and official documentation semantically
Fetch live documentation directly from
docs.midnight.networkExplore 115+ indexed Midnight repositories
🔧 Contract Analysis & Compilation
Static analysis of contract structure, security patterns, and common syntax errors (
analyze-contract,extract-contract-structure)Plain-language explanations of Compact circuits, including ZK proof and privacy implications (
explain-circuit)Real compilation via a hosted service: fast syntax validation (~1–2s) or full ZK circuit generation (~10–30s), with fallback to static analysis (
compile-contract)
🤖 AI-Powered Generation (requires client sampling)
Generate Compact smart contracts from natural language requirements (
generate-contract)Security review for vulnerabilities, logic errors, and best practices (
review-contract)Generate Markdown or JSDoc documentation for contracts (
document-contract)
📁 Repository Access
Retrieve specific files from Midnight repositories, optionally at a specific version or line range (
get-file,get-file-at-version)Browse example contracts and DApps with complexity ratings (
list-examples)Get recent commits and changes across repositories (
get-latest-updates)
📦 Version & Migration
Get version info, release notes, and breaking changes (
get-version-info,check-breaking-changes)Obtain step-by-step migration guides between versions (
get-migration-guide)Diff files between versions and get an authoritative Compact syntax reference to prevent hallucinations (
compare-syntax,get-latest-syntax)
⚡ Compound Tools (token-efficient)
Combined version check + breaking changes + migration guide in one call, ~60% token savings (
upgrade-check)Version info + syntax reference + examples in one call for starting a coding session, ~50% token savings (
get-repo-context)
🩺 Health & Status
Monitor server health, API connectivity, rate limits, and cache statistics (
health-check,get-status)Check if the installed midnight-mcp is up to date against the npm registry (
check-version)
🧭 Tool Discovery
Browse 7 logical tool categories and their tools (
list-tool-categories,list-category-tools)Describe your intent in natural language and get tool recommendations (
suggest-tool)
Provides embedded resources with OpenZeppelin contract templates and documentation for use in Midnight smart contract development.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@midnight-mcpsearch for compact contracts"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Midnight MCP Server
⚠️ Deprecated — use Kapa + Midnight Expert
midnight-mcp is being wound down. Midnight has standardised on two official tools:
Kapa MCP (docs Q&A / search):
claude mcp add --transport http midnight https://midnight.mcp.kapa.aiMidnight Expert (hands-on dev, Claude Code plugins):
curl -fsSL https://midnightntwrk.expert/install.sh | bashMigration guide → https://docs.midnight.network/blog/migrating-to-kapa-and-midnight-expert
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.
Related MCP server: Aindreyway MCP Codex Keeper
Requirements
Node.js 20+ (LTS recommended)
Check your version: node --version
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"
]
}
}
}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.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.jsonLinux:
~/.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 |
| Semantic search + live docs fetching |
Analysis |
| Static analysis + real compilation |
Repository |
| Access files and examples |
Versioning |
| Version tracking and migration |
AI Generation |
| AI-powered code generation (requires sampling) |
Compound |
| Multi-step operations (saves 50-70% tokens) |
Health |
| Server status and version checking |
Discovery |
| 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 2841msFast mode (
skipZk=true): Syntax validation in ~1-2 secondsFull mode (
fullCompile=true): Complete ZK circuit generation in ~10-30 secondsAutomatic 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 |
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 |
| P0 | Catches |
| P0 | Catches |
| P0 | Catches old pragma → use |
| P1 | Enums need |
| P0 | Use |
+ 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 |
|
SDKs & APIs | 5 |
|
Core Infrastructure | 9 |
|
ZK & Cryptography | 6 |
|
Documentation | 5 |
|
Examples & Templates | 18 |
|
Identity | 5 |
|
Developer Tools | 5 |
|
Solutions & Apps | 7 |
|
Glacier Drop | 15 |
|
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 3000Endpoints:
/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 versionWhy 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 # PrettierThe hosted API runs on Cloudflare Workers + Vectorize. See api/README.md for backend details.
Links
License
MIT
Stargazers ⭐️
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Olanetsoft/midnight-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server