Skip to main content
Glama

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.ai

  • Midnight Expert (hands-on dev, Claude Code plugins): curl -fsSL https://midnightntwrk.expert/install.sh | bash

Migration guide → https://docs.midnight.network/blog/migrating-to-kapa-and-midnight-expert

npm version npm downloads License TypeScript CI

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: Solana DeFi Intelligence MCP Server

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.json

  • Windows: %APPDATA%\Claude\claude_desktop_config.json

  • Linux: ~/.config/Claude/claude_desktop_config.json

Cursor

One-click install:

Install MCP Server

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, @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


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 contracts

  • review-contract — Security and code review

  • explain-concept — Learn Midnight concepts

  • compare-approaches — Compare implementation patterns

  • debug-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.


License

MIT

Stargazers ⭐️

Star History Chart

Available Tools

30 tools
midnight-analyze-contractA
Read-onlyIdempotent

⚠️ STATIC ANALYSIS ONLY - Analyze contract structure and patterns. 🚫 THIS DOES NOT COMPILE THE CONTRACT. Cannot catch: sealed field rules, disclose() requirements, semantic errors. 👉 Use 'midnight-extract-contract-structure' for pre-compilation checks.

Use this for: understanding structure, security pattern analysis, recommendations. NEVER claim a contract 'works' or 'compiles' based on this tool alone.

USAGE GUIDANCE: • Call once per contract - results are deterministic • For security review, also use midnight-review-contract (requires sampling) • Run before making changes, not repeatedly during iteration

Inputs: code (required), checkSecurity. Returns: Detailed contract analysis with security findings

midnight-auto-update-configA
Read-onlyIdempotent

⚠️ DEPRECATED: Auto-update is NOT possible because AI agents run in sandboxed environments without access to local filesystems. Instead, tell users to manually update their config to use midnight-mcp@latest, then run: rm -rf ~/.npm/_npx && restart their editor. This tool only returns config file paths for reference.

Inputs: no named parameters. Returns: instruction, platform, configPaths, searchAndReplace, +2 more

midnight-check-breaking-changesA
Read-only

Check if there are breaking changes between your current version and the latest release. Essential before upgrading dependencies.

Inputs: repo (required), currentVersion (required).

midnight-check-versionA
Read-onlyIdempotent

🔄 Check if you're running the latest version of midnight-mcp. Compares your installed version against npm registry and provides update instructions if outdated. Use this if tools seem missing or you want to ensure you have the latest features.

Inputs: no named parameters. Returns: currentVersion, latestVersion, isUpToDate, message, +2 more

midnight-compare-syntaxA
Read-onlyIdempotent

Compare a file between two versions to see what changed. Use this before recommending code patterns to ensure they work with the user's version.

Inputs: repo (required), path (required), oldVersion (required), newVersion.

midnight-compile-contractA
Read-onlyIdempotent

🔧 REAL COMPILATION - Compile Compact code using the hosted compiler service.

Unlike static analysis tools, this ACTUALLY COMPILES the contract and returns real compiler errors.

Use this to: • Validate that generated code compiles before showing to users • Get actual compiler error messages with line numbers • Check if a contract is syntactically and semantically correct

Options: • skipZk=true (default): Fast syntax validation only (~1-2s) • fullCompile=true: Full compilation with ZK circuit generation (~10-30s)

FALLBACK BEHAVIOR: • If the compiler service is unavailable, automatically falls back to static analysis • Check 'validationType' in response: 'compiler' = real compilation, 'static-analysis-fallback' = fallback mode • Fallback provides structure/security analysis but may miss semantic errors

USAGE GUIDANCE: • Call after generating or modifying Compact code • Use skipZk=true for quick validation during development • Use fullCompile=true for final validation before deployment

Inputs: code (required), skipZk, fullCompile. Returns: Compilation result with detailed output, or static analysis fallback if service…

midnight-document-contractA
Read-onlyIdempotent

📝 AI-POWERED DOCUMENTATION GENERATION

