内容
# acodex
[](LICENSE)
**本地MCP自动化,用于Codex桌面应用程序。**
acodex为脚本、工具和代理提供了一个本地桥梁,可以进入正在运行的Codex桌面会话。它可以重新启动Codex,并使用Chrome DevTools协议(CDP)端口,运行一个托管的HTTP/MCP服务器,并调用Codex桌面构建暴露的实时`codex_app.*`工具。
[快速入门](#快速入门) | [命令行界面](#命令行界面) | [支持](#支持) | [贡献](#贡献)
## 为什么选择acodex
- **实时Codex桌面访问。** 检查和调用由正在运行的桌面渲染器暴露的工具,无需编写CDP管道。
- **MCP兼容的本地服务器。** 在`/mcp`处暴露Codex桌面工具,用于本地自动化客户端。
- **实用的命令行界面工作流程。** 从终端检查配置、重新启动Codex、使用CDP、管理桥梁服务器和调用工具。
## 快速入门
前提条件:
- Python 3.10或更新版本。
- `uv`;请参阅[官方安装指南](https://docs.astral.sh/uv/getting-started/installation/)。
- 带有Codex.app的macOS。重新启动流程默认情况下需要`/Applications/Codex.app`;如果您的应用程序位于其他位置,请设置`ACODEX_CODEX_APP_PATH`。
安装命令行界面:
```sh
uv tool install acodex
```
初始化配置,启动Codex并启用CDP,并启动本地桥梁:
```sh
acodex config init
acodex codex relaunch --yes
acodex server start
```
`acodex codex relaunch --yes`启动或重新启动Codex,以便acodex可以访问默认的CDP端点`http://127.0.0.1:45217`。
在服务器运行时,使用`acodex doctor --deep`进行更深入的诊断。
列出和调用Codex桌面工具:
```sh
acodex tools list
acodex tools call codex_app.list_threads --limit 1
```
完成操作后停止托管的桥梁:
```sh
acodex server stop
```
## 命令行界面
常用命令:
```sh
acodex config path
acodex config show
acodex doctor --deep
acodex codex status
acodex codex relaunch --yes
acodex server start
acodex server status
acodex server logs --tail 50
acodex tools list --json
acodex tools call codex_app.list_threads --help
```
工具调用使用MCP模式属性名称。传递简单的高级参数作为标志,或使用JSON进行嵌套输入:
```sh
acodex tools call codex_app.list_threads --limit=5
acodex tools call --args-json '{"limit":5}' codex_app.list_threads
acodex tools call --output json codex_app.list_threads --limit 5
```
## 配置
acodex默认从`~/.acodex/config.json`读取JSON配置。设置`ACODEX_CONFIG`以使用不同的文件。使用`acodex config path`和`acodex config show`检查活动路径和有效值。
基本本地端点:
- Codex CDP:`http://127.0.0.1:45217`
- 托管服务器健康检查:`http://127.0.0.1:45218/healthz`
- MCP端点:`http://127.0.0.1:45218/mcp`
配置优先级和完整默认值矩阵位于[CONTRIBUTING.md](CONTRIBUTING.md)。
状态更改的工具调用会改变实时Codex桌面应用程序。在调用不熟悉的工具之前,请使用`acodex tools call <tool> --help`。
## 支持
当设置失败时,请从内置诊断和托管服务器日志开始:
```sh
acodex doctor
acodex server logs --tail 50
```
如果问题仍然存在,请在[GitHub问题](https://github.com/maksimzayats/acodex/issues)中提出您尝试过的内容、发生的情况、您的操作系统和Python版本、您的acodex源分支或提交、您的Codex桌面/CDP设置以及相关的命令输出(已删除密钥)。
## 贡献
贡献者设置、架构说明、质量控制和文档规则位于[CONTRIBUTING.md](CONTRIBUTING.md)。代理特定指南位于[AGENTS.md](AGENTS.md)。
## 许可证
acodex在[MIT许可证](LICENSE)下发布。
acodex由独立维护,不隶属于、不赞助或不认可OpenAI。