midnight-cast

io.github.Kanasjnr由 GitHub 账号 Kanasjnr 发布v0.2.2更新于 Nov 8, 2026

Read-only tools for live Midnight networks: health, transactions, DUST, errors and example code

概览

AI 生成的概览

面向 Midnight 实时网络的只读 MCP 服务器:检查节点、索引器与证明服务器健康状态,查看交易、合约与 DUST,解码错误并获取官方示例代码。

可以做什么
  • 检查网络健康状况、探测各服务、比较节点与索引器高度,并对照支持矩阵核对版本
  • 在首笔交易前预检网络、证明服务器与钱包是否就绪
  • 读取区块头,查询交易、已部署合约、DUST 状态与 DUST 事件流
  • 解码 Midnight 错误消息与错误码,并获取 DUST、同步、版本等主题的背景说明
  • 按主题查找 Midnight 官方示例中的可用代码
适用场景
适合在协助 Midnight 开发时使用:需要了解 preview、preprod 或 mainnet 的实时状态、某个具体错误的含义,或找到官方示例代码。它是诊断与查询工具,不是钱包或应用脚手架。
运行要求
以 stdio 在本地运行,通常通过 npx 或全局 npm 安装;需要 Node.js 20 以上(建议 22 以上)或独立二进制文件。preview 网络无需凭据。preprod 与 mainnet 经由 Blockfrost,需要为每个网络申请免费项目 ID,分别通过 BLOCKFROST_PREPROD_PROJECT_ID 和 BLOCKFROST_MAINNET_PROJECT_ID 提供。需要网络访问;可用 MIDNIGHT_CAST_NETWORKS 限制可查询的网络。
安装前请注意
所有工具均为只读,无需钱包、密钥或助记词。唯一的机密是可选的 Blockfrost 项目 ID,仅发送给 Blockfrost 并在响应中被隐去。访问网络的工具默认有速率限制,避免循环调用的智能体耗尽公共端点或 Blockfrost 配额。CLI 的原始 rpc 命令并未作为 MCP 工具提供。

安装

在 SourceWeft 中

  1. 打开 控制台中的 midnight-cast,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

midnight-cast

[!NOTE] This project extends the Midnight Network with additional developer tooling.

Read-only CLI and MCP server for the Midnight networks: network health, error decoding, transactions, contracts, DUST, and working code from Midnight's official examples. Think Foundry cast for Midnight, not a wallet or app scaffold.

bash
npx midnight-cast@latest health preview# or: npm i -g midnight-cast@latest && midnight-cast health preview

Preview needs nothing else. Preprod and mainnet go through Blockfrost and need a free project ID for each; see Quick start.

Note: midnight-cast also installs a short alias, mn, which runs the same commands. Other global CLIs (e.g. @mermaid-js/mermaid-cli, midnight-wallet-cli) install an mn too, so these docs, the hints and the JSON output always say midnight-cast.

bash
midnight-cast health preview

Or step by step: midnight-cast ping preview && midnight-cast tip preview && midnight-cast versions preview

Requires Node.js 20+ (22+ recommended). Without Node.js, the release binaries install the same commands after checking the checksum:

bash
curl -fsSL https://github.com/Kanasjnr/midnight-cast/releases/latest/download/install.sh | sh

On Windows, in PowerShell: irm https://github.com/Kanasjnr/midnight-cast/releases/latest/download/install.ps1 | iex. Where there's no curl, wget -qO- <same URL> | sh works too. Alpine needs libstdc++ and libgcc first (apk add libstdc++ libgcc). MIDNIGHT_CAST_VERSION=0.2.0 pins a release and MIDNIGHT_CAST_INSTALL_DIR picks the directory (default ~/.local/bin). Each archive carries build provenance: gh attestation verify <archive> --repo Kanasjnr/midnight-cast.

Key capabilities

  • Read RPC, indexer, and proof-server health, and whether Midnight's own examples pass on the node a network runs
  • Compare live stack signals and a project's Midnight packages with the support matrix
  • Decode ledger, pallet, Substrate 1010, and JSON-RPC errors, and messages from current tooling and Blockfrost
  • Check a network, proof server and wallet are ready before the first transaction (preflight)
  • Inspect transactions, deployed contracts, DUST generation and DUST event streams
  • Find working code in Midnight's official examples for a topic in your own words (examples)
  • Serve all of it to AI agents as a read-only MCP server, with guidance for Claude Code, Codex, Gemini CLI, Cursor and others
  • Query block headers and raw JSON-RPC without writing scripts
  • Run without Node.js from a standalone binary

