diff --git a/.changeset/remove-mcp-command.md b/.changeset/remove-mcp-command.md new file mode 100644 index 0000000..eef9146 --- /dev/null +++ b/.changeset/remove-mcp-command.md @@ -0,0 +1,36 @@ +--- +"@camoneart/maestro": major +--- + +Remove obsolete `mcp` command and add dedicated MCP server binary + +BREAKING CHANGE: The `mcp` command has been removed. It became obsolete with the introduction of the modern `claude mcp add` command which automatically manages the MCP server lifecycle. + +**Migration:** +- Users no longer need to manually start the MCP server with `mst mcp serve` +- Claude Code automatically manages the server lifecycle +- New dedicated `maestro-mcp-server` binary added for MCP integration + +**Setup for different scopes:** +```bash +# Local scope (default - current project only) +claude mcp add maestro -- npx -y @camoneart/maestro maestro-mcp-server + +# Project scope (saved in .mcp.json for team sharing) +claude mcp add maestro -s project -- npx -y @camoneart/maestro maestro-mcp-server + +# User scope (all projects on machine) +claude mcp add maestro -s user -- npx -y @camoneart/maestro maestro-mcp-server + +# For global installation +claude mcp add maestro -s user -- maestro-mcp-server +``` + +**Rationale:** +- Simplifies the CLI by removing unnecessary complexity +- Reduces confusion for users +- Reduces maintenance burden +- Aligns with modern MCP setup practices +- Provides dedicated binary for cleaner MCP integration + +Fixes #207 \ No newline at end of file diff --git a/README.ja.md b/README.ja.md index 9a89e4c..2fae1be 100644 --- a/README.ja.md +++ b/README.ja.md @@ -338,18 +338,27 @@ mst config init # プロジェクト設定を 最新のコマンドを使用してClaude CodeにMaestroをMCPサーバーとして追加: +#### ローカルスコープ(デフォルト - 現在のプロジェクトでのみ、個人専用) ```bash -# ユーザースコープ(マシン上の全プロジェクトで利用可能) -claude mcp add maestro -s user -- npx -y @camoneart/maestro mcp serve +claude mcp add maestro -s local -- npx -y @camoneart/maestro maestro-mcp-server +# または -s フラグなし(localがデフォルト) +claude mcp add maestro -- npx -y @camoneart/maestro maestro-mcp-server +``` -# プロジェクトスコープ(.mcp.jsonに保存、バージョン管理でチーム共有) -claude mcp add maestro -s project -- npx -y @camoneart/maestro mcp serve +#### プロジェクトスコープ(.mcp.jsonに保存、バージョン管理でチーム共有) +```bash +claude mcp add maestro -s project -- npx -y @camoneart/maestro maestro-mcp-server +``` -# ローカルスコープ(デフォルト - 現在のプロジェクトでのみ、個人専用) -claude mcp add maestro -s local -- npx -y @camoneart/maestro mcp serve +#### ユーザースコープ(マシン上の全プロジェクトで利用可能) +```bash +claude mcp add maestro -s user -- npx -y @camoneart/maestro maestro-mcp-server +``` -# グローバルインストールの場合(npxの代わりにmaestroを使用) -claude mcp add maestro -s user -- maestro mcp serve +#### グローバルインストールの場合 +Maestroをグローバルインストールしている場合は以下を使用: +```bash +claude mcp add maestro -s user -- maestro-mcp-server ``` これによりClaude CodeがMaestroのMCPサーバーを選択したスコープレベルで使用できるよう自動設定されます。 @@ -398,7 +407,6 @@ mst completion fish > ~/.config/fish/completions/mst.fish | **Git が古い**
`fatal: unknown option` | Git バージョン < 2.22 | `brew install git` | | **fzf が見つからない** | fzf 未インストール | `brew install fzf` | | **tmux が見つからない** | tmux 未インストール | `brew install tmux` | -| **Claude Code が起動しない** | MCP サーバー未起動 or ポート競合 | `mst mcp status` → `mst mcp stop` | | **tmux ペインが多すぎる**
`画面サイズに対してペイン数(N個)が多すぎるため、セッションが作成できませんでした` | ターミナルウィンドウに対してペイン数が過多 | ウィンドウのリサイズまたはペイン数を削減(最大:水平10個、垂直15個) | | **GitHub PR/Issue が見つからない**
`Error: PR/Issue #999 が見つかりません` | 存在しないIssue/PR番号を指定 | 正しい番号を確認するか、リポジトリを確認 | @@ -406,7 +414,6 @@ mst completion fish > ~/.config/fish/completions/mst.fish | エラーコード | 原因 | 解決策 | | ------------ | ------------------------------ | ----------------------------------- | -| `EADDRINUSE` | MCP サーバーのポート競合 | `mst mcp stop` で既存プロセスを停止 | | `ENOENT` | Git 実行ファイルが見つからない | Git の PATH を確認、再インストール | ### ⚠️ CLIオプション検証とエラーハンドリング diff --git a/README.md b/README.md index 54a40a3..f3ac4ec 100644 --- a/README.md +++ b/README.md @@ -339,18 +339,27 @@ All available configuration options for `.maestro.json`: Add Maestro as an MCP server to Claude Code using the modern command: +#### Local Scope (Default - only for current project, private to you) ```bash -# User scope (available across all projects on the machine) -claude mcp add maestro -s user -- npx -y @camoneart/maestro mcp serve +claude mcp add maestro -s local -- npx -y @camoneart/maestro maestro-mcp-server +# Or without -s flag (local is default) +claude mcp add maestro -- npx -y @camoneart/maestro maestro-mcp-server +``` -# Project scope (saved in .mcp.json for team sharing via version control) -claude mcp add maestro -s project -- npx -y @camoneart/maestro mcp serve +#### Project Scope (saved in .mcp.json for team sharing via version control) +```bash +claude mcp add maestro -s project -- npx -y @camoneart/maestro maestro-mcp-server +``` -# Local scope (default - only for current project, private to you) -claude mcp add maestro -s local -- npx -y @camoneart/maestro mcp serve +#### User Scope (available across all projects on the machine) +```bash +claude mcp add maestro -s user -- npx -y @camoneart/maestro maestro-mcp-server +``` -# For global installation (use 'maestro' instead of 'npx') -claude mcp add maestro -s user -- maestro mcp serve +#### For global installation users +If you've installed Maestro globally, use: +```bash +claude mcp add maestro -s user -- maestro-mcp-server ``` This will automatically configure Claude Code to use Maestro's MCP server for orchestra management at the chosen scope level. @@ -424,7 +433,6 @@ mst create feature/new-feature --tmux | **Git is too old**
`fatal: unknown option` | Git < 2.22 | `brew install git` | | **fzf not found** | fzf not installed | `brew install fzf` | | **tmux not found** | tmux not installed | `brew install tmux` | -| **Claude Code won't start** | MCP server not running or port conflict | `mst mcp status` → `mst mcp stop` | | **Too many tmux panes**
`Unable to create session with N panes due to terminal size` | Terminal window too small for requested panes | Resize window or reduce panes (max: 10 horizontal, 15 vertical) | | **GitHub PR/Issue not found**
`Error: PR/Issue #999 が見つかりません` | Specified non-existent Issue/PR number | Check correct number or verify repository | @@ -432,7 +440,6 @@ mst create feature/new-feature --tmux | Code | Cause | Fix | | ------------ | ---------------------- | --------------------------------------- | -| `EADDRINUSE` | MCP server port in use | `mst mcp stop` to kill previous process | | `ENOENT` | Git binary not found | Check PATH or reinstall Git | ### ⚠️ CLI Option Validation and Error Handling diff --git a/docs/COMMANDS.md b/docs/COMMANDS.md index 05d8ff9..7699b76 100644 --- a/docs/COMMANDS.md +++ b/docs/COMMANDS.md @@ -26,7 +26,6 @@ Detailed usage of all maestro (mst) commands. - [config](#-config) - Configuration management - [where](#-where) - Check current location - [exec](#-exec) - Execute commands in members -- [mcp](#-mcp) - MCP server management - [attach](#-attach) - Attach to existing branch - [graph](#-graph) - Display relationships - [history](#-history) - Operation history @@ -761,27 +760,6 @@ mst exec --fzf --tmux-v npm test ``` -### 🔸 mcp - -Manage MCP server. - -```bash -mst mcp [options] -``` - -| Subcommand | Description | -|------------|-------------| -| `serve` | Start MCP server for Claude Code/Cursor integration | - -#### Examples -```bash -# Start MCP server -mst mcp serve - -# Display usage information -mst mcp -``` - ### 🔸 attach Attach to existing branch. @@ -1149,7 +1127,6 @@ For detailed usage of each command, see the following documentation: - [Config Management Details](./commands/config.md) - [Where Command Details](./commands/where.md) - [Exec Command Details](./commands/exec.md) -- [MCP Server Details](./commands/mcp.md) - [Attach Command Details](./commands/attach.md) - [Graph Display Details](./commands/graph.md) - [History Management Details](./commands/history.md) diff --git a/docs/CONFIGURATION.md b/docs/CONFIGURATION.md index b3e0c6c..1c33af1 100644 --- a/docs/CONFIGURATION.md +++ b/docs/CONFIGURATION.md @@ -408,45 +408,53 @@ Cleanup before deletion: Maestro includes a Model Context Protocol (MCP) server for AI assistant integration. -### Adding Maestro to Claude Code +### Setup Instructions Use the modern `claude mcp add` command: +#### Local Scope (Default - only for current project, private to you) ```bash -# User scope (available across all projects on the machine) -claude mcp add maestro -s user -- npx -y @camoneart/maestro mcp serve +claude mcp add maestro -s local -- npx -y @camoneart/maestro maestro-mcp-server +# Or without -s flag (local is default) +claude mcp add maestro -- npx -y @camoneart/maestro maestro-mcp-server +``` -# Project scope (saved in .mcp.json for team sharing via version control) -claude mcp add maestro -s project -- npx -y @camoneart/maestro mcp serve +#### Project Scope (saved in .mcp.json for team sharing via version control) +```bash +claude mcp add maestro -s project -- npx -y @camoneart/maestro maestro-mcp-server +``` -# Local scope (default - only for current project, private to you) -claude mcp add maestro -s local -- npx -y @camoneart/maestro mcp serve +#### User Scope (available across all projects on the machine) +```bash +claude mcp add maestro -s user -- npx -y @camoneart/maestro maestro-mcp-server +``` -# For global installation (use 'maestro' instead of 'npx') -claude mcp add maestro -s user -- maestro mcp serve +#### For global installation +If you've installed Maestro globally: +```bash +claude mcp add maestro -s user -- maestro-mcp-server ``` -### JSON Configuration Alternative +### Alternative Setup You can also use JSON configuration with the `claude mcp add-json` command: ```bash # Using JSON format -claude mcp add-json maestro -s user '{"type":"stdio","command":"npx","args":["-y","@camoneart/maestro","mcp","serve"]}' +claude mcp add-json maestro -s user '{"type":"stdio","command":"npx","args":["-y","@camoneart/maestro","maestro-mcp-server"]}' # For global installation -claude mcp add-json maestro -s user '{"type":"stdio","command":"maestro","args":["mcp","serve"]}' +claude mcp add-json maestro -s user '{"type":"stdio","command":"maestro-mcp-server","args":[]}' ``` **Note**: The traditional manual configuration in `.claude/mcp_settings.json` is no longer supported. ### Available MCP Tools -When integrated, AI assistants can: -- Create and manage worktrees -- Execute commands in specific worktrees -- List all orchestra members with status -- Delete worktrees safely +- `create_orchestra_member` - Create new worktrees with optional base branch +- `delete_orchestra_member` - Remove worktrees with force option +- `exec_in_orchestra_member` - Execute commands within specific worktrees +- `list_orchestra_members` - List all active worktrees with status The MCP server respects all Maestro configuration settings including hooks, sync files, and Claude markdown modes. diff --git a/docs/commands/completion.md b/docs/commands/completion.md index 5e9b89c..80579a0 100644 --- a/docs/commands/completion.md +++ b/docs/commands/completion.md @@ -59,7 +59,7 @@ All main commands and aliases are completed: ```bash mst # Suggests: create, list, delete, shell, exec, attach, github, -# config, mcp, completion, tmux, where +# config, completion, tmux, where # ls, rm, sh, e, a, gh, t, w (aliases) ``` diff --git a/docs/commands/mcp.md b/docs/commands/mcp.md deleted file mode 100644 index 00d6925..0000000 --- a/docs/commands/mcp.md +++ /dev/null @@ -1,206 +0,0 @@ -# 🔸 mcp - -Command to start the MCP (Model Context Protocol) server for maestro. Enables Claude Code and Cursor integration to manage orchestra members through AI interfaces. - -## Overview - -```bash -mst mcp [subcommand] -``` - -## Usage Examples - -### Basic Usage - -```bash -# Display MCP server information -mst mcp - -# Start MCP server -mst mcp serve -``` - -## Subcommands - -| Subcommand | Description | Usage | -|------------|-------------|-------| -| `serve` | Start MCP server for AI integration | `mst mcp serve` | - -## MCP Server Integration - -### Starting the Server - -```bash -mst mcp serve -``` - -**Output:** -``` -🎼 orchestra-conductor MCPサーバーを起動中... - -Claude Codeに追加するには以下のコマンドを使用してください: - -# ユーザースコープ(マシン上の全プロジェクトで利用可能) -claude mcp add maestro -s user -- npx -y @camoneart/maestro mcp serve - -# プロジェクトスコープ(.mcp.jsonに保存、バージョン管理でチーム共有) -claude mcp add maestro -s project -- npx -y @camoneart/maestro mcp serve - -# ローカルスコープ(デフォルト - 現在のプロジェクトでのみ、個人専用) -claude mcp add maestro -s local -- npx -y @camoneart/maestro mcp serve -``` - -### Claude Code Integration - -Add Maestro as an MCP server using the modern command: - -```bash -# User scope (available across all projects on the machine) -claude mcp add maestro -s user -- npx -y @camoneart/maestro mcp serve - -# Project scope (saved in .mcp.json for team sharing via version control) -claude mcp add maestro -s project -- npx -y @camoneart/maestro mcp serve - -# Local scope (default - only for current project, private to you) -claude mcp add maestro -s local -- npx -y @camoneart/maestro mcp serve - -# For global installation (use 'maestro' instead of 'npx') -claude mcp add maestro -s user -- maestro mcp serve -``` - -**Scope options explained:** -- `user`: Available across all projects on the machine, private to your user account -- `project`: Saved in `.mcp.json` at project root, designed for team sharing via version control -- `local`: Default setting, only accessible when working within the current project directory, private to you - -Alternatively, you can use JSON configuration with the `claude mcp add-json` command: - -```bash -claude mcp add-json maestro -s user '{"type":"stdio","command":"npx","args":["-y","@camoneart/maestro","mcp","serve"]}' -``` - -### Cursor Integration - -Add to your Cursor settings: - -```json -{ - "mcp": { - "servers": { - "maestro": { - "command": "maestro", - "args": ["mcp", "serve"] - } - } - } -} -``` - -## Available MCP Tools - -When the MCP server is running, the following tools become available to AI assistants: - -### Worktree Management -- **Create worktrees** from branches or issues -- **List all worktrees** with status information -- **Delete worktrees** safely -- **Switch between worktrees** - -### Git Operations -- **Branch management** -- **Commit operations** -- **Status checking** - -### GitHub Integration -- **Issue management** -- **Pull request operations** -- **Repository information** - -## Server Lifecycle - -### Starting the Server - -The MCP server runs as a persistent process: - -```bash -mst mcp serve -# Server starts and waits for MCP client connections -# Press Ctrl+C to stop -``` - -### Stopping the Server - -```bash -# From the running server terminal -Ctrl+C - -# Or from another terminal -pkill -f "maestro mcp serve" -``` - -## Configuration - -### Server Settings - -The MCP server automatically: -- Detects the current Git repository -- Loads maestro configuration -- Provides context-aware tools to AI clients - -### Security Considerations - -- **Local only**: MCP server only accepts local connections -- **Repository scope**: Operations are limited to the current Git repository -- **Safe operations**: Destructive operations require confirmation - -## Troubleshooting - -### Common Issues - -1. **Server fails to start** - ```bash - # Check if maestro is properly installed - which maestro - - # Verify in Git repository - git status - ``` - -2. **AI client can't connect** - ```bash - # Verify MCP server is running - ps aux | grep "maestro mcp" - - # Check client configuration - # Ensure command path is correct - ``` - -3. **Tools not available in AI client** - ```bash - # Restart MCP server - # Restart AI client - # Verify configuration syntax - ``` - -## Development - -### MCP Protocol - -The server implements the Model Context Protocol specification: -- **Tools**: Exposed functions for worktree management -- **Resources**: Git repository information -- **Prompts**: Context-aware suggestions - -### Server Implementation - -Located at `src/mcp/server.ts`, the server provides: -- Git worktree operations -- GitHub API integration -- Configuration management -- Safe execution environment - -## Related Commands - -- [`mst create`](./create.md) - Create worktrees (available via MCP) -- [`mst list`](./list.md) - List worktrees (available via MCP) -- [`mst delete`](./delete.md) - Orchestra members exit (available via MCP) \ No newline at end of file diff --git a/package.json b/package.json index 93f7725..dad7f97 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,8 @@ "type": "module", "bin": { "maestro": "./dist/cli.js", - "mst": "./dist/cli.js" + "mst": "./dist/cli.js", + "maestro-mcp-server": "./dist/mcp/server.js" }, "files": [ "dist", diff --git a/src/__tests__/commands/mcp.test.ts b/src/__tests__/commands/mcp.test.ts deleted file mode 100644 index cba13a8..0000000 --- a/src/__tests__/commands/mcp.test.ts +++ /dev/null @@ -1,77 +0,0 @@ -import { describe, it, expect, vi, beforeEach, type Mock } from 'vitest' -import { mcpCommand } from '../../commands/mcp.js' -import { spawn } from 'child_process' -import chalk from 'chalk' - -vi.mock('child_process', () => ({ - spawn: vi.fn(), -})) - -describe('mcp command', () => { - let consoleLogSpy: Mock - - beforeEach(() => { - vi.clearAllMocks() - consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => {}) - vi.spyOn(console, 'error').mockImplementation(() => {}) - vi.spyOn(process, 'exit').mockImplementation((code?: string | number | null) => { - throw new Error(`Process exited with code ${code}`) - }) - }) - - describe('basic functionality', () => { - it('should show usage when no subcommand is provided', async () => { - await expect(mcpCommand.parseAsync(['node', 'mcp'])).rejects.toThrow( - 'Process exited with code 0' - ) - - expect(consoleLogSpy).toHaveBeenCalledWith(chalk.yellow('使い方: maestro mcp serve')) - }) - - it('should start MCP server with serve subcommand', async () => { - const mockChildProcess = { - on: vi.fn(), - killed: false, - } - ;(spawn as Mock).mockReturnValue(mockChildProcess) - - await mcpCommand.parseAsync(['node', 'mcp', 'serve']) - - expect(spawn).toHaveBeenCalledWith( - 'node', - expect.any(Array), - expect.objectContaining({ - stdio: 'inherit', - }) - ) - }) - - it('should resolve correct path to MCP server module', async () => { - const mockChildProcess = { - on: vi.fn(), - killed: false, - } - ;(spawn as Mock).mockReturnValue(mockChildProcess) - - await mcpCommand.parseAsync(['node', 'mcp', 'serve']) - - const spawnCall = (spawn as Mock).mock.calls[0] - const serverPath = spawnCall[1][0] - - // パスがmcp/server.jsで終わることを確認(テスト環境を考慮) - expect(serverPath).toMatch(/mcp[/\\]server\.js$/) - - // パスが文字列であることを確認 - expect(typeof serverPath).toBe('string') - expect(serverPath.length).toBeGreaterThan(0) - }) - - it('should show usage for invalid subcommand', async () => { - await expect(mcpCommand.parseAsync(['node', 'mcp', 'unknown'])).rejects.toThrow( - 'Process exited with code 0' - ) - - expect(consoleLogSpy).toHaveBeenCalledWith(chalk.yellow('使い方: maestro mcp serve')) - }) - }) -}) diff --git a/src/cli.ts b/src/cli.ts index 457c079..97f5fb5 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -13,7 +13,6 @@ import { deleteCommand } from './commands/delete.js' import { shellCommand } from './commands/shell.js' import { execCommand } from './commands/exec.js' import { attachCommand } from './commands/attach.js' -import { mcpCommand } from './commands/mcp.js' import { configCommand } from './commands/config.js' import { githubCommand } from './commands/github.js' import { completionCommand } from './commands/completion.js' @@ -45,7 +44,6 @@ program.addCommand(deleteCommand) program.addCommand(shellCommand) program.addCommand(execCommand) program.addCommand(attachCommand) -program.addCommand(mcpCommand) program.addCommand(configCommand) program.addCommand(githubCommand) program.addCommand(completionCommand) diff --git a/src/commands/completion.ts b/src/commands/completion.ts index 1c01cf6..f7abb71 100644 --- a/src/commands/completion.ts +++ b/src/commands/completion.ts @@ -12,7 +12,7 @@ const BASH_COMPLETION = [ ' prev="${COMP_WORDS[COMP_CWORD - 1]}"', ' ', ' # コマンド一覧', - ' local commands="create list delete shell exec attach github config mcp completion tmux where sync review issue history graph watch health snapshot init push"', + ' local commands="create list delete shell exec attach github config completion tmux where sync review issue history graph watch health snapshot init push"', ' local aliases="ls rm sh e a gh t w i"', ' ', ' # 最初の引数の場合', @@ -47,11 +47,6 @@ const BASH_COMPLETION = [ ' COMPREPLY=( $(compgen -W "init show path" -- ${cur}) )', ' fi', ' ;;', - ' mcp)', - ' if [[ ${COMP_CWORD} -eq 2 ]]; then', - ' COMPREPLY=( $(compgen -W "serve" -- ${cur}) )', - ' fi', - ' ;;', ' completion)', ' if [[ ${COMP_CWORD} -eq 2 ]]; then', ' COMPREPLY=( $(compgen -W "bash zsh fish" -- ${cur}) )', @@ -128,7 +123,6 @@ const ZSH_COMPLETION = [ " 'attach:既存のブランチから演奏者を招集する'", " 'github:GitHub PR/Issueから演奏者を招集する'", " 'config:設定を管理'", - " 'mcp:MCPサーバーを起動'", " 'completion:シェル補完スクリプトを生成'", " 'tmux:tmux/fzfで演奏者を選択して開く'", " 'where:演奏者のパスを表示'", @@ -210,11 +204,6 @@ const ZSH_COMPLETION = [ " '-g[グローバル設定を対象にする]' \\", " '--global[グローバル設定を対象にする]'", ' ;;', - ' mcp)', - ' if (( CURRENT == 3 )); then', - " _values 'subcommand' 'serve'", - ' fi', - ' ;;', ' completion)', ' if (( CURRENT == 3 )); then', " _values 'shell' 'bash' 'zsh' 'fish'", @@ -278,7 +267,6 @@ const FISH_COMPLETION = [ 'complete -c maestro -n "__fish_use_subcommand" -a "attach a" -d "既存のブランチから演奏者を招集する"', 'complete -c maestro -n "__fish_use_subcommand" -a "github gh" -d "GitHub PR/Issueから演奏者を招集する"', 'complete -c maestro -n "__fish_use_subcommand" -a "config" -d "設定を管理"', - 'complete -c maestro -n "__fish_use_subcommand" -a "mcp" -d "MCPサーバーを起動"', 'complete -c maestro -n "__fish_use_subcommand" -a "completion" -d "シェル補完スクリプトを生成"', 'complete -c maestro -n "__fish_use_subcommand" -a "tmux t" -d "tmux/fzfで演奏者を選択して開く"', 'complete -c maestro -n "__fish_use_subcommand" -a "where w" -d "演奏者のパスを表示"', @@ -340,7 +328,6 @@ const FISH_COMPLETION = [ '', '# サブコマンドの引数補完', 'complete -c maestro -n "__fish_seen_subcommand_from config; and __fish_is_nth_token 3" -a "init show path"', - 'complete -c maestro -n "__fish_seen_subcommand_from mcp; and __fish_is_nth_token 3" -a "serve"', 'complete -c maestro -n "__fish_seen_subcommand_from completion; and __fish_is_nth_token 3" -a "bash zsh fish"', 'complete -c maestro -n "__fish_seen_subcommand_from github gh; and __fish_is_nth_token 3" -a "checkout pr issue"', 'complete -c maestro -n "__fish_seen_subcommand_from issue i; and __fish_is_nth_token 3" -a "list"', diff --git a/src/commands/mcp.ts b/src/commands/mcp.ts deleted file mode 100644 index 177d181..0000000 --- a/src/commands/mcp.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { Command } from 'commander' -import chalk from 'chalk' -import { spawn } from 'child_process' -import path from 'path' -import { fileURLToPath } from 'url' -import { processManager } from '../utils/process.js' - -const __dirname = path.dirname(fileURLToPath(import.meta.url)) - -export const mcpCommand = new Command('mcp') - .description('MCPサーバーを起動') - .argument('[subcommand]', 'サブコマンド (serve)') - .exitOverride() - .action(async (subcommand?: string) => { - if (subcommand !== 'serve') { - console.log(chalk.yellow('使い方: maestro mcp serve')) - console.log( - chalk.gray('\nMCPサーバーを起動して、Claude CodeやCursorから演奏者を操作できるようにします') - ) - process.exit(0) - } - - console.log(chalk.green('🎼 orchestra-conductor MCPサーバーを起動中...')) - console.log(chalk.gray('\nClaude Codeに追加するには以下のコマンドを使用してください:')) - console.log( - chalk.cyan(` -# ユーザースコープ(マシン上の全プロジェクトで利用可能) -claude mcp add maestro -s user -- npx -y @camoneart/maestro mcp serve - -# プロジェクトスコープ(.mcp.jsonに保存、バージョン管理でチーム共有) -claude mcp add maestro -s project -- npx -y @camoneart/maestro mcp serve - -# ローカルスコープ(デフォルト - 現在のプロジェクトでのみ、個人専用) -claude mcp add maestro -s local -- npx -y @camoneart/maestro mcp serve -`) - ) - - // MCPサーバーを起動 - const serverPath = path.join(__dirname, 'mcp', 'server.js') - const serverProcess = spawn('node', [serverPath], { - stdio: 'inherit', - env: { - ...process.env, - }, - }) - - serverProcess.on('error', error => { - console.error(chalk.red('MCPサーバーの起動に失敗しました:'), error.message) - process.exit(1) - }) - - serverProcess.on('exit', code => { - if (code !== 0) { - console.error(chalk.red(`MCPサーバーが異常終了しました (exit code: ${code})`)) - process.exit(code || 1) - } - }) - - // MCPサーバープロセスのクリーンアップを登録 - processManager.addCleanupHandler(() => { - if (serverProcess && !serverProcess.killed && typeof serverProcess.kill === 'function') { - serverProcess.kill('SIGTERM') - } - }) - })