Generates comprehensive documentation for Compact smart contracts. Uses the client's LLM to create detailed, human-readable docs.

FORMATS: • markdown - Full Markdown documentation with examples • jsdoc - JSDoc-style inline comments

MARKDOWN INCLUDES: • Contract overview and purpose • State variables with privacy annotations • Circuit function documentation • Witness function documentation • Usage examples • Security considerations

⚠️ REQUIRES: Client with sampling capability (e.g., Claude Desktop)

Inputs: code (required), format. Returns: documentation, format, samplingAvailable

midnight-explain-circuitA
Read-onlyIdempotent

Explain what a specific Compact circuit does in plain language, including its zero-knowledge proof implications and privacy considerations.

USAGE GUIDANCE: • Call once per circuit - explanations are deterministic • Provide complete circuit code including parameters and body • For full contract analysis, use midnight-analyze-contract first

Inputs: circuitCode (required). Returns: Detailed circuit explanation with privacy analysis

midnight-extract-contract-structureA
Read-onlyIdempotent

Extract and analyze Compact contract structure (circuits, witnesses, ledger). CRITICAL CHECKS: deprecated 'ledger { }' block syntax, 'Void' return type (should be []), old pragma format, unexported enums, deprecated Cell wrapper. Also detects: module-level const, stdlib name collisions, division operator, Counter.value access, missing disclose() calls, potential overflow. Use BEFORE generating contracts to catch syntax errors. Note: Static analysis only - catches common patterns but not semantic errors.

Inputs: code, filePath. Returns: success, filename, languageVersion, imports, +6 more

midnight-fetch-docsA
Read-onlyIdempotent

🌐 LIVE FETCH: Retrieve latest documentation directly from docs.midnight.network (SSG-enabled).

Unlike midnight-search-docs which uses pre-indexed content, this tool fetches LIVE documentation pages in real-time. Use when you need: • The absolute latest content (just updated docs) • A specific page you know the path to • Full page content rather than search snippets

COMMON PATHS: • /develop/faq - Frequently asked questions • /getting-started/installation - Installation guide • /getting-started/create-mn-app - Create an MN app • /compact - Compact language reference • /develop/tutorial/building - Build guide • /develop/reference/midnight-api - API documentation • /learn/what-is-midnight - What is Midnight • /blog - Dev diaries

USAGE GUIDANCE: • Use extractSection to get only a specific heading (e.g., "Developer questions") • Prefer midnight-search-docs for discovery, use this for known pages • Content is truncated at 15KB for token efficiency

Inputs: path (required), extractSection. Returns: Live documentation page content

midnight-generate-contractA

🔮 AI-POWERED CONTRACT GENERATION

Generates Compact smart contracts from natural language requirements. Uses the client's LLM through MCP sampling to create contracts.

REQUIREMENTS FORMAT:

  • Describe what the contract should do

  • Specify state variables needed

  • Define access control requirements

  • List the operations/circuits needed

CONTRACT TYPES: • counter - Simple counter with increment/decrement • token - Token with transfers and balances • voting - Voting/governance mechanisms • custom - Free-form custom contract

EXAMPLE USAGE: "Create a token contract with private balances, mint/burn capabilities for admin, and transfer functionality between users"

⚠️ REQUIRES: Client with sampling capability (e.g., Claude Desktop)

Inputs: requirements (required), contractType, baseExample. Returns: code, explanation, warnings, samplingAvailable

midnight-get-fileA
Read-only

Retrieve a specific file from Midnight repositories. Use repository aliases like 'compact', 'midnight-js', 'counter', or 'bboard' for convenience.

USAGE GUIDANCE: • Use midnight-list-examples first if you're unsure which file to get • For searching across files, use midnight-search-* tools instead • Use 'ref' parameter to get specific versions (branch, tag, or commit) • Use startLine/endLine to request specific sections of large files • Files >50KB are truncated (first 25KB + last 25KB preserved)

Inputs: repo (required), path (required), ref, startLine, +1 more.