What it does

AreaCommands
Healthhealth, ping, tip, versions, preflight
Chainblock latest, block <height>, rpc
Errorsdecode (ledger, pallet, 1010, jsonrpc, --raw)
Indexertx, contract, dust-status, dust-event, dust-events
Working code and backgroundexamples, explain (dust, 1010, versions, transcript, sync)
Agentsmcp, agents init
Configconfig init, config show

No wallet keys. No signing or proving.

Common workflows

Is the network healthy?

bash
midnight-cast health preprod

Example output:

text
Network: preprodHealthy: yes
Services:  rpc: OK (668ms)  indexer: OK (1215ms)  proof-server: OK (1053ms) (optional) — version=8.1.0 (matches matrix 8.1.0)
Sync:  RPC height:      2805470  Indexer height:  2805468  Delta:           2 (threshold 100)  In sync:         yes

Why did my tx fail?

bash
midnight-cast tx <hash> --network preprodmidnight-cast decode --raw "<wallet-or-node-error>"

Example output:

text
Type:     RegularTransactionID:       232830Hash:     e5c86fcd43eb9707e8f23d940e59a6c12ca7ad3ca7e9d2f1232843cc62de1b8cBlock:    909000 (428660a6154a27cee57af3527cb3370ad3bbce94f461f433533b1413e24b71f4)Protocol: 22000Status:   PARTIAL_SUCCESSFees:     paid=1Segments: 0:ok, 20003:ok, 35012:failFailure:  indexer v4 exposes segment success only (no failure reason)Hint:     paste wallet/node error → midnight-cast decode --raw "<error>"Actions:  ContractCallDUST:     665110:DustSpendProcessed          → midnight-cast dust-event 665110

Is my local stack aligned with the network?

bash
midnight-cast versions preprod

Example output:

text
Checks:  node: expected=>=1.0.400 live=1.0.400 → OK (recommended 1.0.400)  runtimeSpec: expected=1000300 live=1000300 → OK (node runtime spec_version vs matrix)  indexer-api: expected=v4 live=v4 → OK (from configured indexer URL path)  protocolVersion: expected=1000300 live=1000300 → OK (RPC specVersion vs indexer latest block)  proof-server: expected=8.1.0 live=8.1.0 → OK (GET /version on configured proof server URL)
Summary: live stack matches matrix checks ✓

Quick start

bash
npm i -g midnight-cast          # or: npx midnight-cast …midnight-cast config init                  # ~/.config/midnight-cast/config.tomlmidnight-cast health previewmidnight-cast decode 170midnight-cast examples "dust sponsorship"

Networks: preview, preprod, mainnet, local — use --network or MN_NETWORK.

Preprod and mainnet go through Blockfrost, since Midnight retired its hosted preprod and mainnet endpoints (mainnet on 30 September 2026, preprod on 9 October). Blockfrost project IDs are per network: create a free Midnight Preprod project, a Midnight Mainnet one, or both, on blockfrost.io, then:

bash
export BLOCKFROST_PREPROD_PROJECT_ID=<your Midnight Preprod project ID>export BLOCKFROST_MAINNET_PROJECT_ID=nightmainnet...npx midnight-cast health preprod

Preview is still hosted by Midnight and needs no project ID. The project IDs are never printed. See docs/COMMANDS.md.

Debug ladder

When something breaks, run these in order:

  1. midnight-cast health — ping + sync + versions in one shot (preflight --address <wallet> before a first transaction)
  2. midnight-cast ping — services up?
  3. midnight-cast tip — indexer synced?
  4. midnight-cast versions — stack matches support matrix?
  5. midnight-cast decode — what does the error mean?
  6. midnight-cast tx — what happened on chain?

Common one-liners

bash
midnight-cast health preprod --jsonmidnight-cast ping preprodmidnight-cast versions preprodmidnight-cast decode --raw "1010: Invalid Transaction: Custom error: 186"midnight-cast decode 179 --network preview          # ledger map stamped per networkmidnight-cast tx <hash> --network preprod           # status, fees, segments; links dust-event idsmidnight-cast block 909000 preprod                  # header at height (+ hash)midnight-cast dust-events --from 565900 --limit 10 --network preprodmidnight-cast rpc chain_getHeader --jsonmidnight-cast versions preprod --fail-on-mismatch   # CI; local Midnight packages (either npm scope) vs matrix pinsmidnight-cast preflight preprod --address mn_addr_preprod1…   # ready for a first transaction?midnight-cast contract <address> preprod            # latest action, circuit, deploy block, balancesmidnight-cast examples "send shielded tokens"       # working code from Midnight's official examplesmidnight-cast explain sync                          # why a first wallet sync takes so long

