feat(fleet): add MCP channel server for real-time agent communication#642
Open
feat(fleet): add MCP channel server for real-time agent communication#642
Conversation
Add a kild-fleet MCP channel server that watches inbox files and pushes notifications into Claude Code sessions via the channels protocol. This reduces fleet communication latency from ~1s (Claude inbox polling) to ~100ms (fs.watch + stdio notification). The channel server (TypeScript/Bun) is embedded in the Rust binary and installed to ~/.kild/channels/fleet/ via `kild init-channels`. It exposes MCP tools (report_status, send_to_worker, send_to_brain, list_fleet) so agents can communicate without shelling out to CLI commands. Gated behind [fleet] channels = true config flag (default: false). Requires Bun runtime. Graceful degradation when unavailable. New command: `kild init-channels` — installs server + bun deps. New config: `[fleet] channels` — enables channel server for fleet sessions.
…tall Channel server writes a .channel breadcrumb to the inbox dir after MCP handshake completes. `kild inbox` surfaces this as [channel] next to the status line, so you can confirm the channel server is actually connected. Stale breadcrumbs are cleaned on session create/open (ensure_inbox). Also skip `bun install` in `kild init-channels` when node_modules exists.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a kild-fleet MCP channel server that watches inbox files and pushes notifications into Claude Code sessions via the channels protocol. Reduces fleet communication latency from ~1s (Claude inbox polling) to ~100ms (fs.watch + stdio notification). Also exposes MCP tools so agents can write status/reports/messages without shelling out to CLI commands.
Changes
integrations/channel.rs— installs channel server, patches.mcp.json, cleanup on destroykild init-channelsCLI command — installs server.ts + bun deps at~/.kild/channels/fleet/FleetConfigin kild-config with[fleet] channelstoggle (default: false)fleet_agent_flags()appends--dangerously-load-development-channels server:kild-fleetwhen channels enableddaemon_spawn.rscallssetup_channel_integration()in the spawn sequencedestroy.rscleans up.mcp.jsonfrom project root for--mainsessionsArchitecture
The channel server is a TypeScript/Bun MCP server embedded as a string constant in the Rust binary. It reads
$KILD_INBOXand$KILD_FLEET_DIRfrom the PTY environment (already injected by the inbox module). The file-based inbox protocol remains the source of truth — the channel is a notification + tooling layer on top.MCP Tools Exposed
report_statussend_to_brainsend_to_workerlist_fleetFiles Changed
15 files changed (+616, -23)
File list
crates/kild-core/src/sessions/integrations/channel.rs(new, 442 lines)crates/kild/src/commands/init_channels.rs(new, 59 lines)crates/kild-config/src/types.rs— FleetConfig structcrates/kild-config/src/loading.rs— merge logiccrates/kild-config/src/lib.rs— re-exportcrates/kild-core/src/lib.rs— re-exportcrates/kild-core/src/sessions/daemon_spawn.rs— wire channel integrationcrates/kild-core/src/sessions/fleet.rs— channels flag in fleet_agent_flags()crates/kild-core/src/sessions/destroy.rs— .mcp.json cleanupcrates/kild-core/src/sessions/daemon_helpers.rs— re-exportcrates/kild-core/src/sessions/integrations/mod.rs— register modulecrates/kild-paths/src/lib.rs— channels_dir(), fleet_channel_dir()crates/kild/src/app/misc.rs— init-channels clap defcrates/kild/src/app/mod.rs— subcommand registrationcrates/kild/src/commands/mod.rs— dispatchTesting
cargo fmt --check && cargo clippy --all -- -D warningspassescargo test --allpasses (0 failures)cargo build --allsucceedskild init-channelsinstalls server + deps.mcp.json+ channels flag.mcp.json+ channels flagkild inject→ worker receives task, writes status + report.mcp.jsonfrom project root[fleet] channels = false(no .mcp.json, no flag)Configuration
Requires Bun runtime. Run
kild init-channelsto install dependencies.