feat(cli): expose mcp via code subcommand

This commit is contained in:
James Peter
2025-09-22 15:16:49 +10:00
parent 33f498e19b
commit f15d2e2fd9
7 changed files with 24 additions and 53 deletions
+13 -35
View File
@@ -265,7 +265,7 @@ jobs:
RUST_BACKTRACE: "1"
run: |
cd codex-rs
cargo build --release --frozen --locked --timings --target ${{ matrix.target }} --bin code --bin code-mcp-server
cargo build --release --frozen --locked --timings --target ${{ matrix.target }} --bin code
- name: Post-build smoke (run binary) [Unix]
if: |
@@ -297,10 +297,8 @@ jobs:
mkdir -p artifacts
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
cp codex-rs/target/${{ matrix.target }}/release/code.exe artifacts/${{ matrix.artifact }}
cp codex-rs/target/${{ matrix.target }}/release/code-mcp-server.exe artifacts/code-mcp-server-${{ matrix.target }}.exe
else
cp codex-rs/target/${{ matrix.target }}/release/code artifacts/${{ matrix.artifact }}
cp codex-rs/target/${{ matrix.target }}/release/code-mcp-server artifacts/code-mcp-server-${{ matrix.target }}
fi
- name: Compress artifacts (Windows)
@@ -423,11 +421,11 @@ jobs:
map_target() {
case "$1" in
aarch64-apple-darwin) echo "os=darwin cpu=arm64 pkg=@just-every/code-darwin-arm64 target=$1" ;;
x86_64-apple-darwin) echo "os=darwin cpu=x64 pkg=@just-every/code-darwin-x64 target=$1" ;;
x86_64-unknown-linux-musl) echo "os=linux cpu=x64 pkg=@just-every/code-linux-x64-musl target=$1" ;;
aarch64-unknown-linux-musl) echo "os=linux cpu=arm64 pkg=@just-every/code-linux-arm64-musl target=$1" ;;
x86_64-pc-windows-msvc.exe) echo "os=win32 cpu=x64 pkg=@just-every/code-win32-x64 target=$1" ;;
aarch64-apple-darwin) echo "os=darwin cpu=arm64 pkg=@just-every/code-darwin-arm64" ;;
x86_64-apple-darwin) echo "os=darwin cpu=x64 pkg=@just-every/code-darwin-x64" ;;
x86_64-unknown-linux-musl) echo "os=linux cpu=x64 pkg=@just-every/code-linux-x64-musl" ;;
aarch64-unknown-linux-musl) echo "os=linux cpu=arm64 pkg=@just-every/code-linux-arm64-musl" ;;
x86_64-pc-windows-msvc.exe) echo "os=win32 cpu=x64 pkg=@just-every/code-win32-x64" ;;
*) echo "" ;;
esac
}
@@ -459,14 +457,6 @@ jobs:
esac
}
targets=(
aarch64-apple-darwin
x86_64-apple-darwin
x86_64-unknown-linux-musl
aarch64-unknown-linux-musl
x86_64-pc-windows-msvc.exe
)
for f in release-assets/*; do
b="$(basename "$f")"
# Derive target triple from the filename while preserving optional .exe (Windows):
@@ -477,32 +467,20 @@ jobs:
*.zip) base="${b%.zip}" ;;
*) base="$b" ;;
esac
match=""
for candidate in "${targets[@]}"; do
if [[ "$base" == code-*"$candidate" ]]; then
match="$candidate"
break
fi
done
if [ -z "$match" ]; then
echo "Skipping unrecognized artifact: $b"
continue
fi
meta="$(map_target "$match")" || true
t="${base#code-}"
meta="$(map_target "$t")" || true
if [ -z "$meta" ]; then
echo "Skipping unrecognized artifact: $b"
continue
fi
eval "$meta" # sets os, cpu, pkg, target
eval "$meta" # sets os, cpu, pkg
workdir="$stage_root/${pkg##*/}"
mkdir -p "$workdir/bin"
rm -rf "$workdir" && mkdir -p "$workdir/bin"
rawbin="$(decompress_to "$f" "$workdir/bin")"
chmod +x "$rawbin" || true
if [ ! -f "$workdir/package.json" ]; then
printf '{\n "name": "%s",\n "version": "%s",\n "license": "Apache-2.0",\n "description": "Platform binary for @just-every/code (%s)",\n "os": ["%s"],\n "cpu": ["%s"],\n "files": ["bin/"],\n "private": false\n}\n' \
"$pkg" "$NEW_VERSION" "$target" "$os" "$cpu" > "$workdir/package.json"
fi
# package.json
printf '{\n "name": "%s",\n "version": "%s",\n "license": "Apache-2.0",\n "description": "Platform binary for @just-every/code (%s)",\n "os": ["%s"],\n "cpu": ["%s"],\n "files": ["bin/"],\n "private": false\n}\n' \
"$pkg" "$NEW_VERSION" "$t" "$os" "$cpu" > "$workdir/package.json"
done
ls -R "$stage_root"
+1 -1
View File
@@ -44,7 +44,7 @@ npx -y @just-every/code
```bash
npm install -g @just-every/code
code # or `coder` if you're using VS Code
code-mcp-server --stdio # launches the MCP server for IDE integrations
code mcp # launches the MCP server over stdio
```
Note: If another tool already provides a `code` command (e.g. VS Code), our CLI is also installed as `coder`. Use `coder` to avoid conflicts.
@@ -1,6 +0,0 @@
#!/usr/bin/env node
process.env.CODE_NATIVE_BINARY = process.env.CODE_NATIVE_BINARY || 'code-mcp-server';
process.env.CODE_NATIVE_COMMAND = process.env.CODE_NATIVE_COMMAND || 'code-mcp-server';
await import('./coder.js');
+2 -2
View File
@@ -314,8 +314,8 @@ async function main() {
const packageJson = JSON.parse(readFileSync(join(__dirname, 'package.json'), 'utf8'));
const version = packageJson.version;
// Download only the primary binary; we'll create wrappers for legacy names.
const binaries = ['code', 'code-mcp-server'];
// Download only the primary CLI binary; subcommands (e.g., `code mcp`) reuse it.
const binaries = ['code'];
console.log(`Installing @just-every/code v${version} for ${targetTriple}...`);
+1 -3
View File
@@ -4,8 +4,7 @@
"license": "Apache-2.0",
"description": "Lightweight coding agent that runs in your terminal - fork of OpenAI Codex",
"bin": {
"coder": "bin/coder.js",
"code-mcp-server": "bin/code-mcp-server.js"
"coder": "bin/coder.js"
},
"type": "module",
"engines": {
@@ -13,7 +12,6 @@
},
"files": [
"bin/coder.js",
"bin/code-mcp-server.js",
"bin/codex.js",
"postinstall.js",
"scripts/preinstall.js",
+2 -1
View File
@@ -3,7 +3,8 @@
This document describes Codex’s experimental MCP interface: a JSON‑RPC API that runs over the Model Context Protocol (MCP) transport to control a local Codex engine.
- Status: experimental and subject to change without notice
- Server binary: `codex mcp` (or `code-mcp-server`)
- Recommended entry point: `code mcp`
- Underlying Rust binary (for development): `cargo run -p code-mcp-server`
- Transport: standard MCP over stdio (JSON‑RPC 2.0, line‑delimited)
## Overview
+5 -5
View File
@@ -22,10 +22,10 @@ Any existing MCP servers can remain in this table; the exiting overrides simply
## 2. Launch the MCP server under the new name
If you globally installed Code from npm (`npm install -g @just-every/code`), the postinstall step now places the prebuilt `code-mcp-server` alongside the other `code-*` binaries on your `PATH`. You can launch it directly:
If you globally installed Code from npm (`npm install -g @just-every/code`), launch the MCP server with the built-in subcommand:
```bash
code-mcp-server --stdio
code mcp
```
Prefer building from source? The previous workflow still works:
@@ -44,8 +44,8 @@ Add an entry to Zed's MCP configuration (for example, `~/.config/zed/mcp.json`):
{
"servers": {
"code": {
"command": "/path/to/code-mcp-server",
"args": ["--stdio"],
"command": "/path/to/code",
"args": ["mcp"],
"env": {
"CODEX_HOME": "/Users/you/.code" ,
"RUST_LOG": "info"
@@ -63,4 +63,4 @@ When Zed starts the server it will discover the ACP tools, call `acp/new_session
- Explicit approvals (for shell commands or apply_patch) are raised via `permission/request`.
- Code retains confirm guards, sandbox policies, and validation harnesses; the server simply forwards the resulting events over ACP.
Once configured, Zed users can work with Code without any terminal interaction beyond starting `code-mcp-server`.
Once configured, Zed users can work with Code without any terminal interaction beyond starting `code mcp` (or `coder mcp` if the `code` alias is unavailable).