ai-cli-mcp 2.0.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.
- package/.claude/settings.local.json +19 -0
- package/.github/workflows/ci.yml +31 -0
- package/.github/workflows/test.yml +43 -0
- package/.vscode/settings.json +3 -0
- package/AGENT.md +57 -0
- package/CHANGELOG.md +126 -0
- package/LICENSE +22 -0
- package/README.md +329 -0
- package/RELEASE.md +74 -0
- package/data/rooms/refactor-haiku-alias-main/messages.jsonl +5 -0
- package/data/rooms/refactor-haiku-alias-main/presence.json +20 -0
- package/data/rooms.json +10 -0
- package/dist/__tests__/e2e.test.js +238 -0
- package/dist/__tests__/edge-cases.test.js +135 -0
- package/dist/__tests__/error-cases.test.js +296 -0
- package/dist/__tests__/mocks.js +32 -0
- package/dist/__tests__/model-alias.test.js +36 -0
- package/dist/__tests__/process-management.test.js +632 -0
- package/dist/__tests__/server.test.js +665 -0
- package/dist/__tests__/setup.js +11 -0
- package/dist/__tests__/utils/claude-mock.js +80 -0
- package/dist/__tests__/utils/mcp-client.js +104 -0
- package/dist/__tests__/utils/persistent-mock.js +25 -0
- package/dist/__tests__/utils/test-helpers.js +11 -0
- package/dist/__tests__/validation.test.js +212 -0
- package/dist/__tests__/version-print.test.js +69 -0
- package/dist/parsers.js +54 -0
- package/dist/server.js +614 -0
- package/docs/RELEASE_CHECKLIST.md +26 -0
- package/docs/e2e-testing.md +148 -0
- package/docs/local_install.md +111 -0
- package/hello.txt +3 -0
- package/implementation-log.md +110 -0
- package/implementation-plan.md +189 -0
- package/investigation-report.md +135 -0
- package/package.json +53 -0
- package/print-eslint-config.js +3 -0
- package/quality-score.json +47 -0
- package/refactoring-requirements.md +25 -0
- package/review-report.md +132 -0
- package/scripts/check-version-log.sh +34 -0
- package/scripts/publish-release.sh +95 -0
- package/scripts/restore-config.sh +28 -0
- package/scripts/test-release.sh +69 -0
- package/src/__tests__/e2e.test.ts +290 -0
- package/src/__tests__/edge-cases.test.ts +181 -0
- package/src/__tests__/error-cases.test.ts +378 -0
- package/src/__tests__/mocks.ts +35 -0
- package/src/__tests__/model-alias.test.ts +44 -0
- package/src/__tests__/process-management.test.ts +772 -0
- package/src/__tests__/server.test.ts +851 -0
- package/src/__tests__/setup.ts +13 -0
- package/src/__tests__/utils/claude-mock.ts +87 -0
- package/src/__tests__/utils/mcp-client.ts +129 -0
- package/src/__tests__/utils/persistent-mock.ts +29 -0
- package/src/__tests__/utils/test-helpers.ts +13 -0
- package/src/__tests__/validation.test.ts +258 -0
- package/src/__tests__/version-print.test.ts +86 -0
- package/src/parsers.ts +55 -0
- package/src/server.ts +735 -0
- package/start.bat +9 -0
- package/start.sh +21 -0
- package/test-results.md +119 -0
- package/test-standalone.js +5877 -0
- package/tsconfig.json +16 -0
- package/vitest.config.e2e.ts +27 -0
- package/vitest.config.ts +22 -0
- package/vitest.config.unit.ts +29 -0
- package/xx.txt +1 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"permissions": {
|
|
3
|
+
"allow": [
|
|
4
|
+
"Bash(npm run build:*)",
|
|
5
|
+
"Bash(npm test:*)",
|
|
6
|
+
"Bash(npx vitest run:*)",
|
|
7
|
+
"Bash(rg:*)",
|
|
8
|
+
"Bash(grep:*)",
|
|
9
|
+
"Bash(chmod:*)",
|
|
10
|
+
"Bash(npx:*)",
|
|
11
|
+
"mcp__ccm__claude_code",
|
|
12
|
+
"mcp__ccm__get_claude_result",
|
|
13
|
+
"mcp__chat__agent_communication_list_rooms",
|
|
14
|
+
"mcp__chat__agent_communication_get_messages",
|
|
15
|
+
"mcp__ccm__list_claude_processes"
|
|
16
|
+
],
|
|
17
|
+
"deny": []
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
name: Node.js CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ main ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ main ]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
build:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
|
|
13
|
+
strategy:
|
|
14
|
+
matrix:
|
|
15
|
+
node-version: [20.x, 22.x]
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- name: Checkout repository
|
|
19
|
+
uses: actions/checkout@v4
|
|
20
|
+
|
|
21
|
+
- name: Set up Node.js ${{ matrix.node-version }}
|
|
22
|
+
uses: actions/setup-node@v4
|
|
23
|
+
with:
|
|
24
|
+
node-version: ${{ matrix.node-version }}
|
|
25
|
+
cache: 'npm'
|
|
26
|
+
|
|
27
|
+
- name: Install dependencies
|
|
28
|
+
run: npm ci
|
|
29
|
+
|
|
30
|
+
- name: Build project
|
|
31
|
+
run: npm run build
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
name: Tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ main ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ main ]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: macos-latest
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
node-version: [20.x, 22.x]
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
|
|
19
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
20
|
+
uses: actions/setup-node@v4
|
|
21
|
+
with:
|
|
22
|
+
node-version: ${{ matrix.node-version }}
|
|
23
|
+
|
|
24
|
+
- name: Install dependencies
|
|
25
|
+
run: npm ci
|
|
26
|
+
|
|
27
|
+
- name: Build
|
|
28
|
+
run: npm run build
|
|
29
|
+
|
|
30
|
+
- name: Run unit tests only
|
|
31
|
+
run: npm run test:unit
|
|
32
|
+
|
|
33
|
+
- name: Run all tests with coverage
|
|
34
|
+
run: npm run test:coverage
|
|
35
|
+
|
|
36
|
+
- name: Upload coverage to Codecov
|
|
37
|
+
uses: codecov/codecov-action@v4
|
|
38
|
+
if: matrix.node-version == '20.x'
|
|
39
|
+
with:
|
|
40
|
+
token: ${{ secrets.CODECOV_TOKEN }}
|
|
41
|
+
file: ./coverage/coverage-final.json
|
|
42
|
+
flags: unittests
|
|
43
|
+
name: codecov-umbrella
|
package/AGENT.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# AGENT.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Repository Purpose
|
|
6
|
+
|
|
7
|
+
This is the source code for the Claude Code MCP tool - a server that allows running Claude Code in one-shot mode with permissions bypassed automatically. When you're asked to edit the Claude Code tool description or behavior, update it in `src/server.ts`.
|
|
8
|
+
|
|
9
|
+
## Key Files
|
|
10
|
+
|
|
11
|
+
- `src/server.ts`: The main server implementation containing the Claude Code tool description and functionality
|
|
12
|
+
- `package.json`: Package configuration and dependencies
|
|
13
|
+
- `start.sh`/`start.bat`: Scripts to start the server
|
|
14
|
+
|
|
15
|
+
## Development Commands
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# Install dependencies
|
|
19
|
+
npm install
|
|
20
|
+
|
|
21
|
+
# Build the project
|
|
22
|
+
npm run build
|
|
23
|
+
|
|
24
|
+
# Start the server
|
|
25
|
+
npm run start
|
|
26
|
+
|
|
27
|
+
# Development mode with auto-reloading
|
|
28
|
+
npm run dev
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Tool Description
|
|
32
|
+
|
|
33
|
+
The tool description can be found in `src/server.ts`. When asked to update the Claude Code tool description, look for the `description` field in the `setupToolHandlers` method.
|
|
34
|
+
|
|
35
|
+
## Architecture Notes
|
|
36
|
+
|
|
37
|
+
- This MCP server provides a single tool (`claude_code`) that executes Claude CLI with bypassed permissions
|
|
38
|
+
- The server handles execution via the `spawnAsync` function that runs Claude CLI with appropriate parameters
|
|
39
|
+
- Error handling and timeout management are implemented for reliability
|
|
40
|
+
- Working directory can be specified via the `workFolder` parameter
|
|
41
|
+
|
|
42
|
+
## Environment Variables
|
|
43
|
+
|
|
44
|
+
- `CLAUDE_CLI_PATH`: Path to the Claude CLI executable
|
|
45
|
+
- `MCP_CLAUDE_DEBUG`: Set to `true` for verbose debug logging
|
|
46
|
+
|
|
47
|
+
## Best Practices
|
|
48
|
+
|
|
49
|
+
- Always test changes locally before committing
|
|
50
|
+
- Maintain compatibility with the Model Context Protocol spec
|
|
51
|
+
- Keep error messages informative for troubleshooting
|
|
52
|
+
- Document any changes to the API or configuration options
|
|
53
|
+
- Pure updates to the readme and/or adding new images do not require a version bump.
|
|
54
|
+
- **Comprehensive Staging for README Image Updates:** When updating `README.md` to include new images, ensure that prompts for `claude_code` explicitly instruct it to stage *both* the modified `README.md` file *and* all new image files (e.g., from the `assets/` directory). Committing the `README.md` without its new image assets is a common pitfall.
|
|
55
|
+
- **Clarity in Multi-Step Git Prompts:** For complex, multi-step `claude_code` prompts involving Git operations (like creating branches, committing multiple files, and pushing/creating PRs):
|
|
56
|
+
- Clearly list all files to be staged in the commit (text files, new image assets, etc.).
|
|
57
|
+
- **Automatic Push on PR Branches:** When the user asks to commit changes while on a pull request branch, Claude should automatically push the changes to the remote after committing. This ensures PR updates are immediately visible for review.
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [1.10.12] - 2025-05-17
|
|
9
|
+
|
|
10
|
+
- Fixed MCP server startup issue by ensuring process runs regardless of module detection
|
|
11
|
+
- Updated server version constant to match package version
|
|
12
|
+
- Simplified entry point logic to prevent early exit
|
|
13
|
+
|
|
14
|
+
## [1.10.11] - 2025-05-17
|
|
15
|
+
|
|
16
|
+
- Restored package structure to v1.9.4 configuration after bundling issues
|
|
17
|
+
- Removed bundling approach and dependencies (esbuild)
|
|
18
|
+
- Fixed build by returning to simple TypeScript compilation with tsc
|
|
19
|
+
- Kept ESLint in devDependencies where it belongs
|
|
20
|
+
- Package now works correctly as MCP server again
|
|
21
|
+
|
|
22
|
+
## [1.10.10] - 2025-05-17
|
|
23
|
+
|
|
24
|
+
- Restored shipping TypeScript source files alongside compiled JavaScript
|
|
25
|
+
- Returns to the pre-bundling approach of versions 1.5.0-1.9.x
|
|
26
|
+
- Includes src/server.ts, tsconfig.json, and start scripts in package
|
|
27
|
+
- Provides flexibility for users to run or modify the TypeScript version
|
|
28
|
+
|
|
29
|
+
## [1.10.9] - 2025-05-17
|
|
30
|
+
|
|
31
|
+
- Switched from bundling approach to TypeScript compilation like working MCP servers
|
|
32
|
+
- Aligns with successful macos-automator-mcp package structure
|
|
33
|
+
- Simpler build process with tsc instead of esbuild bundling
|
|
34
|
+
|
|
35
|
+
## [1.10.8] - 2025-05-17
|
|
36
|
+
|
|
37
|
+
- Fixed critical dependency issue by moving @eslint/js to devDependencies
|
|
38
|
+
- This resolves the MCP server crash on initialization
|
|
39
|
+
- Cleaner production bundle without unnecessary development dependencies
|
|
40
|
+
|
|
41
|
+
## [1.10.7] - 2025-05-17
|
|
42
|
+
|
|
43
|
+
- Fixed bundling configuration to properly include all native modules
|
|
44
|
+
- Resolved MCP initialization errors in bundled version
|
|
45
|
+
|
|
46
|
+
## [1.10.6] - 2025-05-17
|
|
47
|
+
|
|
48
|
+
- Runs now from compiled dist, bundled. Faster startup & smaller package size.
|
|
49
|
+
- Tool version and startup time print on first use
|
|
50
|
+
|
|
51
|
+
## [1.10.0] - 2025-05-17
|
|
52
|
+
|
|
53
|
+
- Support for `CLAUDE_CLI_NAME` environment variable to override the Claude CLI binary name
|
|
54
|
+
- Support for absolute paths in `CLAUDE_CLI_NAME` (e.g., `/tmp/claude-test`)
|
|
55
|
+
- Comprehensive unit and e2e tests for the server functionality
|
|
56
|
+
- Test infrastructure with mocked Claude CLI for reliable testing
|
|
57
|
+
- `CLAUDE_CLI_NAME` now supports both simple names and absolute paths
|
|
58
|
+
- Relative paths in `CLAUDE_CLI_NAME` now throw an error (security improvement)
|
|
59
|
+
- Removed test mock directory lookup when absolute path is provided
|
|
60
|
+
|
|
61
|
+
## [1.9.5] - 2025-05-15
|
|
62
|
+
|
|
63
|
+
### Changed
|
|
64
|
+
- Clarify that workingDir must be absolute.
|
|
65
|
+
|
|
66
|
+
## [1.9.4] - 2025-05-15
|
|
67
|
+
|
|
68
|
+
### Added
|
|
69
|
+
- Enhanced `claude_code` tool description in `src/server.ts` to reflect multi-modal capabilities (image analysis), file content analysis, and provide more comprehensive prompt tips.
|
|
70
|
+
|
|
71
|
+
### Changed
|
|
72
|
+
- Resized example images in `README.md` for better display via HTML width attributes.
|
|
73
|
+
|
|
74
|
+
## [1.9.3] - 2025-05-15
|
|
75
|
+
|
|
76
|
+
### Changed
|
|
77
|
+
- Better work directory management.
|
|
78
|
+
|
|
79
|
+
## [1.9.1] - 2025-05-14
|
|
80
|
+
|
|
81
|
+
### Changed
|
|
82
|
+
- Increased the maximum execution timeout for the Claude Code tool from 5 minutes to 30 minutes.
|
|
83
|
+
|
|
84
|
+
## [1.9.0] - 2025-05-14
|
|
85
|
+
|
|
86
|
+
### Changed
|
|
87
|
+
- Modified the input for the `claude_code` tool. The `workFolder` is now an optional explicit JSON parameter instead of being parsed from the `prompt` string. This improves clarity and simplifies prompt construction.
|
|
88
|
+
|
|
89
|
+
## [1.8.0] - 2025-05-14
|
|
90
|
+
|
|
91
|
+
### Changed
|
|
92
|
+
- Improved startup stability by explicitly using `/bin/bash` for Claude CLI script execution and ensuring correct command-line arguments are used.
|
|
93
|
+
|
|
94
|
+
## [1.7.0] - 2025-05-14
|
|
95
|
+
|
|
96
|
+
### Changed
|
|
97
|
+
- Renamed the primary MCP tool from `code` to `claude_code` for better clarity and consistency in UI (`src/server.ts`).
|
|
98
|
+
- Updated `README.md` to reflect the new tool name.
|
|
99
|
+
|
|
100
|
+
## [1.6.1] - 2025-05-14
|
|
101
|
+
|
|
102
|
+
### Fixed
|
|
103
|
+
- Amended previous commit on `feature/v1.6.0-updates` to include `dist/server.js` which was built but not staged.
|
|
104
|
+
- Resolved merge conflicts by rebasing `release/v1.6.1` onto `main` before merge.
|
|
105
|
+
|
|
106
|
+
*(Note: Version 1.6.1 was primarily a maintenance release for PR #6 hygiene after rebasing).*
|
|
107
|
+
|
|
108
|
+
## [1.6.0] - 2025-05-14
|
|
109
|
+
|
|
110
|
+
### Added
|
|
111
|
+
- Integrated logic in `src/server.ts` to parse "Your work folder is..." directive from prompts to set the Current Working Directory (CWD) for the underlying `claude-code-cli`.
|
|
112
|
+
- Default CWD for `claude-code-cli` is set to the user's home directory if no specific "Your work folder is..." directive is provided in the prompt.
|
|
113
|
+
- Enhanced error messages for `claude-code-cli` execution failures, including attempts to append `stderr` and `stdout` from the failed process to the error message.
|
|
114
|
+
|
|
115
|
+
### Fixed
|
|
116
|
+
- Resolved various linting errors in `src/server.ts` related to:
|
|
117
|
+
- Correct access of request parameters (e.g., `args.params.name` for tool name, `args.params.arguments.prompt` for prompt).
|
|
118
|
+
- Correct usage of `ErrorCode` enum members from `@modelcontextprotocol/sdk` (e.g., `ErrorCode.MethodNotFound`, `ErrorCode.InvalidParams`, `ErrorCode.InternalError` for timeouts and general failures).
|
|
119
|
+
- Ensured `npm run build` completes successfully after CWD logic integration and lint fixes.
|
|
120
|
+
- Ensured the `--dangerously-skip-permissions` flag is passed correctly as one of the first arguments to `claude-code-cli`.
|
|
121
|
+
|
|
122
|
+
### Changed
|
|
123
|
+
- Set default execution timeout for `claude-code-cli` to 5 minutes (300,000 ms).
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
*Older versions might not have detailed changelog entries.*
|
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Peter Steinberger (Original work)
|
|
4
|
+
Copyright (c) 2025 mkXultra (Modified work)
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
# AI CLI MCP Server
|
|
2
|
+
|
|
3
|
+
<img src="assets/claude_code_mcp_logo.png" alt="AI CLI MCP Logo">
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/ai-cli-mcp)
|
|
6
|
+
[](/CHANGELOG.md)
|
|
7
|
+
|
|
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
|
+
|
|
10
|
+
An MCP (Model Context Protocol) server that allows running AI CLI tools (Claude and Codex) in background processes with automatic permission handling.
|
|
11
|
+
|
|
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
|
+
|
|
14
|
+
<img src="assets/screenshot.png" width="300" alt="Screenshot">
|
|
15
|
+
|
|
16
|
+
## Overview
|
|
17
|
+
|
|
18
|
+
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:
|
|
19
|
+
|
|
20
|
+
- Run Claude CLI with all permissions bypassed (using `--dangerously-skip-permissions`)
|
|
21
|
+
- Execute Codex CLI with automatic approval mode (using `--full-auto`)
|
|
22
|
+
- Support multiple AI models: Claude (sonnet, opus, haiku) and Codex (gpt-5-low, gpt-5-medium, gpt-5-high)
|
|
23
|
+
- Manage background processes with PID tracking
|
|
24
|
+
- Parse and return structured outputs from both tools
|
|
25
|
+
|
|
26
|
+
## Benefits
|
|
27
|
+
|
|
28
|
+
- Claude/Windsurf often have trouble editing files. Claude Code is better and faster at it.
|
|
29
|
+
- Multiple commands can be queued instead of direct execution. This saves context space so more important stuff is retained longer, fewer compacts happen.
|
|
30
|
+
- File ops, git, or other operations don't need costy models. Claude Code is pretty cost effective if you sign up for Antropic Max. You can use Gemini or o3 in Max mode and save costs with offloading tasks to cheaper models.
|
|
31
|
+
- Claude has wider system access and can do things that Cursor/Windsurf can't do (or believe they can't), so whenever they are stuck just ask them "use claude code" and it will usually un-stuck them.
|
|
32
|
+
- Agents in Agents rules.
|
|
33
|
+
|
|
34
|
+
<img src="assets/agents_in_agents_meme.jpg" alt="Agents in Agents Meme">
|
|
35
|
+
|
|
36
|
+
## Prerequisites
|
|
37
|
+
|
|
38
|
+
- Node.js v20 or later (Use fnm or nvm to install)
|
|
39
|
+
- Claude CLI installed locally (run it and call /doctor) and `--dangerously-skip-permissions` accepted
|
|
40
|
+
- Codex CLI installed (optional, for Codex support)
|
|
41
|
+
|
|
42
|
+
## Configuration
|
|
43
|
+
|
|
44
|
+
### Environment Variables
|
|
45
|
+
|
|
46
|
+
- `CLAUDE_CLI_NAME`: Override the Claude CLI binary name or provide an absolute path (default: `claude`)
|
|
47
|
+
- `CODEX_CLI_NAME`: Override the Codex CLI binary name or provide an absolute path (default: `codex`)
|
|
48
|
+
- `MCP_CLAUDE_DEBUG`: Enable debug logging (set to `true` for verbose output)
|
|
49
|
+
|
|
50
|
+
Both CLI name variables support:
|
|
51
|
+
- Simple name: `CLAUDE_CLI_NAME=claude-custom` or `CODEX_CLI_NAME=codex-v2`
|
|
52
|
+
- Absolute path: `CLAUDE_CLI_NAME=/path/to/custom/claude`
|
|
53
|
+
|
|
54
|
+
Note: Relative paths are not allowed and will throw an error.
|
|
55
|
+
|
|
56
|
+
## Installation & Usage
|
|
57
|
+
|
|
58
|
+
The recommended way to use this server is by installing it by using `npx`.
|
|
59
|
+
|
|
60
|
+
### Using npx in your MCP configuration:
|
|
61
|
+
|
|
62
|
+
```json
|
|
63
|
+
"ai-cli-mcp": {
|
|
64
|
+
"command": "npx",
|
|
65
|
+
"args": [
|
|
66
|
+
"-y",
|
|
67
|
+
"ai-cli-mcp@latest"
|
|
68
|
+
]
|
|
69
|
+
},
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Using Claude CLI mcp add command:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
claude mcp add ai-cli '{"name":"ai-cli","command":"npx","args":["-y","ai-cli-mcp@latest"]}'
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### With custom CLI binaries:
|
|
79
|
+
|
|
80
|
+
```json
|
|
81
|
+
"ai-cli-mcp": {
|
|
82
|
+
"command": "npx",
|
|
83
|
+
"args": [
|
|
84
|
+
"-y",
|
|
85
|
+
"ai-cli-mcp@latest"
|
|
86
|
+
],
|
|
87
|
+
"env": {
|
|
88
|
+
"CLAUDE_CLI_NAME": "claude-custom",
|
|
89
|
+
"CODEX_CLI_NAME": "codex-custom"
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Important First-Time Setup
|
|
95
|
+
|
|
96
|
+
### For Claude CLI:
|
|
97
|
+
|
|
98
|
+
**Before the MCP server can use Claude, you must first run the Claude CLI manually once with the `--dangerously-skip-permissions` flag, login and accept the terms.**
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
npm install -g @anthropic-ai/claude-code
|
|
102
|
+
claude --dangerously-skip-permissions
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Follow the prompts to accept. Once this is done, the MCP server will be able to use the flag non-interactively.
|
|
106
|
+
|
|
107
|
+
### For Codex CLI:
|
|
108
|
+
|
|
109
|
+
**For Codex, ensure you're logged in and have accepted any necessary terms:**
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
codex login
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
macOS might ask for folder permissions the first time either tool runs. If the first run fails, subsequent runs should work.
|
|
116
|
+
|
|
117
|
+
## Connecting to Your MCP Client
|
|
118
|
+
|
|
119
|
+
After setting up the server, you need to configure your MCP client (like Cursor or others that use `mcp.json` or `mcp_config.json`).
|
|
120
|
+
|
|
121
|
+
### MCP Configuration File
|
|
122
|
+
|
|
123
|
+
The configuration is typically done in a JSON file. The name and location can vary depending on your client.
|
|
124
|
+
|
|
125
|
+
#### Cursor
|
|
126
|
+
|
|
127
|
+
Cursor uses `mcp.json`.
|
|
128
|
+
- **macOS:** `~/.cursor/mcp.json`
|
|
129
|
+
- **Windows:** `%APPDATA%\\Cursor\\mcp.json`
|
|
130
|
+
- **Linux:** `~/.config/cursor/mcp.json`
|
|
131
|
+
|
|
132
|
+
#### Windsurf
|
|
133
|
+
|
|
134
|
+
Windsurf users use `mcp_config.json`
|
|
135
|
+
- **macOS:** `~/.codeium/windsurf/mcp_config.json`
|
|
136
|
+
- **Windows:** `%APPDATA%\\Codeium\\windsurf\\mcp_config.json`
|
|
137
|
+
- **Linux:** `~/.config/.codeium/windsurf/mcp_config.json`
|
|
138
|
+
|
|
139
|
+
(Note: In some mixed setups, if Cursor is also installed, these clients might fall back to using Cursor's `~/.cursor/mcp.json` path. Prioritize the Codeium-specific paths if using the Codeium extension.)
|
|
140
|
+
|
|
141
|
+
Create this file if it doesn't exist. Add or update the configuration for `ai-cli-mcp`:
|
|
142
|
+
|
|
143
|
+
## Tools Provided
|
|
144
|
+
|
|
145
|
+
This server exposes the following tools:
|
|
146
|
+
|
|
147
|
+
### `run`
|
|
148
|
+
|
|
149
|
+
Executes a prompt using either Claude CLI or Codex CLI. The appropriate CLI is automatically selected based on the model name.
|
|
150
|
+
|
|
151
|
+
**Arguments:**
|
|
152
|
+
- `prompt` (string, optional): The prompt to send to the AI agent. Either `prompt` or `prompt_file` is required.
|
|
153
|
+
- `prompt_file` (string, optional): Path to a file containing the prompt. Either `prompt` or `prompt_file` is required. Can be absolute path or relative to `workFolder`.
|
|
154
|
+
- `workFolder` (string, required): The working directory for the CLI execution. Must be an absolute path.
|
|
155
|
+
- `model` (string, optional): The model to use:
|
|
156
|
+
- Claude models: "sonnet", "opus", "haiku"
|
|
157
|
+
- Codex models: "gpt-5-low", "gpt-5-medium", "gpt-5-high"
|
|
158
|
+
- `session_id` (string, optional): Optional session ID to resume a previous session. Supported for: haiku, sonnet, opus.
|
|
159
|
+
|
|
160
|
+
### `list_processes`
|
|
161
|
+
|
|
162
|
+
Lists all running and completed AI agent processes with their status, PID, and basic info.
|
|
163
|
+
|
|
164
|
+
### `get_result`
|
|
165
|
+
|
|
166
|
+
Gets the current output and status of an AI agent process by PID.
|
|
167
|
+
|
|
168
|
+
**Arguments:**
|
|
169
|
+
- `pid` (number, required): The process ID returned by the `run` tool.
|
|
170
|
+
|
|
171
|
+
### `kill_process`
|
|
172
|
+
|
|
173
|
+
Terminates a running AI agent process by PID.
|
|
174
|
+
|
|
175
|
+
**Arguments:**
|
|
176
|
+
- `pid` (number, required): The process ID to terminate.
|
|
177
|
+
|
|
178
|
+
**Example with Claude:**
|
|
179
|
+
```json
|
|
180
|
+
{
|
|
181
|
+
"toolName": "run",
|
|
182
|
+
"arguments": {
|
|
183
|
+
"prompt": "Refactor the function foo in main.py to be async.",
|
|
184
|
+
"workFolder": "/Users/username/my_project",
|
|
185
|
+
"model": "sonnet"
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
**Example with Codex:**
|
|
191
|
+
```json
|
|
192
|
+
{
|
|
193
|
+
"toolName": "run",
|
|
194
|
+
"arguments": {
|
|
195
|
+
"prompt": "Create a REST API with Express.js",
|
|
196
|
+
"workFolder": "/Users/username/my_project",
|
|
197
|
+
"model": "gpt-5-high"
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Examples
|
|
203
|
+
|
|
204
|
+
Here are some visual examples of the server in action:
|
|
205
|
+
|
|
206
|
+
<img src="assets/claude_tool_git_example.png" alt="Claude Tool Git Example" width="50%">
|
|
207
|
+
|
|
208
|
+
<img src="assets/additional_claude_screenshot.png" alt="Additional Claude Screenshot" width="50%">
|
|
209
|
+
|
|
210
|
+
<img src="assets/cursor-screenshot.png" alt="Cursor Screenshot" width="50%">
|
|
211
|
+
|
|
212
|
+
### Fixing ESLint Setup
|
|
213
|
+
|
|
214
|
+
Here's an example of using the Claude Code MCP tool to interactively fix an ESLint setup by deleting old configuration files and creating a new one:
|
|
215
|
+
|
|
216
|
+
<img src="assets/eslint_example.png" alt="ESLint file operations example" width="50%">
|
|
217
|
+
|
|
218
|
+
### Listing Files Example
|
|
219
|
+
|
|
220
|
+
Here's an example of the Claude Code tool listing files in a directory:
|
|
221
|
+
|
|
222
|
+
<img src="assets/file_list_example.png" alt="File listing example" width="50%">
|
|
223
|
+
|
|
224
|
+
## Key Use Cases
|
|
225
|
+
|
|
226
|
+
This server, through its unified `run` tool, unlocks a wide range of powerful capabilities by giving your AI direct access to both Claude and Codex CLI tools. Here are some examples of what you can achieve:
|
|
227
|
+
|
|
228
|
+
1. **Code Generation, Analysis & Refactoring:**
|
|
229
|
+
- `"Generate a Python script to parse CSV data and output JSON."`
|
|
230
|
+
- `"Analyze my_script.py for potential bugs and suggest improvements."`
|
|
231
|
+
|
|
232
|
+
2. **File System Operations (Create, Read, Edit, Manage):**
|
|
233
|
+
- **Creating Files:** `"Your work folder is /Users/steipete/my_project\n\nCreate a new file named 'config.yml' in the 'app/settings' directory with the following content:\nport: 8080\ndatabase: main_db"`
|
|
234
|
+
- **Editing Files:** `"Your work folder is /Users/steipete/my_project\n\nEdit file 'public/css/style.css': Add a new CSS rule at the end to make all 'h2' elements have a 'color: navy'."`
|
|
235
|
+
- **Moving/Copying/Deleting:** `"Your work folder is /Users/steipete/my_project\n\nMove the file 'report.docx' from the 'drafts' folder to the 'final_reports' folder and rename it to 'Q1_Report_Final.docx'."`
|
|
236
|
+
|
|
237
|
+
3. **Version Control (Git):**
|
|
238
|
+
- `"Your work folder is /Users/steipete/my_project\n\n1. Stage the file 'src/main.java'.\n2. Commit the changes with the message 'feat: Implement user authentication'.\n3. Push the commit to the 'develop' branch on origin."`
|
|
239
|
+
|
|
240
|
+
4. **Running Terminal Commands:**
|
|
241
|
+
- `"Your work folder is /Users/steipete/my_project/frontend\n\nRun the command 'npm run build'."`
|
|
242
|
+
- `"Open the URL https://developer.mozilla.org in my default web browser."`
|
|
243
|
+
|
|
244
|
+
5. **Web Search & Summarization:**
|
|
245
|
+
- `"Search the web for 'benefits of server-side rendering' and provide a concise summary."`
|
|
246
|
+
|
|
247
|
+
6. **Complex Multi-Step Workflows:**
|
|
248
|
+
- Automate version bumps, update changelogs, and tag releases: `"Your work folder is /Users/steipete/my_project\n\nFollow these steps: 1. Update the version in package.json to 2.5.0. 2. Add a new section to CHANGELOG.md for version 2.5.0 with the heading '### Added' and list 'New feature X'. 3. Stage package.json and CHANGELOG.md. 4. Commit with message 'release: version 2.5.0'. 5. Push the commit. 6. Create and push a git tag v2.5.0."`
|
|
249
|
+
|
|
250
|
+
<img src="assets/multistep_example.png" alt="Complex multi-step operation example" width="50%">
|
|
251
|
+
|
|
252
|
+
7. **Repairing Files with Syntax Errors:**
|
|
253
|
+
- `"Your work folder is /path/to/project\n\nThe file 'src/utils/parser.js' has syntax errors after a recent complex edit that broke its structure. Please analyze it, identify the syntax errors, and correct the file to make it valid JavaScript again, ensuring the original logic is preserved as much as possible."`
|
|
254
|
+
|
|
255
|
+
8. **Interacting with GitHub (e.g., Creating a Pull Request):**
|
|
256
|
+
- `"Your work folder is /Users/steipete/my_project\n\nCreate a GitHub Pull Request in the repository 'owner/repo' from the 'feature-branch' to the 'main' branch. Title: 'feat: Implement new login flow'. Body: 'This PR adds a new and improved login experience for users.'"`
|
|
257
|
+
|
|
258
|
+
9. **Interacting with GitHub (e.g., Checking PR CI Status):**
|
|
259
|
+
- `"Your work folder is /Users/steipete/my_project\n\nCheck the status of CI checks for Pull Request #42 in the GitHub repository 'owner/repo'. Report if they have passed, failed, or are still running."`
|
|
260
|
+
|
|
261
|
+
### Correcting GitHub Actions Workflow
|
|
262
|
+
|
|
263
|
+
<img src="assets/github_actions_fix_example.png" alt="GitHub Actions workflow fix example" width="50%">
|
|
264
|
+
|
|
265
|
+
### Complex Multi-Step Operations
|
|
266
|
+
|
|
267
|
+
This example illustrates the AI agent handling a more complex, multi-step task, such as preparing a release by creating a branch, updating multiple files (`package.json`, `CHANGELOG.md`), committing changes, and initiating a pull request, all within a single, coherent operation.
|
|
268
|
+
|
|
269
|
+
<img src="assets/claude_code_multistep_example.png" alt="AI agent multi-step example" width="50%">
|
|
270
|
+
|
|
271
|
+
**CRITICAL: Remember to provide Current Working Directory (CWD) context in your prompts for file system or git operations (e.g., `"Your work folder is /path/to/project\n\n...your command..."`).**
|
|
272
|
+
|
|
273
|
+
## Troubleshooting
|
|
274
|
+
|
|
275
|
+
- **"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.
|
|
276
|
+
- **"Command not found" (claude or ~/.claude/local/claude):** Ensure the Claude CLI is installed correctly. Run `claude/doctor` or check its documentation.
|
|
277
|
+
- **Permissions Issues:** Make sure you've run the "Important First-Time Setup" step.
|
|
278
|
+
- **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.
|
|
279
|
+
- **ESM/Import Errors:** Ensure you are using Node.js v20 or later.
|
|
280
|
+
|
|
281
|
+
**For Developers: Local Setup & Contribution**
|
|
282
|
+
|
|
283
|
+
If you want to develop or contribute to this server, or run it from a cloned repository for testing, please see our [Local Installation & Development Setup Guide](./docs/local_install.md).
|
|
284
|
+
|
|
285
|
+
## Testing
|
|
286
|
+
|
|
287
|
+
The project includes comprehensive test suites:
|
|
288
|
+
|
|
289
|
+
```bash
|
|
290
|
+
# Run all tests
|
|
291
|
+
npm test
|
|
292
|
+
|
|
293
|
+
# Run unit tests only
|
|
294
|
+
npm run test:unit
|
|
295
|
+
|
|
296
|
+
# Run e2e tests (with mocks)
|
|
297
|
+
npm run test:e2e
|
|
298
|
+
|
|
299
|
+
# Run e2e tests locally (requires Claude CLI)
|
|
300
|
+
npm run test:e2e:local
|
|
301
|
+
|
|
302
|
+
# Watch mode for development
|
|
303
|
+
npm run test:watch
|
|
304
|
+
|
|
305
|
+
# Coverage report
|
|
306
|
+
npm run test:coverage
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
For detailed testing documentation, see our [E2E Testing Guide](./docs/e2e-testing.md).
|
|
310
|
+
|
|
311
|
+
## Configuration via Environment Variables
|
|
312
|
+
|
|
313
|
+
The server's behavior can be customized using these environment variables:
|
|
314
|
+
|
|
315
|
+
- `CLAUDE_CLI_PATH`: Absolute path to the Claude CLI executable.
|
|
316
|
+
- Default: Checks `~/.claude/local/claude`, then falls back to `claude` (expecting it in PATH).
|
|
317
|
+
- `MCP_CLAUDE_DEBUG`: Set to `true` for verbose debug logging from this MCP server. Default: `false`.
|
|
318
|
+
|
|
319
|
+
These can be set in your shell environment or within the `env` block of your `mcp.json` server configuration (though the `env` block in `mcp.json` examples was removed for simplicity, it's still a valid way to set them for the server process if needed).
|
|
320
|
+
|
|
321
|
+
## Contributing
|
|
322
|
+
|
|
323
|
+
Contributions are welcome! Please refer to the [Local Installation & Development Setup Guide](./docs/local_install.md) for details on setting up your environment.
|
|
324
|
+
|
|
325
|
+
Submit issues and pull requests to the [GitHub repository](https://github.com/mkXultra/claude-code-mcp).
|
|
326
|
+
|
|
327
|
+
## License
|
|
328
|
+
|
|
329
|
+
MIT
|