Using with AI agents

An agent working on a Midnight project needs to know what the network is doing right now, what an error means, and what working code looks like. midnight-cast answers all three from live data and Midnight's own sources, in a form an agent can parse, and its MCP server can't change anything.

It sits next to two other sources an agent may already have. The Kapa answer engine answers questions from Midnight's documentation and examples. Midnight Expert gives agents skills and MCP tools for writing and verifying Compact and SDK code. midnight-cast is the part neither covers: the live state of preview, preprod and mainnet, the meaning of a specific error code on the ledger the network runs, whether a project's versions match the network, and which of Midnight's official examples shows a pattern.

The JSON contract

Add --json to any command for one stable envelope: ok, data, a structured error with a kind and hint, any warnings, and next, the follow-up commands an expert would run. midnight-cast explain --json describes every command, option, exit code and error kind in one call, and schemas/ has a JSON Schema for each command's output. Exit codes are 0 for success, 1 for a failed check and 2 for a usage error. See JSON output.

bash
midnight-cast decode --raw "1010: Invalid Transaction: Custom error: 186" --jsonmidnight-cast explain --json

The MCP server

Agents that speak MCP can use midnight-cast directly: midnight-cast mcp runs an MCP server on stdio with 14 tools, health, preflight, ping, tip, versions, block, tx, dust_event, dust_events, contract, dust_status, decode, explain and examples, each returning the same envelope. For example, in Claude Code:

bash
claude mcp add --transport stdio midnight-cast -- npx -y midnight-cast mcp

A sandbox or CI image without Node.js can run the same server from the standalone binary: midnight-cast mcp.

What an agent can and can't do with it

  • Every MCP tool only reads, and each is marked read-only to the client. None signs or submits a transaction, and none needs a wallet, a key or a seed. The CLI's rpc command, which passes any JSON-RPC method to a node, isn't an MCP tool.
  • MIDNIGHT_CAST_NETWORKS limits which networks the model may query, for example preview,preprod.
  • Tools that reach a network are rate limited, 30 calls a minute by default (MIDNIGHT_CAST_MAX_CALLS_PER_MINUTE), so a looping agent can't exhaust public endpoints or a Blockfrost plan.
  • The only secrets it holds are optional Blockfrost project IDs for preprod and mainnet. They're sent only to Blockfrost and redacted from every response, so the model never sees them.
  • decode, explain and examples work offline from data bundled with the release.

Guidance, skill and plugin

To teach a coding agent when and how to use midnight-cast, add the guidance to your project: midnight-cast agents init --write appends a marked section to AGENTS.md (read by Codex, Cursor, Copilot, Gemini CLI, Windsurf, Aider and others; use --file CLAUDE.md for Claude Code), or install the portable skill with npx skills add Kanasjnr/midnight-cast --skill midnight-cast. The snippets are in docs/agents.

In Claude Code, one plugin installs the skill, the MCP server and a /midnight-cast:diagnose <network> [tx or error] command. When the plugin is enabled, Claude Code asks for optional Blockfrost project IDs for preprod and mainnet and keeps them in secure storage; left empty, an exported BLOCKFROST_PREPROD_PROJECT_ID or BLOCKFROST_MAINNET_PROJECT_ID is used. If you added the server with claude mcp add before, remove it with claude mcp remove midnight-cast so only the plugin's server runs:

bash
claude plugin marketplace add Kanasjnr/midnight-castclaude plugin install midnight-cast@midnight-cast

docs/MCP.md has the setup for Codex, Gemini CLI, Cursor, VS Code and others, the network allow-list, and how the Blockfrost project ID stays out of the model's sight.

Community & support

NeedWhere
Midnight errors, network issues, dev questionsMidnight Discord
midnight-cast bug or something not workingGitHub Issues
New command or feature ideaGitHub Issues (feature request)

