mcp-coordinator 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +92 -0
  3. package/dashboard/Dockerfile +19 -0
  4. package/dashboard/public/index.html +1178 -0
  5. package/dist/cli/config.d.ts +14 -0
  6. package/dist/cli/config.js +58 -0
  7. package/dist/cli/dashboard.d.ts +2 -0
  8. package/dist/cli/dashboard.js +14 -0
  9. package/dist/cli/index.d.ts +2 -0
  10. package/dist/cli/index.js +13 -0
  11. package/dist/cli/server/index.d.ts +2 -0
  12. package/dist/cli/server/index.js +11 -0
  13. package/dist/cli/server/start.d.ts +2 -0
  14. package/dist/cli/server/start.js +57 -0
  15. package/dist/cli/server/status.d.ts +2 -0
  16. package/dist/cli/server/status.js +60 -0
  17. package/dist/cli/server/stop.d.ts +2 -0
  18. package/dist/cli/server/stop.js +59 -0
  19. package/dist/cli/version.d.ts +1 -0
  20. package/dist/cli/version.js +22 -0
  21. package/dist/src/agent-activity.d.ts +27 -0
  22. package/dist/src/agent-activity.js +70 -0
  23. package/dist/src/agent-registry.d.ts +10 -0
  24. package/dist/src/agent-registry.js +38 -0
  25. package/dist/src/auth.d.ts +22 -0
  26. package/dist/src/auth.js +91 -0
  27. package/dist/src/conflict-detector.d.ts +17 -0
  28. package/dist/src/conflict-detector.js +114 -0
  29. package/dist/src/consultation.d.ts +75 -0
  30. package/dist/src/consultation.js +332 -0
  31. package/dist/src/context-provider.d.ts +14 -0
  32. package/dist/src/context-provider.js +34 -0
  33. package/dist/src/database.d.ts +4 -0
  34. package/dist/src/database.js +194 -0
  35. package/dist/src/db-adapter.d.ts +15 -0
  36. package/dist/src/db-adapter.js +1 -0
  37. package/dist/src/dependency-map.d.ts +7 -0
  38. package/dist/src/dependency-map.js +76 -0
  39. package/dist/src/file-tracker.d.ts +21 -0
  40. package/dist/src/file-tracker.js +44 -0
  41. package/dist/src/impact-scorer.d.ts +31 -0
  42. package/dist/src/impact-scorer.js +112 -0
  43. package/dist/src/index.d.ts +2 -0
  44. package/dist/src/index.js +26 -0
  45. package/dist/src/introspection.d.ts +24 -0
  46. package/dist/src/introspection.js +28 -0
  47. package/dist/src/logger.d.ts +20 -0
  48. package/dist/src/logger.js +55 -0
  49. package/dist/src/mqtt-bridge.d.ts +40 -0
  50. package/dist/src/mqtt-bridge.js +173 -0
  51. package/dist/src/mqtt-broker.d.ts +23 -0
  52. package/dist/src/mqtt-broker.js +99 -0
  53. package/dist/src/plan-quality.d.ts +11 -0
  54. package/dist/src/plan-quality.js +30 -0
  55. package/dist/src/quota/credential-reader.d.ts +21 -0
  56. package/dist/src/quota/credential-reader.js +86 -0
  57. package/dist/src/quota/quota-cache.d.ts +93 -0
  58. package/dist/src/quota/quota-cache.js +177 -0
  59. package/dist/src/quota/quota.d.ts +47 -0
  60. package/dist/src/quota/quota.js +117 -0
  61. package/dist/src/serve-http.d.ts +5 -0
  62. package/dist/src/serve-http.js +775 -0
  63. package/dist/src/server-setup.d.ts +34 -0
  64. package/dist/src/server-setup.js +453 -0
  65. package/dist/src/sse-emitter.d.ts +10 -0
  66. package/dist/src/sse-emitter.js +35 -0
  67. package/dist/src/types.d.ts +121 -0
  68. package/dist/src/types.js +1 -0
  69. package/package.json +80 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Maxime Gagnon
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,92 @@
1
+ # mcp-coordinator
2
+
3
+ **Embedded MQTT broker + MCP server for multi-agent coordination.**
4
+
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
6
+ [![npm](https://img.shields.io/npm/v/mcp-coordinator.svg)](https://www.npmjs.com/package/mcp-coordinator)
7
+ [![Tests](https://github.com/swoofer/mcp-coordinator/actions/workflows/test.yml/badge.svg)](https://github.com/swoofer/mcp-coordinator/actions)
8
+
9
+ ## What it does
10
+
11
+ When multiple AI agents work on the same repository in parallel, they need a coordination layer to avoid stepping on each other. mcp-coordinator provides:
12
+
13
+ - **Embedded MQTT broker** (Aedes) for real-time agent-to-agent messaging
14
+ - **MCP server** (HTTP/SSE + STDIO) exposing 26 tools for announcement, conflict detection, consultation, and quota tracking
15
+ - **SQLite-backed state** for thread persistence
16
+ - **Live dashboard** showing connected agents, open consultations, file activity, quota
17
+
18
+ The server is **client-agnostic**: it speaks the MCP protocol and MQTT, so any MCP-compatible agent (Claude Code, Cursor, Cline, Aider, custom scripts) can connect.
19
+
20
+ ## Quick start
21
+
22
+ ```bash
23
+ npm install -g mcp-coordinator
24
+ mcp-coordinator server start # foreground, port 3100, MQTT 1883
25
+ mcp-coordinator server start --daemon # background
26
+ mcp-coordinator server status
27
+ mcp-coordinator server stop
28
+ mcp-coordinator dashboard # opens dashboard URL in browser
29
+ ```
30
+
31
+ Or in-process from your own Node app:
32
+
33
+ ```ts
34
+ import { startServer } from "mcp-coordinator";
35
+
36
+ await startServer({
37
+ port: 3100,
38
+ dataDir: "./coordinator-data",
39
+ });
40
+ ```
41
+
42
+ ## MQTT topics
43
+
44
+ The broker publishes coordination events on well-known topics. Agents subscribe to receive real-time updates.
45
+
46
+ | Topic | When emitted | Payload |
47
+ |---|---|---|
48
+ | `coordinator/consultations/new` | A thread is opened | `{ thread_id, subject, initiator_id, target_modules, target_files }` |
49
+ | `coordinator/consultations/{id}/messages` | Anyone posts | `{ agent_id, name, content, type }` |
50
+ | `coordinator/consultations/{id}/status` | Thread state change | `{ status: open / resolving / resolved / timeout }` |
51
+ | `coordinator/consultations/{id}/claimed` | Atomic task claim | `{ claimed_by, thread_id }` |
52
+ | `coordinator/consultations/{id}/completed` | Claimed task done | `{ agent_id, thread_id, resolution }` |
53
+ | `coordinator/agents/{id}/status` | Agent online/offline | `{ status, name, modules }` |
54
+ | `coordinator/quota/update` | Quota refresh | `{ usage, limit, utilization_pct }` |
55
+
56
+ ## MCP tools
57
+
58
+ The server exposes 26 MCP tools. Highlights: `register_agent`, `announce_work`, `propose_resolution`, `approve_resolution`, `contest_resolution`, `list_threads`, `get_thread`, `post_to_thread`, `wait_for_peers`, `log_action_summary`. See the in-server `introspection` tool for the full schema.
59
+
60
+ ## Configuration
61
+
62
+ Server reads config from `~/.mcp-coordinator/config.json` (auto-created with defaults on first run) and environment variables:
63
+
64
+ - `COORDINATOR_DATA_DIR` — sqlite directory (default: `~/.mcp-coordinator/data`)
65
+ - `PORT` — HTTP port (default: 3100)
66
+ - `COORDINATOR_MQTT_TCP_PORT` — MQTT TCP port (default: 1883)
67
+ - `COORDINATOR_AUTH_ENABLED` — set to `"true"` to enable JWT auth (requires `COORDINATOR_JWT_SECRET`)
68
+
69
+ CLI flags override env vars override config file.
70
+
71
+ ## Integration patterns
72
+
73
+ ### Any MCP client
74
+
75
+ Connect to `http://localhost:3100/mcp` (HTTP/SSE) or stdio. The server speaks MCP 2024-11-05.
76
+
77
+ ### Custom orchestrator
78
+
79
+ Spawn agents that connect to the MQTT broker and register via the MCP `register_agent` tool. See the [essaim](https://github.com/swoofer/essaim) reference orchestrator for an example, or write your own.
80
+
81
+ ### Example agent configurations
82
+
83
+ For a reference catalog of coordinator-aware agent behaviors (announce-before-write, conflict-resolution, work-stealing phases, etc.), see [essaim's behaviors](https://github.com/swoofer/essaim/tree/main/behaviors). These are YAML configs consumable by [@swoofer/promptweave](https://github.com/swoofer/promptweave).
84
+
85
+ ## Related projects
86
+
87
+ - **[@swoofer/promptweave](https://github.com/swoofer/promptweave)** — YAML composer for assembling agent prompts, hooks, and MCP configs. Use it with mcp-coordinator-aware behaviors from essaim.
88
+ - **[essaim](https://github.com/swoofer/essaim)** *(coming soon)* — end-to-end orchestrator that spawns N coordinated agents using `@swoofer/promptweave` + `mcp-coordinator`.
89
+
90
+ ## License
91
+
92
+ MIT
@@ -0,0 +1,19 @@
1
+ FROM node:22-slim
2
+ WORKDIR /app
3
+ COPY dashboard/public/ public/
4
+ RUN cat > server.mjs << 'SCRIPT'
5
+ import { createServer } from "http";
6
+ import { readFileSync, existsSync } from "fs";
7
+ import { join, extname } from "path";
8
+
9
+ const MIME = { ".html": "text/html", ".js": "application/javascript", ".css": "text/css", ".json": "application/json" };
10
+
11
+ createServer((req, res) => {
12
+ const filePath = join("public", req.url === "/" ? "index.html" : req.url);
13
+ if (!existsSync(filePath)) { res.writeHead(200, {"Content-Type":"text/html"}); res.end(readFileSync("public/index.html","utf-8")); return; }
14
+ const ext = extname(filePath);
15
+ res.writeHead(200, {"Content-Type": MIME[ext] || "text/plain"});
16
+ res.end(readFileSync(filePath));
17
+ }).listen(3200, () => console.log("Dashboard on :3200"));
18
+ SCRIPT
19
+ CMD ["node", "server.mjs"]