L2 v0.1.1 source

mcp-doctor

Bir MCP server bağlanamadığında ya da bağlantısı koptuğunda bunu size söyleyen, onu yeniden bağlayan bir tuş sunan ve server geri geldiğinde bunu da söyleyen bir Claude Code Mod'u. Engine başarısız bir server'ı yalnız modele bildirir; bu mod kişiye bildirir.

Ne yapar

  1. Session başında, her main-loop turn sonunda ve deferred tool'larla ilgili her engine notundan sonra mod, engine'in bağlı olmayan server listesini okur. Built-in ToolSearch tool'una sorar. Sonucu başarısız her server'ı (failed_mcp_servers) ve hâlâ bağlanan her server'ı (pending_mcp_servers) adlandırır. Engine bu listeyi yalnız eşleşmesi olmayan bir cevaba ekler, bu yüzden sorgu var olamayacak bir tool'u seçer. Çağrı modelin context'inde hiçbir şey bırakmaz.

  2. Engine'in modele giden deferred_tools_delta notu da okunur: "configured but failed to connect" bloğu başarısız server'ları, "available again (MCP server reconnected)" satırı geri gelen tool prefix'lerini adlandırır. Not modele değişmeden ulaşır.

  3. Bağlı olmayan bir server, sidebar içinde session boyunca duran bir kırmızı section alır. Section engine'in verdiği nedeni ve bir reconnect tuşunu taşır:

    flaky: not connected (CONNECTION_CLOSED: Connection closed)
    [ reconnect flaky ]
    

    Sidebar kapalıyken tek bir transcript satırı aynı şeyi söyler ve komutu adlandırır: flaky: not connected (disconnected); /mcp-doctor reconnect flaky. Sidebar açıldıktan sonraki ilk ölçümde section çizilir.

  4. Tuş /mcp-doctor reconnect <server> komutunu çalıştırır. Bu komut engine'den /mcp reconnect <server> çalıştırmasını ister ve listeyi yeniden okur. Sonrasında hâlâ başarısız olan bir server, engine'in cevabını taşıyan tek bir satır alır.

  5. Geri gelen bir server kırmızı section'ını kaybeder ve tek bir yeşil satır alır: flaky: connected again. Hâlâ bağlanan bir server olduğu gibi kalır.

  6. Aynı hata bir kere yazılır. Aynı server'ı yine başarısız bulan sonraki bir turn hiçbir şey yazmaz.

claude.ai connector'ları (claude.ai <ad> adlı server'lar) dışarıda kalır, çünkü onlar bu makinenin config'ine değil hesaba aittir. Model bu mod'dan not almaz, çünkü engine ona zaten bildirir.

Komut

/mcp-doctor                    ayar ve bağlı olmayan her server
/mcp-doctor reconnect <server> engine'den tek bir server'ı yeniden bağlamasını ister
/mcp-doctor on | off           varsayılan on

Kurulum

claude plugin marketplace add KilimcininKorOglu/claude-code-mods
claude plugin install mcp-doctor@kilimcininkoroglu-mods

Function hook'lar early access. Flag olmadan hiçbir şey yüklenmez. Flag'i kalıcı yapmak için ~/.claude/settings.json dosyasına ekleyin:

{ "env": { "CLAUDE_CODE_ENABLE_FUNCTION_HOOKS": "1" } }

Kurulumdan sonra

  1. Claude Code'u yeniden başlatın.
  2. Kırmızı section ve tuşu için sidebar mod'unu kurun. O olmadan mod her server için tek bir transcript satırı yazar.

Nereye uzanır

Claude Code 2.1.280 üzerinde claude plugin validate ile doğrulandı:

❯ ./register.ts hooks: session.start, command.run{command=mcp-doctor}, turn.complete, prompt.attachment{type=deferred_tools_delta}
❯ ./register.ts calls: $.clock.after (via later, runCommand), $.command.register, $.command.run (via reconnect), $.sidebar.clear (via showBack), $.sidebar.set (via placeFailed, showBack), $.store.get, $.store.set (via setEnabled), $.tool.call (via measure), $.ui.log (via addFailures, later, measure, reconnect, showBack)

Reach L2, Claude'u yönlendirir: /mcp reconnect komutunu çalıştırır.

1. Okur:     engine'in başarısız ve bağlanan MCP server listesini (bir ToolSearch sonucu) ve engine'in deferred_tools_delta notunu. Hiçbir dosyayı, prompt'u ya da cevabı okumaz.
2. Çalıştırır: ToolSearch'ü her session başında, her turn sonunda ve her deferred_tools_delta notunda bir kere; /mcp reconnect <server> komutunu tuşa her basışta bir kere
3. Gönderir: modele ve network'e hiçbir şey
4. Saklar:   $.store içinde on/off ayarını
5. Düşman girdi: server adları ve hata metinleri engine'den ve server config'inden gelir; metin olarak çizilir, hiç çalıştırılmaz, ve reconnect komutu adı yalnız argüman olarak alır

