feat(mcp): agenthub mcp install — print per-CLI registration config
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 <noreply@anthropic.com>
This commit is contained in:
parent
96fdf0dbd4
commit
eec2050a32
@ -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",
|
||||
|
||||
@ -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<void>): Promise<vo
|
||||
export function createProgram(cwd: string): Command {
|
||||
const program = new Command('agenthub')
|
||||
.description('Local coordination layer for AI coding agents')
|
||||
.version('0.7.2')
|
||||
.version('0.7.3')
|
||||
.option('--server <url>', '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);
|
||||
});
|
||||
|
||||
|
||||
59
src/mcp/install.ts
Normal file
59
src/mcp/install.ts
Normal file
@ -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('');
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user