ai-cli-mcp 2.11.0 → 2.13.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 (55) hide show
  1. package/.github/workflows/publish.yml +25 -0
  2. package/CHANGELOG.md +23 -0
  3. package/README.ja.md +112 -8
  4. package/README.md +112 -9
  5. package/dist/__tests__/app-cli.test.js +293 -0
  6. package/dist/__tests__/cli-bin-smoke.test.js +58 -0
  7. package/dist/__tests__/cli-builder.test.js +37 -0
  8. package/dist/__tests__/cli-process-service.test.js +279 -0
  9. package/dist/__tests__/cli-utils.test.js +140 -0
  10. package/dist/__tests__/error-cases.test.js +2 -1
  11. package/dist/__tests__/mcp-contract.test.js +343 -0
  12. package/dist/__tests__/parsers.test.js +37 -1
  13. package/dist/__tests__/process-management.test.js +15 -8
  14. package/dist/__tests__/server.test.js +29 -3
  15. package/dist/__tests__/wait.test.js +31 -0
  16. package/dist/app/cli.js +304 -0
  17. package/dist/app/mcp.js +366 -0
  18. package/dist/bin/ai-cli-mcp.js +6 -0
  19. package/dist/bin/ai-cli.js +10 -0
  20. package/dist/cli-builder.js +15 -6
  21. package/dist/cli-parse.js +8 -5
  22. package/dist/cli-process-service.js +332 -0
  23. package/dist/cli-utils.js +159 -88
  24. package/dist/cli.js +4 -3
  25. package/dist/model-catalog.js +53 -0
  26. package/dist/parsers.js +55 -0
  27. package/dist/process-service.js +201 -0
  28. package/dist/server.js +4 -578
  29. package/docs/cli-architecture.md +275 -0
  30. package/package.json +4 -3
  31. package/server.json +1 -1
  32. package/src/__tests__/app-cli.test.ts +370 -0
  33. package/src/__tests__/cli-bin-smoke.test.ts +75 -0
  34. package/src/__tests__/cli-builder.test.ts +47 -0
  35. package/src/__tests__/cli-process-service.test.ts +334 -0
  36. package/src/__tests__/cli-utils.test.ts +166 -0
  37. package/src/__tests__/error-cases.test.ts +3 -4
  38. package/src/__tests__/mcp-contract.test.ts +422 -0
  39. package/src/__tests__/parsers.test.ts +44 -1
  40. package/src/__tests__/process-management.test.ts +15 -9
  41. package/src/__tests__/server.test.ts +27 -6
  42. package/src/__tests__/wait.test.ts +38 -0
  43. package/src/app/cli.ts +373 -0
  44. package/src/app/mcp.ts +402 -0
  45. package/src/bin/ai-cli-mcp.ts +7 -0
  46. package/src/bin/ai-cli.ts +11 -0
  47. package/src/cli-builder.ts +19 -10
  48. package/src/cli-parse.ts +8 -5
  49. package/src/cli-process-service.ts +418 -0
  50. package/src/cli-utils.ts +205 -99
  51. package/src/cli.ts +4 -3
  52. package/src/model-catalog.ts +64 -0
  53. package/src/parsers.ts +61 -0
  54. package/src/process-service.ts +263 -0
  55. package/src/server.ts +4 -668
@@ -43,22 +43,47 @@ jobs:
43
43
  - name: Verify provenance attestations
44
44
  run: npm audit signatures
45
45
 
46
+ - name: Capture version before release
47
+ id: release_before
48
+ run: |
49
+ VERSION=$(node -p 'require("./package.json").version')
50
+ echo "version=$VERSION" >> "$GITHUB_OUTPUT"
51
+
46
52
  - name: Release
47
53
  env:
48
54
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49
55
  run: npx semantic-release
50
56
 
57
+ - name: Capture version after release
58
+ id: release_after
59
+ run: |
60
+ VERSION=$(node -p 'require("./package.json").version')
61
+ echo "version=$VERSION" >> "$GITHUB_OUTPUT"
62
+
63
+ - name: Detect whether a release was published
64
+ id: release_status
65
+ run: |
66
+ if [ "${{ steps.release_before.outputs.version }}" != "${{ steps.release_after.outputs.version }}" ]; then
67
+ echo "published=true" >> "$GITHUB_OUTPUT"
68
+ else
69
+ echo "published=false" >> "$GITHUB_OUTPUT"
70
+ fi
71
+
51
72
  - name: Install mcp-publisher
73
+ if: steps.release_status.outputs.published == 'true'
52
74
  run: |
