From eec2050a326228d6e21fac6e500cdc7ed570bb6f Mon Sep 17 00:00:00 2001 From: chahinebrini Date: Mon, 29 Jun 2026 01:47:14 +0200 Subject: [PATCH] =?UTF-8?q?feat(mcp):=20`agenthub=20mcp=20install`=20?= =?UTF-8?q?=E2=80=94=20print=20per-CLI=20registration=20config?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removes the registration friction: `agenthub mcp install` prints ready-to-paste MCP config for Claude Code, Codex and Kimi, with the hub URL filled in from the project config. `agenthub mcp` (no action) still starts the stdio server, so the MCP-client spawn command is unchanged. Bump 0.7.2 -> 0.7.3. Co-Authored-By: Claude Opus 4.8 --- package.json | 2 +- src/cli/index.ts | 13 ++++++---- src/mcp/install.ts | 59 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 5 deletions(-) create mode 100644 src/mcp/install.ts diff --git a/package.json b/package.json index 8d841c7..35d0a05 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "agenthub", - "version": "0.7.2", + "version": "0.7.3", "description": "Local coordination layer for AI coding agents", "type": "module", "main": "./dist/index.js", diff --git a/src/cli/index.ts b/src/cli/index.ts index 4845b0b..64d373b 100644 --- a/src/cli/index.ts +++ b/src/cli/index.ts @@ -12,6 +12,7 @@ import { watchEvents } from './commands/watch.js'; import { startAgent } from './commands/start.js'; import { workAgent } from './commands/work.js'; import { startMcpServer } from '../mcp/server.js'; +import { printMcpConfig } from '../mcp/install.js'; import { loadConfig, saveConfig } from '../core/config.js'; import { findProjectRoot } from '../core/paths.js'; import { discoverServer } from '../discovery.js'; @@ -115,7 +116,7 @@ async function runRemote(serverUrl: string, fn: () => Promise): Promise', 'AgentHub server URL (env: AGENTHUB_SERVER)'); program @@ -484,9 +485,13 @@ export function createProgram(cwd: string): Command { // ─── mcp ─────────────────────────────────────────────────────────────────── program - .command('mcp') - .description('Start the MCP server (stdio) — exposes hub tools to MCP-capable agents (Claude/Codex/Kimi)') - .action(async () => { + .command('mcp [action]') + .description('Start the MCP server (stdio). `agenthub mcp install` prints per-CLI registration config.') + .action(async (action?: string) => { + if (action === 'install') { + printMcpConfig(cwd); + return; + } await startMcpServer(cwd); }); diff --git a/src/mcp/install.ts b/src/mcp/install.ts new file mode 100644 index 0000000..aa15dcf --- /dev/null +++ b/src/mcp/install.ts @@ -0,0 +1,59 @@ +import { findProjectRoot } from '../core/paths.js'; +import { loadConfig } from '../core/config.js'; + +/** + * Print ready-to-paste MCP registration config for each agent CLI, with the + * hub URL filled in. The MCP server itself is `agenthub mcp` (stdio) — every + * client just needs to know to spawn it + which hub to talk to. + */ +export function printMcpConfig(cwd: string): void { + const root = findProjectRoot(cwd) ?? cwd; + let serverUrl = process.env.AGENTHUB_SERVER || undefined; + if (!serverUrl) { + try { + serverUrl = loadConfig(root).serverUrl; + } catch { + /* no project config */ + } + } + const url = serverUrl ?? 'http://127.0.0.1:3377'; + + const out = (s: string) => process.stdout.write(s + '\n'); + + out(''); + out('AgentHub MCP — registration'); + out('═══════════════════════════'); + out(`Hub URL: ${url}`); + out('(On the Windows machine use the Mac\'s LAN IP, e.g. http://192.168.178.30:3377)'); + out(''); + out('The MCP server is `agenthub mcp` (stdio). Register it once per agent CLI:'); + out(''); + + out('── Claude Code ──────────────────────────────────────────────'); + out(` claude mcp add agenthub --env AGENTHUB_SERVER=${url} -- agenthub mcp`); + out(' (or add the .mcp.json block below to the project)'); + out(''); + + out('── .mcp.json (project root — Claude Code / generic) ─────────'); + out(JSON.stringify( + { mcpServers: { agenthub: { command: 'agenthub', args: ['mcp'], env: { AGENTHUB_SERVER: url } } } }, + null, + 2, + )); + out(''); + + out('── Codex CLI (~/.codex/config.toml) ─────────────────────────'); + out(' [mcp_servers.agenthub]'); + out(' command = "agenthub"'); + out(' args = ["mcp"]'); + out(` env = { AGENTHUB_SERVER = "${url}" }`); + out(''); + + out('── Kimi CLI ─────────────────────────────────────────────────'); + out(' Add a stdio MCP server via Kimi\'s MCP config with the same shape:'); + out(' command: agenthub args: ["mcp"] env: { AGENTHUB_SERVER: ' + url + ' }'); + out(''); + out('After registering, the agent calls the tools (agenthub_work, agenthub_task_review, …)'); + out('instead of CLI strings. Requires agenthub >= 0.7.0 on each machine.'); + out(''); +}