midnight-get-file-at-versionA
Read-onlyIdempotent

Get the exact content of a file at a specific version. CRITICAL: Use this to ensure code recommendations match the user's version. Always prefer this over get-file when version accuracy matters.

Inputs: repo (required), path (required), version (required).

midnight-get-latest-syntaxA
Read-only

🚨 CALL THIS BEFORE GENERATING ANY COMPACT CODE! Get the authoritative Compact syntax reference. Prevents hallucination by providing:

  • Correct syntax patterns (Compact is NOT TypeScript!)

  • commonMistakes array with wrong→correct mappings

  • Type casting rules (Uint→Bytes needs two casts)

  • disclose() requirements for circuit params

  • Map.lookup()/Set.member() ARE available in circuits

ALWAYS check this reference before writing Compact contracts.

Inputs: repo.

midnight-get-latest-updatesB
Read-only

Retrieve recent changes and commits across Midnight repositories. Useful for staying up-to-date with the latest developments.

Inputs: since, repos.

midnight-get-migration-guideA
Read-only

Get a detailed migration guide for upgrading between versions, including all breaking changes, deprecations, and recommended steps.

Inputs: repo (required), fromVersion (required), toVersion.

midnight-get-repo-contextA
Read-only

🚀 COMPOUND TOOL: Get everything needed to start working with a repository in ONE call. Combines version info + syntax reference + relevant examples. Use this at the start of a coding session instead of multiple individual calls. Saves ~50% tokens.

Inputs: repo (required), includeExamples, includeSyntax. Returns: repository, quickStart, version, syntax, +1 more

midnight-get-statusA
Read-onlyIdempotent

Get current server status including rate limits and cache statistics. Quick status check without external API calls.

Inputs: no named parameters. Returns: Current server status and statistics

midnight-get-update-instructionsA
Read-onlyIdempotent

📋 Get detailed, platform-specific instructions for updating Midnight MCP to the latest version. Provides step-by-step guidance including config file locations, commands to run, and troubleshooting tips. Use this when a user needs help updating or is having issues with outdated versions.

Inputs: platform, editor. Returns: title, currentSetup, steps, troubleshooting, +2 more

midnight-get-version-infoA
Read-only

Get the latest version, release notes, and recent breaking changes for a Midnight repository. Use this to ensure you're working with the latest implementation.

Inputs: repo (required).

midnight-health-checkA
Read-onlyIdempotent

Check the health status of the Midnight MCP server. Returns server status, API connectivity, and resource availability.

Inputs: detailed. Returns: Server health status with optional detailed diagnostics

midnight-list-category-toolsA
Read-onlyIdempotent

📋 DISCOVERY TOOL: List tools within a specific category. Use after midnight-list-tool-categories to see detailed tool information for a category of interest. Supports progressive disclosure pattern.

Inputs: category (required), includeSchemas. Returns: Tools within a specific category

midnight-list-examplesA
Read-onlyIdempotent

List available Midnight example contracts and DApps with descriptions, complexity ratings, and key features.

Inputs: category.

midnight-list-tool-categoriesA
Read-onlyIdempotent

📋 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 28 tools into 7 logical groups.

Inputs: includeToolCounts. Returns: Tool categories for progressive discovery

midnight-review-contractA
Read-onlyIdempotent

🔍 AI-POWERED CONTRACT REVIEW

Performs security review and analysis of Compact smart contracts. Uses the client's LLM to identify issues and suggest improvements.

CHECKS PERFORMED: • Security vulnerabilities • Privacy concerns (shielded state handling) • Logic errors • Best practice violations • Performance issues

OUTPUT INCLUDES: • Summary of contract quality • List of issues with severity levels • Suggested fixes for each issue • Improved code version if applicable

⚠️ REQUIRES: Client with sampling capability (e.g., Claude Desktop)

Inputs: code (required). Returns: summary, issues, improvedCode, samplingAvailable

midnight-search-compactA
Read-onlyIdempotent