midnight-cast decode --raw "…" auto-detects 1010 envelopes, Custom(N), ledger error names, pallet module errors, and JSON-RPC codes from one pasted error. Use --network so the ledger map matches preview vs preprod. Pallet Transaction hints point to inner Custom(N), and codes 179–181 show grouped transcript context. For missing codes or protocol questions, use Discord and the Midnight docs.

Documentation

Cast ↔ midnight-cast

cast block  →  midnight-cast block latest | midnight-cast block <height>cast rpc    →  midnight-cast rpccast logs   →  midnight-cast dust-eventscast 4byte  →  midnight-cast decodecast send   →  wallet / Lace (not midnight-cast)doctor      →  midnight-cast health

Development

bash
git clone https://github.com/Kanasjnr/midnight-cast.gitcd midnight-cast && npm install && npm run buildnpm link                        # global midnight-castnpm run cli -- decode 170       # without linknpm testBLOCKFROST_PREPROD_PROJECT_ID=<id> INTEGRATION=1 npm run test:integration   # live tests; mainnet ones also need BLOCKFROST_MAINNET_PROJECT_ID

License

Apache-2.0

来源:README.md,提交 2b05741

工具

14

health

midnight-cast health

Full check of a Midnight network: RPC and indexer reachability, indexer sync against the node, and live versions against the support matrix. data.examples says whether Midnight's own examples pass on the node the network runs. Start here when something might be wrong with the network rather than the user's code.

输入参数network必填threshold

preflight

midnight-cast preflight

Check that a network, its proof server and optionally a wallet are ready before the first transaction: the network answers and is in sync, the proof server answers at the expected version, and the wallet holds NIGHT registered for DUST generation. data.expectations quotes how long wallet sync and restore took in Midnight's examples run, so a long first sync isn't mistaken for a hang.

输入参数addressnetwork必填

ping

midnight-cast ping

Check whether the network's RPC node, indexer and proof server answer, with latency and a classified error kind for each failure.

输入参数network必填

tip

midnight-cast tip

Compare the node's latest block height with the indexer's, to see whether the indexer is behind.

输入参数network必填threshold

versions

midnight-cast versions

Compare the network's live node, runtime, indexer API and proof server with Midnight's support matrix, and a project's Midnight packages (package.json and package-lock.json) with the matrix pins. data.localProject says which directory was checked and whether it had a package.json, and data.examples whether Midnight's own examples pass on the node the network runs.

输入参数network必填projectDircheckLocalPackages

block

midnight-cast block

Read a block header: the latest one, or the block at a height.

输入参数heightnetwork必填

tx

midnight-cast tx

Look up a transaction on the indexer: status, segments, fees, contract actions and the DUST and Zswap events it produced.

输入参数byhash必填network必填

dust_event

midnight-cast dust-event

Read one DUST ledger event by id from the indexer subscription.

输入参数id必填network必填

dust_events

midnight-cast dust-events

Read DUST ledger events from the indexer: the latest ones, or a run starting at an id.

输入参数fromlimitnetwork必填

contract

midnight-cast contract

Look up a deployed contract by address: whether it exists, its latest action (deploy, call or update) and the circuit a call ran, the deploy transaction and block (not reported after an update), unshielded balances, and the state's size and sha256.

输入参数address必填network必填includeState

dust_status

midnight-cast dust-status

DUST generation for Cardano reward addresses: whether each is registered, its NIGHT balance, generation rate, and current and maximum DUST capacity. Use when a wallet has no DUST.

输入参数network必填addresses必填

decode

midnight-cast decode

Explain a Midnight error. Paste the whole message from a wallet, node, toolkit or Blockfrost: 1010 rejections, Custom(N) ledger codes, pallet errors, JSON-RPC codes and known tooling messages are recognised. A bare code such as 170 works too.

输入参数message必填network

explain

midnight-cast explain

Background on a Midnight topic: dust, 1010, versions, transcript, sync.

输入参数topic必填

examples

midnight-cast examples

Working code from Midnight's official examples (midnightntwrk/midnight-examples), each compiled and tested in CI. Give a topic such as "DUST sponsorship", "send shielded tokens" or "verify a signature in a circuit" to get the examples that show it, with file paths, line ranges, links pinned to a commit and the code itself. Without a topic, lists every example and what it covers. Prefer these over writing Midnight code from memory.

输入参数topic

版本历史

2
  1. v0.2.1Oct 23, 2026
  2. v0.2.0Oct 10, 2026

评分

已满足适用检查项的 90%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分
  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具必需15 分
  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分