53
75
  curl -L "https://github.com/modelcontextprotocol/registry/releases/latest/download/mcp-publisher_$(uname -s | tr '[:upper:]' '[:lower:]')_$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/').tar.gz" | tar xz mcp-publisher
54
76
 
55
77
  - name: Authenticate to MCP Registry
78
+ if: steps.release_status.outputs.published == 'true'
56
79
  run: ./mcp-publisher login github-oidc
57
80
 
58
81
  - name: Set version in server.json
82
+ if: steps.release_status.outputs.published == 'true'
59
83
  run: |
60
84
  VERSION=$(node -p "require('./package.json').version")
61
85
  jq --arg v "$VERSION" '.version = $v | .packages[0].version = $v' server.json > server.tmp && mv server.tmp server.json
62
86
 
63
87
  - name: Publish to MCP Registry
88
+ if: steps.release_status.outputs.published == 'true'
64
89
  run: ./mcp-publisher publish
package/CHANGELOG.md CHANGED
@@ -1,3 +1,26 @@
1
+ # [2.13.0](https://github.com/mkXultra/ai-cli-mcp/compare/v2.12.0...v2.13.0) (2026-04-07)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **ci:** correct release version capture shell quoting ([2986b0b](https://github.com/mkXultra/ai-cli-mcp/commit/2986b0bb0452fcf4b34491c3d832cff3b271616c))
7
+ * **ci:** skip MCP Registry publish when no release is created ([9de4c83](https://github.com/mkXultra/ai-cli-mcp/commit/9de4c836a946b4a0028a46525b4bcfa2094032cc))
8
+
9
+
10
+ ### Features
11
+
12
+ * Forge CLIを新しいAIバックエンドとして追加 ([35ae860](https://github.com/mkXultra/ai-cli-mcp/commit/35ae8604ff0a663e960fc758eee2872680aec503))
13
+
14
+ # [2.12.0](https://github.com/mkXultra/ai-cli-mcp/compare/v2.11.0...v2.12.0) (2026-03-12)
15
+
16
+
17
+ ### Features
18
+
19
+ * ai-cliコマンドを追加しアーキテクチャをリファクタリング ([10a1209](https://github.com/mkXultra/ai-cli-mcp/commit/10a120933d5893d47e47001a165f0abc5e4557aa))
20
+ * CliProcessServiceとCLIサブコマンドを追加 ([0043ee4](https://github.com/mkXultra/ai-cli-mcp/commit/0043ee4a73bbf2d48f57b0b0ded8f12e29e8ebf2))
21
+ * CLIサブコマンドhelpとcleanupを追加し状態保存先を再設計 ([63dc1a2](https://github.com/mkXultra/ai-cli-mcp/commit/63dc1a238e9883cab04e818413576ad265b600ab))
22
+ * doctorとmodelsサブコマンドを追加しモデルカタログをモジュール化 ([15222e3](https://github.com/mkXultra/ai-cli-mcp/commit/15222e3c29c18bc16fa0bc7d6c4f3bdc621f6ff6))
23
+
1
24
  # [2.11.0](https://github.com/mkXultra/ai-cli-mcp/compare/v2.10.0...v2.11.0) (2026-03-08)
2
25
 
3
26
 
package/README.ja.md CHANGED
@@ -5,10 +5,14 @@
5
5
 
6
6
  > **📦 パッケージ移行のお知らせ**: 本パッケージは旧名 `@mkxultra/claude-code-mcp` から `ai-cli-mcp` に名称変更されました。これは、複数のAI CLIツールのサポート拡大を反映したものです。
7
7
 
8
- AI CLIツール(Claude, Codex, Gemini)をバックグラウンドプロセスとして実行し、権限処理を自動化するMCP(Model Context Protocol)サーバーです。
8
+ AI CLIツール(Claude, Codex, Gemini, Forge)をバックグラウンドプロセスとして実行し、権限処理を自動化するMCP(Model Context Protocol)サーバーです。
9
9
 
10
10
  Cursorなどのエディタが、複雑な手順を伴う編集や操作に苦戦していることに気づいたことはありませんか?このサーバーは、強力な統合 `run` ツールを提供し、複数のAIエージェントを活用してコーディングタスクをより効果的に処理できるようにします。
11
11
 
12
+ ## デモ
13
+
14
+ [![デモ](docs/assets/demo-jp.gif)](https://github.com/mkXultra/ai-cli-mcp/releases/download/v2.11.0/demo-jp.mp4)
15
+
12
16
  ## 概要
13
17
 
14
18
  このMCPサーバーは、LLMがAI CLIツールと対話するためのツールを提供します。MCPクライアントと統合することで、LLMは以下のことが可能になります:
@@ -16,10 +20,12 @@ Cursorなどのエディタが、複雑な手順を伴う編集や操作に苦
16
20
  - すべての権限確認をスキップしてClaude CLIを実行(`--dangerously-skip-permissions` を使用)
17
21
  - 自動承認モードでCodex CLIを実行(`--full-auto` を使用)
18
22
  - 自動承認モードでGemini CLIを実行(`-y` を使用)
23
+ - Forge CLI を非対話モードで実行(`forge -C <workFolder> -p <prompt>` を使用)
19
24
  - 複数のAIモデルのサポート:
20
25
  - Claude (sonnet, sonnet[1m], opus, opusplan, haiku)
21
26
  - Codex (gpt-5.4, gpt-5.3-codex, gpt-5.2-codex, gpt-5.1-codex-mini, gpt-5.1-codex-max, など)
22
27
  - Gemini (gemini-2.5-pro, gemini-2.5-flash, gemini-3.1-pro-preview, gemini-3-pro-preview, gemini-3-flash-preview)
28
+ - Forge (`forge`)
23
29
  - PID追跡によるバックグラウンドプロセスの管理
24
30
  - ツールからの構造化された出力の解析と返却
25
31
 
@@ -45,11 +51,13 @@ Cursorなどのエディタが、複雑な手順を伴う編集や操作に苦
45
51
  > - `gpt-5.2-codex` で `README.md` にアーキテクチャの解説を追記
46
52
  > 4. 最後に再び `wait` して、両方の結果をまとめてください。
47
53
 
54
+ [![セッション再開デモ](docs/assets/demo-resume-jp.gif)](https://github.com/mkXultra/ai-cli-mcp/releases/download/v2.11.0/demo-resume-jp.mp4)
55
+
48
56
  ## メリット
49
57
 
50
58
  - **真の非同期マルチタスク**: エージェントの実行はバックグラウンドで行われ、即座に制御が戻ります。呼び出し元のAIは実行完了を待つことなく、並行して次のタスクの実行や別のエージェントの呼び出しを行うことができます。
51
59
  - **CLI in CLI (Agent in Agent) の実現**: MCPをサポートするあらゆるIDEやCLIから、Claude CodeやCodexといった強力なCLIツールを直接呼び出せます。ホスト環境の制限を超えた、より広範で複雑なシステム操作や自動化が可能になります。
52
- - **モデル・プロバイダの制約からの解放**: 特定のエコシステムに縛られることなく、Claude、Codex (GPT)、Geminiの中から、タスクに最適な「最強のモデル」や「コスト効率の良いモデル」を自由に選択・組み合わせて利用できます。
60
+ - **モデル・プロバイダの制約からの解放**: 特定のエコシステムに縛られることなく、Claude、Codex (GPT)、Gemini、Forgeの中から、タスクに最適な「最強のモデル」や「コスト効率の良いモデル」を自由に選択・組み合わせて利用できます。
53
61
 
54
62
  ## 前提条件
55
63
 
@@ -58,12 +66,20 @@ Cursorなどのエディタが、複雑な手順を伴う編集や操作に苦
58
66
  - **Claude Code**: `claude doctor` が通り、`--dangerously-skip-permissions` での実行が承認済み(一度手動で実行してログイン・承認済み)であること。
59
67
  - **Codex CLI**(オプション): インストール済みで、ログインなどの初期設定が完了していること。
60
68
  - **Gemini CLI**(オプション): インストール済みで、ログインなどの初期設定が完了していること。
69
+ - **Forge CLI**(オプション): インストール済みで、初期設定が完了していること。
61
70
 
62
71
  ## インストールと使い方
63
72
 
64
- 推奨される使用方法は、`npx` を使用してインストールすることです。
73
+ 現在の主な使い方は 2 つあります。
74
+
75
+ - `ai-cli-mcp`: MCP サーバーの起動
76
+ - `ai-cli`: 人間向け CLI
77
+
78
+ ### MCP 利用 (`npx`)
65
79
 
66
- ### MCP設定ファイルでnpxを使用する場合:
80
+ MCP サーバーとして使う場合は、`npx` 経由が推奨です。
81
+
82
+ #### MCP設定ファイルでnpxを使用する場合:
67
83
 
68
84
  ```json
69
85
  "ai-cli-mcp": {
@@ -75,12 +91,47 @@ Cursorなどのエディタが、複雑な手順を伴う編集や操作に苦
75
91
  },
76
92
  ```
77
93
 
78
- ### Claude CLI mcp add コマンドを使用する場合:
94
+ #### Claude CLI mcp add コマンドを使用する場合:
79
95
 
80
96
  ```bash
81
97
  claude mcp add ai-cli '{"name":"ai-cli","command":"npx","args":["-y","ai-cli-mcp@latest"]}'
82
98
  ```
83
99
 
100
+ ### 人間向け CLI 利用 (グローバルインストール)
101
+
102
+ シェルから `ai-cli` を直接使いたい場合は、グローバルインストールしてください。
103
+
104
+ ```bash
105
+ npm install -g ai-cli-mcp
106
+ ```
107
+
108
+ これで以下の 2 つのコマンドが使えるようになります。
109
+
110
+ - `ai-cli`
111
+ - `ai-cli-mcp`
112
+
113
+ 例:
114
+
115
+ ```bash
116
+ ai-cli doctor
117
+ ai-cli models
118
+ ai-cli run --cwd "$PWD" --model sonnet --prompt "summarize this repository"
119
+ ai-cli ps
120
+ ai-cli result 12345
121
+ ai-cli wait 12345 --timeout 300
122
+ ai-cli kill 12345
123
+ ai-cli cleanup
124
+ ai-cli-mcp
125
+ ```
126
+
127
+ ### 人間向け CLI 利用 (`npx`)
128
+
129
+ 公開パッケージ名はまだ `ai-cli-mcp` のままなので、`npx` で `ai-cli` を使う場合は次の形になります。
130
+
131
+ ```bash
132
+ npx -y --package ai-cli-mcp@latest ai-cli run --cwd "$PWD" --model sonnet --prompt "hello"
133
+ ```
134
+
84
135
  ## 重要な初回セットアップ
85
136
 
86
137
  ### Claude CLIの場合:
@@ -112,6 +163,56 @@ gemini auth login
112
163
 
113
164
  macOSでは、これらのツールを初めて実行する際にフォルダへのアクセス許可を求められる場合があります。最初の実行が失敗しても、2回目以降は動作するはずです。
114
165
 
166
+ ## CLI コマンド
167
+
168
+ `ai-cli` は現在以下をサポートしています。
169
+
170
+ - `run`
171
+ - `ps`
172
+ - `result`
173
+ - `wait`
174
+ - `kill`
175
+ - `cleanup`
176
+ - `doctor`
177
+ - `models`
178
+ - `mcp`
179
+
180
+ 基本的な流れ:
181
+
182
+ ```bash
183
+ ai-cli doctor
184
+ ai-cli models
185
+ ai-cli run --cwd "$PWD" --model codex-ultra --prompt "fix failing tests"
186
+ ai-cli ps
187
+ ai-cli wait 12345
188
+ ai-cli result 12345
189
+ ai-cli cleanup
190
+ ```
191
+
192
+ `run` の作業ディレクトリ指定は `--cwd` が基本です。互換性のために `--workFolder` / `--work-folder` も受け付けます。
193
+
194
+ `doctor` は CLI バイナリの存在確認と path 解決だけを行います。ログイン状態や利用規約同意までは確認しません。
195
+
196
+ ## CLI の状態保存先
197
+
198
+ バックグラウンド実行した `ai-cli` の状態は、次のディレクトリに保存されます。
199
+
200
+ ```text
201
+ ~/.local/state/ai-cli/cwds/<normalized-cwd>/<pid>/
202
+ ```
203
+
204
+ 各 PID ディレクトリには以下が入ります。
205
+
206
+ - `meta.json`
207
+ - `stdout.log`
208
+ - `stderr.log`
209
+
210
+ 完了済み・失敗済みの実行は `ai-cli cleanup` で削除できます。`running` のものは保持されます。
211
+
212
+ ## 既知の制約
213
+
214
+ detached 実行された `ai-cli` の自然終了 exit code は、まだ永続化していません。そのため、CLI は出力と running/completed 状態は返せますが、自然終了したバックグラウンド実行の `exitCode` は現時点では保証しません。
215
+
115
216
  ## MCPクライアントへの接続
116
217
 
117
218
  サーバーのセットアップ後、MCPクライアント(CursorやWindsurfなど)の設定ファイル(`mcp.json` や `mcp_config.json`)に設定を追加してください。
@@ -124,7 +225,7 @@ macOSでは、これらのツールを初めて実行する際にフォルダへ
124
225
 
125
226
  ### `run`
126
227
 
127
- Claude CLI、Codex CLI、またはGemini CLIを使用してプロンプトを実行します。モデル名に基づいて適切なCLIが自動的に選択されます。
228
+ Claude CLI、Codex CLIGemini CLI、または Forge CLI を使用してプロンプトを実行します。モデル名に基づいて適切なCLIが自動的に選択されます。
128
229
 
129
230
  **引数:**
130
231
  - `prompt` (string, 任意): AIエージェントに送信するプロンプト。`prompt` または `prompt_file` のいずれかが必須です。
@@ -135,8 +236,9 @@ Claude CLI、Codex CLI、またはGemini CLIを使用してプロンプトを実
135
236
  - Claude: `sonnet`, `sonnet[1m]`, `opus`, `opusplan`, `haiku`
136
237
  - Codex: `gpt-5.4`, `gpt-5.3-codex`, `gpt-5.2-codex`, `gpt-5.1-codex-mini`, `gpt-5.1-codex-max`, `gpt-5.2`, `gpt-5.1`, `gpt-5`
137
238
  - Gemini: `gemini-2.5-pro`, `gemini-2.5-flash`, `gemini-3.1-pro-preview`, `gemini-3-pro-preview`, `gemini-3-flash-preview`
138
- - `reasoning_effort` (string, 任意): Claude と Codex の推論制御。Claude では `--effort` を使います(許容値: "low", "medium", "high")。Codex では `model_reasoning_effort` を使います(許容値: "low", "medium", "high", "xhigh")。
139
- - `session_id` (string, 任意): 以前のセッションを再開するためのセッションID。対応モデル: haiku, sonnet, opus, gemini-2.5-pro, gemini-2.5-flash, gemini-3.1-pro-preview, gemini-3-pro-preview, gemini-3-flash-preview。
239
+ - Forge: `forge`
240
+ - `reasoning_effort` (string, 任意): Claude Codex の推論制御。Claude では `--effort` を使います(許容値: "low", "medium", "high")。Codex では `model_reasoning_effort` を使います(許容値: "low", "medium", "high", "xhigh")。Forge では `reasoning_effort` はサポートしません。
241
+ - `session_id` (string, 任意): 以前のセッションを再開するためのセッションID。対応モデル: haiku, sonnet, opus, gemini-2.5-pro, gemini-2.5-flash, gemini-3.1-pro-preview, gemini-3-pro-preview, gemini-3-flash-preview, forge。
140
242
 
141
243
  ### `wait`
142
244
 
@@ -167,6 +269,7 @@ PIDを指定して、実行中のAIエージェントプロセスを終了しま
167
269
  ## トラブルシューティング
168
270
 
169
271
  - **"Command not found" (claude-code-mcp):** グローバルにインストールした場合、npmのグローバルbinディレクトリがシステムのPATHに含まれているか確認してください。`npx` を使用している場合、`npx` 自体が機能しているか確認してください。
272
+ - **"Command not found" (`ai-cli`):** グローバルインストール時は npm のグローバル bin ディレクトリが `PATH` に入っているか確認してください。`npx` の場合は `npx -y --package ai-cli-mcp@latest ai-cli ...` を使ってください。
170
273
  - **"Command not found" (claude または ~/.claude/local/claude):** Claude CLIが正しくインストールされていることを確認してください。`claude/doctor` を実行するか、公式ドキュメントを確認してください。
171
274
  - **権限の問題:** 「重要な初回セットアップ」の手順を実行したか確認してください。
172
275
  - **サーバーからのJSONエラー:** `MCP_CLAUDE_DEBUG` が `true` の場合、エラーメッセージやログがMCPのJSON解析を妨げる可能性があります。通常動作時は `false` に設定してください。
@@ -197,6 +300,7 @@ npm run test:e2e
197
300
  - `CLAUDE_CLI_NAME`: Claude CLIのバイナリ名または絶対パスを上書き(デフォルト: `claude`)
198
301
  - `CODEX_CLI_NAME`: Codex CLIのバイナリ名または絶対パスを上書き(デフォルト: `codex`)
199
302
  - `GEMINI_CLI_NAME`: Gemini CLIのバイナリ名または絶対パスを上書き(デフォルト: `gemini`)
303
+ - `FORGE_CLI_NAME`: Forge CLIのバイナリ名または絶対パスを上書き(デフォルト: `forge`)
200
304
  - `MCP_CLAUDE_DEBUG`: デバッグログを有効化(`true` に設定すると詳細な出力が表示されます)
201
305
 
202
306
  **CLI名の指定方法:**
package/README.md CHANGED
@@ -7,10 +7,14 @@
7
7
 
8
8
  > **📦 Package Migration Notice**: This package was formerly `@mkxultra/claude-code-mcp` and has been renamed to `ai-cli-mcp` to reflect its expanded support for multiple AI CLI tools.
9
9
 
10
- An MCP (Model Context Protocol) server that allows running AI CLI tools (Claude, Codex, and Gemini) in background processes with automatic permission handling.
10
+ An MCP (Model Context Protocol) server that allows running AI CLI tools (Claude, Codex, Gemini, and Forge) in background processes with automatic permission handling.
11
11
 
12
12
  Did you notice that Cursor sometimes struggles with complex, multi-step edits or operations? This server, with its powerful unified `run` tool, enables multiple AI agents to handle your coding tasks more effectively.
13
13
 
14
+ ## Demo
15
+
16
+ [![Demo](docs/assets/demo.gif)](https://github.com/mkXultra/ai-cli-mcp/releases/download/v2.11.0/demo.mp4)
17
+
14
18
  ## Overview
15
19
 
16
20
  This MCP server provides tools that can be used by LLMs to interact with AI CLI tools. When integrated with MCP clients, it allows LLMs to:
@@ -18,7 +22,8 @@ This MCP server provides tools that can be used by LLMs to interact with AI CLI
18
22
  - Run Claude CLI with all permissions bypassed (using `--dangerously-skip-permissions`)
19
23
  - Execute Codex CLI with automatic approval mode (using `--full-auto`)
20
24
  - Execute Gemini CLI with automatic approval mode (using `-y`)
21
- - Support multiple AI models: Claude (sonnet, sonnet[1m], opus, opusplan, haiku), Codex (gpt-5.4, gpt-5.3-codex, gpt-5.2-codex, gpt-5.1-codex-mini, gpt-5.1-codex-max, gpt-5.2, gpt-5.1, gpt-5.1-codex, gpt-5-codex, gpt-5-codex-mini, gpt-5), and Gemini (gemini-2.5-pro, gemini-2.5-flash, gemini-3.1-pro-preview, gemini-3-pro-preview, gemini-3-flash-preview)
25
+ - Execute Forge CLI in non-interactive mode (using `forge -C <workFolder> -p <prompt>`)
26
+ - Support multiple AI models: Claude (sonnet, sonnet[1m], opus, opusplan, haiku), Codex (gpt-5.4, gpt-5.3-codex, gpt-5.2-codex, gpt-5.1-codex-mini, gpt-5.1-codex-max, gpt-5.2, gpt-5.1, gpt-5.1-codex, gpt-5-codex, gpt-5-codex-mini, gpt-5), Gemini (gemini-2.5-pro, gemini-2.5-flash, gemini-3.1-pro-preview, gemini-3-pro-preview, gemini-3-flash-preview), and Forge (`forge`)
22
27
  - Manage background processes with PID tracking
23
28
  - Parse and return structured outputs from both tools
24
29
 
@@ -44,11 +49,13 @@ You can reuse heavy context (like large codebases) using session IDs to save cos
44
49
  > - Add architecture documentation to `README.md` using `gpt-5.2-codex`
45
50
  > 4. Finally, `wait` again to combine both results.
46
51
 
52
+ [![Session Resume Demo](docs/assets/demo-resume.gif)](https://github.com/mkXultra/ai-cli-mcp/releases/download/v2.11.0/demo-resume.mp4)
53
+
47
54
  ## Benefits
48
55
 
49
56
  - **True Async Multitasking**: Agent execution happens in the background, returning control immediately. The calling AI can proceed with the next task or invoke another agent without waiting for completion.
50
57
  - **CLI in CLI (Agent in Agent)**: Directly invoke powerful CLI tools like Claude Code or Codex from any MCP-supported IDE or CLI. This enables broader, more complex system operations and automation beyond host environment limitations.
51
- - **Freedom from Model/Provider Constraints**: Freely select and combine the "strongest" or "most cost-effective" models from Claude, Codex (GPT), and Gemini without being tied to a specific ecosystem.
58
+ - **Freedom from Model/Provider Constraints**: Freely select and combine the "strongest" or "most cost-effective" models from Claude, Codex (GPT), Gemini, and Forge without being tied to a specific ecosystem.
52
59
 
53
60
  ## Prerequisites
54
61
 
@@ -57,12 +64,20 @@ The only prerequisite is that the AI CLI tools you want to use are locally insta
57
64
  - **Claude Code**: `claude doctor` passes, and execution with `--dangerously-skip-permissions` is approved (you must run it manually once to login and accept terms).
58
65
  - **Codex CLI** (Optional): Installed and initial setup (login etc.) completed.
59
66
  - **Gemini CLI** (Optional): Installed and initial setup (login etc.) completed.
67
+ - **Forge CLI** (Optional): Installed and initial setup completed.
60
68
 
61
69
  ## Installation & Usage
62
70
 
63
- The recommended way to use this server is by installing it by using `npx`.
71
+ There are now two primary ways to use this package:
72
+
73
+ - `ai-cli-mcp`: MCP server entrypoint
74
+ - `ai-cli`: human-facing CLI for background AI runs
75
+
76
+ ### MCP usage with `npx`
64
77
 
65
- ### Using npx in your MCP configuration:
78
+ The recommended way to use the MCP server is via `npx`.
79
+
80
+ #### Using npx in your MCP configuration:
66
81
 
67
82
  ```json
68
83
  "ai-cli-mcp": {
@@ -74,12 +89,47 @@ The recommended way to use this server is by installing it by using `npx`.
74
89
  },
75
90
  ```
76
91
 
77
- ### Using Claude CLI mcp add command:
92
+ #### Using Claude CLI mcp add command:
78
93
 
79
94
  ```bash
80
95
  claude mcp add ai-cli '{"name":"ai-cli","command":"npx","args":["-y","ai-cli-mcp@latest"]}'
81
96
  ```
82
97
 
98
+ ### Human CLI usage with global install
99
+
100
+ If you want to use the production CLI directly from your shell, install the package globally:
101
+
102
+ ```bash
103
+ npm install -g ai-cli-mcp
104
+ ```
105
+
106
+ This exposes both commands:
107
+
108
+ - `ai-cli`
109
+ - `ai-cli-mcp`
110
+
111
+ Examples:
112
+
113
+ ```bash
114
+ ai-cli doctor
115
+ ai-cli models
116
+ ai-cli run --cwd "$PWD" --model sonnet --prompt "summarize this repository"
117
+ ai-cli ps
118
+ ai-cli result 12345
119
+ ai-cli wait 12345 --timeout 300
120
+ ai-cli kill 12345
121
+ ai-cli cleanup
122
+ ai-cli-mcp
123
+ ```
124
+
125
+ ### Human CLI usage with `npx`
126
+
127
+ Because the published package name is still `ai-cli-mcp`, the shortest `npx` form for the CLI is:
128
+
129
+ ```bash
130
+ npx -y --package ai-cli-mcp@latest ai-cli run --cwd "$PWD" --model sonnet --prompt "hello"
131
+ ```
132
+
83
133
  ## Important First-Time Setup
84
134
 
85
135
  ### For Claude CLI:
@@ -111,6 +161,56 @@ gemini auth login
111
161
 
112
162
  macOS might ask for folder permissions the first time any of these tools run. If the first run fails, subsequent runs should work.
113
163
 
164
+ ## CLI Commands
165
+
166
+ `ai-cli` currently supports:
167
+
168
+ - `run`
169
+ - `ps`
170
+ - `result`
171
+ - `wait`
172
+ - `kill`
173
+ - `cleanup`
174
+ - `doctor`
175
+ - `models`
176
+ - `mcp`
177
+
178
+ Example flow:
179
+
180
+ ```bash
181
+ ai-cli doctor
182
+ ai-cli models
183
+ ai-cli run --cwd "$PWD" --model codex-ultra --prompt "fix failing tests"
184
+ ai-cli ps
185
+ ai-cli wait 12345
186
+ ai-cli result 12345
187
+ ai-cli cleanup
188
+ ```
189
+
190
+ `run` accepts `--cwd` as the primary working-directory flag and also accepts the older aliases `--workFolder` / `--work-folder` for compatibility.
191
+
192
+ `doctor` checks only binary existence and path resolution. It does not verify login state or terms acceptance.
193
+
194
+ ## CLI State Storage
195
+
196
+ Background CLI runs are stored under:
197
+
198
+ ```text
199
+ ~/.local/state/ai-cli/cwds/<normalized-cwd>/<pid>/
200
+ ```
201
+
202
+ Each PID directory contains:
203
+
204
+ - `meta.json`
205
+ - `stdout.log`
206
+ - `stderr.log`
207
+
208
+ Use `ai-cli cleanup` to remove completed and failed runs. Running processes are preserved.
209
+
210
+ ## Known Limitation
211
+
212
+ Detached `ai-cli` runs do not currently persist natural process exit codes. As a result, the CLI can report process output and running/completed state, but it does not yet guarantee `exitCode` for naturally finished background runs.
213
+
114
214
  ## Connecting to Your MCP Client
115
215
 
116
216
  After setting up the server, add the configuration to your MCP client's settings file (e.g., `mcp.json` for Cursor, `mcp_config.json` for Windsurf).
@@ -123,7 +223,7 @@ This server exposes the following tools:
123
223
 
124
224
  ### `run`
125
225
 
126
- Executes a prompt using Claude CLI, Codex CLI, or Gemini CLI. The appropriate CLI is automatically selected based on the model name.
226
+ Executes a prompt using Claude CLI, Codex CLI, Gemini CLI, or Forge CLI. The appropriate CLI is automatically selected based on the model name.
127
227
 
128
228
  **Arguments:**
129
229
  - `prompt` (string, optional): The prompt to send to the AI agent. Either `prompt` or `prompt_file` is required.
@@ -134,8 +234,9 @@ Executes a prompt using Claude CLI, Codex CLI, or Gemini CLI. The appropriate CL
134
234
  - Claude: `sonnet`, `sonnet[1m]`, `opus`, `opusplan`, `haiku`
135
235
  - Codex: `gpt-5.4`, `gpt-5.3-codex`, `gpt-5.2-codex`, `gpt-5.1-codex-mini`, `gpt-5.1-codex-max`, `gpt-5.2`, `gpt-5.1`, `gpt-5`
136
236
  - Gemini: `gemini-2.5-pro`, `gemini-2.5-flash`, `gemini-3.1-pro-preview`, `gemini-3-pro-preview`, `gemini-3-flash-preview`
137
- - `reasoning_effort` (string, optional): Reasoning control for Claude and Codex. Claude uses `--effort` (allowed: "low", "medium", "high"). Codex uses `model_reasoning_effort` (allowed: "low", "medium", "high", "xhigh").
138
- - `session_id` (string, optional): Optional session ID to resume a previous session. Supported for: haiku, sonnet, opus, gemini-2.5-pro, gemini-2.5-flash, gemini-3.1-pro-preview, gemini-3-pro-preview, gemini-3-flash-preview.
237
+ - Forge: `forge`
238
+ - `reasoning_effort` (string, optional): Reasoning control for Claude and Codex. Claude uses `--effort` (allowed: "low", "medium", "high"). Codex uses `model_reasoning_effort` (allowed: "low", "medium", "high", "xhigh"). Forge does not support `reasoning_effort`.
239
+ - `session_id` (string, optional): Optional session ID to resume a previous session. Supported for: haiku, sonnet, opus, gemini-2.5-pro, gemini-2.5-flash, gemini-3.1-pro-preview, gemini-3-pro-preview, gemini-3-flash-preview, forge.
139
240
 
140
241
  ### `wait`
141
242
 
@@ -166,6 +267,7 @@ Terminates a running AI agent process by PID.
166
267
  ## Troubleshooting
167
268
 
168
269
  - **"Command not found" (claude-code-mcp):** If installed globally, ensure the npm global bin directory is in your system's PATH. If using `npx`, ensure `npx` itself is working.
270
+ - **"Command not found" (`ai-cli`):** If installed globally, ensure your npm global bin directory is in `PATH`. If using `npx`, use `npx -y --package ai-cli-mcp@latest ai-cli ...`.
169
271
  - **"Command not found" (claude or ~/.claude/local/claude):** Ensure the Claude CLI is installed correctly. Run `claude/doctor` or check its documentation.
170
272
  - **Permissions Issues:** Make sure you've run the "Important First-Time Setup" step.
171
273
  - **JSON Errors from Server:** If `MCP_CLAUDE_DEBUG` is `true`, error messages or logs might interfere with MCP's JSON parsing. Set to `false` for normal operation.
@@ -182,6 +284,7 @@ Normally not required, but useful for customizing CLI paths or debugging.
182
284
  - `CLAUDE_CLI_NAME`: Override the Claude CLI binary name or provide an absolute path (default: `claude`)
183
285
  - `CODEX_CLI_NAME`: Override the Codex CLI binary name or provide an absolute path (default: `codex`)
184
286
  - `GEMINI_CLI_NAME`: Override the Gemini CLI binary name or provide an absolute path (default: `gemini`)
287
+ - `FORGE_CLI_NAME`: Override the Forge CLI binary name or provide an absolute path (default: `forge`)
185
288
  - `MCP_CLAUDE_DEBUG`: Enable debug logging (set to `true` for verbose output)
186
289
 
187
290
  **CLI Name Specification:**