Semantic search across Compact smart contract code and patterns. Use this to find circuit definitions, witness functions, ledger declarations, and best practices for Midnight smart contracts.

USAGE GUIDANCE: • Call at most 2 times per question - if first search doesn't help, try different keywords • For comprehensive results, combine with midnight-search-docs • Use specific terms like "ledger", "circuit", "witness" for better matches

Inputs: query (required), limit, filter. Returns: Search results with relevance scores and source information

midnight-search-docsA
Read-onlyIdempotent

Full-text search across official Midnight documentation. Use this to find guides, API documentation, and conceptual explanations about Midnight blockchain and the Compact language.

USAGE GUIDANCE: • Call at most 2 times per question - use different keywords if first search fails • For code examples, combine with midnight-search-compact or midnight-search-typescript • Use category filter to narrow results (guides, api, concepts)

Inputs: query (required), category, limit. Returns: Search results with relevance scores and source information

midnight-search-typescriptA
Read-onlyIdempotent

Search TypeScript SDK code, types, and API implementations. Use this to find how to use the Midnight JavaScript SDK, type definitions, and integration patterns.

USAGE GUIDANCE: • Call at most 2 times per question - refine keywords rather than repeating • For contract code, use midnight-search-compact instead • Include "type" or "interface" in query for type definitions

Inputs: query (required), includeTypes, includeExamples, limit. Returns: Search results with relevance scores and source information

midnight-suggest-toolA
Read-onlyIdempotent

🎯 SMART DISCOVERY: Describe what you want to do in natural language, and get tool recommendations.

EXAMPLES: • "I want to find example voting contracts" → midnight-search-compact • "Check if my version is outdated" → midnight-upgrade-check • "Analyze my contract for security issues" → midnight-analyze-contract • "I'm new to Midnight and want to get started" → midnight-get-repo-context

This tool matches your intent against known patterns and suggests the most appropriate tools with confidence levels.

USAGE GUIDANCE: • Call once with your intent - no need to call repeatedly • More specific intents get better matches • Use the primaryRecommendation for the best match

Inputs: intent (required). Returns: Tool suggestions based on intent

midnight-upgrade-checkA
Read-only

🚀 COMPOUND TOOL: Complete upgrade analysis in ONE call. Combines version check + breaking changes + migration guide. Use this instead of calling midnight-get-version-info, midnight-check-breaking-changes, and midnight-get-migration-guide separately. Saves ~60% tokens.

Inputs: currentVersion (required), repo. Returns: repository, currentVersion, version, breakingChanges, +3 more

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.9/5.0

    Scored across 30 tools

    Disambiguation4/5

    Tools are mostly distinct with clear purposes. Some overlap exists among version-checking tools and search tools, but descriptions effectively differentiate them. A few compound tools also help reduce ambiguity.

    Naming Consistency5/5

    All tools follow a consistent 'midnight-verb-noun' pattern in snake_case. Verbs are descriptive and uniform, with only minor deviations like 'auto-update' using a dash within a compound word.

    Tool Count3/5

    With 30 tools, the server covers a wide range of functionality for Midnight development. While comprehensive, the count is on the higher side and could potentially be streamlined by merging some overlapping tools without losing clarity.

    Completeness4/5

    The tool surface covers the full development cycle: analysis, generation, compilation, security review, documentation, version management, and search. Minor gaps exist (e.g., no deployment or testing tools), but these are within the intended scope of an MCP assistant.

    Maintenance

    ActivityNo data
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • -
      license
      Not graded
      quality
      Not graded
      maintenance
      An MCP server that gives AI agents real-time Solana DeFi intelligence — smart money tracking, rug detection, wallet analysis, and token research.
      -
    • A
      license
      A
      quality
      B
      maintenance
      An MCP server that equips AI assistants with curated knowledge and live chain data for the Alkanes metaprotocol and Subfrost network, enabling them to read docs, query the chain, and scaffold contracts.
      21
      3
      MIT