Sınırlar

  • Yeniden bağlama yalnız interaktif bir session'da çalışır. Headless bir session (claude -p) Reconnect, enable, and disable aren't available in this session. cevabını verir ve mod bu cevabı yazar.
  • Engine session sırasında kopan bir server için hata vermez, bu yüzden satırı disconnected yazar.
  • ToolSearch'ün cevap vermediği bir build (tool search kapalı) yalnız engine'in notlarıyla okunur ve mod bunu bir kere söyler.
  • Engine'in notu geri gelen bir server'ı tool prefix'iyle adlandırır. Tek bir prefix'e düşen iki server adı (a.b ve a_b) birlikte kapanır.
  • Bir subagent'ın turn'ü ölçüm başlatmaz; yalnız main loop'un sonu başlatır.

Geliştirme

make install     # eslint, typescript-eslint, typescript
make lint        # complexity limiti 10, üstünde build'i düşürür
make typecheck   # /plugin-types ile üretilen .claude/types/ gerekir
make validate
make test        # claude plugin test

mcp-doctor

A Claude Code Mod that tells you when an MCP server failed to connect or dropped, with a button that reconnects it, and says so again when the server is back. The engine tells only the model about a failed server; this mod tells the person.

What it does

  1. At session start, at the end of each main-loop turn and after each engine note about deferred tools, the mod reads the engine's own list of servers that are not connected. It asks the built-in ToolSearch tool, whose result names each failed server (failed_mcp_servers) and each server still connecting (pending_mcp_servers). The engine adds that list only to an answer with no match, so the query selects a tool that cannot exist. The call leaves nothing in the model's context.

  2. The engine's deferred_tools_delta note to the model is read too: its "configured but failed to connect" block names failed servers, and its "available again (MCP server reconnected)" line names the tool prefixes that came back. The note reaches the model unchanged.

  3. A server that is not connected gets one red section in the sidebar that stays for the session, with the engine's reason and a reconnect button:

    flaky: not connected (CONNECTION_CLOSED: Connection closed)
    [ reconnect flaky ]
    

    While the sidebar is closed, one transcript line says the same and names the command: flaky: not connected (disconnected); /mcp-doctor reconnect flaky. The section is drawn at the next measure after the sidebar opens.

  4. The button runs /mcp-doctor reconnect <server>, which asks the engine to run /mcp reconnect <server> and reads the list again. A server still failed afterwards gets one line with the engine's answer.

  5. A server that is back loses its red section and gets one green line: flaky: connected again. A server still connecting is left as it is.

  6. The same failure is written once. A later turn that finds the same server failed writes nothing.

claude.ai connectors (servers named claude.ai <name>) are left out, because they belong to the account and not to this machine's config. The model gets no note from this mod, because the engine already tells it.

Command

/mcp-doctor                    the setting and every server that is not connected
/mcp-doctor reconnect <server> asks the engine to reconnect one server
/mcp-doctor on | off           on by default

Install

claude plugin marketplace add KilimcininKorOglu/claude-code-mods
claude plugin install mcp-doctor@kilimcininkoroglu-mods

Function hooks are early access. Nothing loads without the flag. To keep it on, add this to ~/.claude/settings.json:

{ "env": { "CLAUDE_CODE_ENABLE_FUNCTION_HOOKS": "1" } }

After installing

  1. Restart Claude Code.
  2. Install the sidebar mod for the red section and its button. Without it the mod writes one transcript line per server.

What it can reach

Validated with claude plugin validate on Claude Code 2.1.280:

❯ ./register.ts hooks: session.start, command.run{command=mcp-doctor}, turn.complete, prompt.attachment{type=deferred_tools_delta}
❯ ./register.ts calls: $.clock.after (via later, runCommand), $.command.register, $.command.run (via reconnect), $.sidebar.clear (via showBack), $.sidebar.set (via placeFailed, showBack), $.store.get, $.store.set (via setEnabled), $.tool.call (via measure), $.ui.log (via addFailures, later, measure, reconnect, showBack)

Reach L2, it drives Claude: it runs the /mcp reconnect command.

1. Reads:    the engine's list of failed and connecting MCP servers (a ToolSearch result), and the engine's deferred_tools_delta note. It reads no file, no prompt and no answer.
2. Runs:     ToolSearch once per session start, per turn end and per deferred_tools_delta note; /mcp reconnect <server> once per press of the button
3. Sends:    nothing to the model and nothing to the network
4. Persists: in $.store, the on/off setting
5. Hostile input: the server names and error texts come from the engine and the server config; they are drawn as text and never run, and the reconnect command takes the name only as its argument

Limits

  • Reconnecting works in an interactive session alone. A headless session (claude -p) answers Reconnect, enable, and disable aren't available in this session., and the mod writes that answer.
  • The engine gives no error for a server that dropped during the session, so its line reads disconnected.
  • A build where ToolSearch does not answer (tool search turned off) is read through the engine's notes alone, and the mod says so once.
  • The engine's note names a reconnected server by its tool prefix. Two server names that map to one prefix (a.b and a_b) are closed together.
  • A subagent's turn does not trigger a measure; only the main loop's end does.

Development

make install     # eslint, typescript-eslint, typescript
make lint        # complexity limit 10, fails the build above it
make typecheck   # needs .claude/types/ from /plugin-types
make validate
make test        # claude plugin test