# chatgpt-cli — Multi-Provider ChatGPT CLI + MCP > A fast ChatGPT CLI with threads/history and built-in MCP client support (tools + session handling); verified 922★, pushed 2026-05-09. ## Install Copy the content below into your project: ## Quick Use ```bash brew tap kardolus/chatgpt-cli && brew install chatgpt-cli export OPENAI_API_KEY="your_api_key" mkdir -p ~/.chatgpt-cli # enable history (README) chatgpt --help # MCP tool injection example (README): chatgpt --mcp "https://your-mcp-server.example.com" --mcp-tool "some-tool-name" --mcp-params '{"foo":"bar"}' ``` ## Intro A fast ChatGPT CLI with threads/history and built-in MCP client support (tools + session handling); verified 922★, pushed 2026-05-09. **Best for:** Developers who want a terminal-first assistant that can call MCP tools and keep history **Works with:** macOS/Linux/Windows binaries; uses `OPENAI_API_KEY` and can call MCP servers over HTTP(S) (per README) **Setup time:** 6-12 minutes ### Key facts (verified) - GitHub: 922 stars · 61 forks · pushed 2026-05-09. - License: MIT · owner avatar + repo URL verified via GitHub API. - README-backed entrypoint: `chatgpt --help`. ## Main - Start with history: creating `~/.chatgpt-cli` enables per-thread message history and a sliding context window (README). - Use MCP for tool-augmented questions: inject tool results into the thread first, then ask follow-ups while the context stays local to the CLI. - Let the CLI manage MCP sessions: README explains it auto-handles servers that require `mcp-session-id` headers. - Prefer direct-download binaries for CI or locked-down machines: README shows `curl -L -o chatgpt ... && chmod +x` one-liners by OS/arch. ### Source-backed notes - README documents MCP flags (`--mcp`, `--mcp-tool`, `--mcp-params`) and that results are injected as `[MCP: ] ...` messages. - README includes Homebrew installation plus direct-download commands for multiple platforms/architectures. - README says creating `~/.chatgpt-cli` enables history tracking stored under `~/.chatgpt-cli/history/`. ### FAQ - **Do I need an API key?**: Yes — README instructs setting `OPENAI_API_KEY` before running the CLI. - **How do I keep conversation history?**: Create `~/.chatgpt-cli`; the CLI stores thread history under `~/.chatgpt-cli/history/` (README). - **Does MCP work with servers requiring a session header?**: README says the CLI automatically manages `mcp-session-id` for HTTP(S) MCP servers. ## Source & Thanks > Source: https://github.com/kardolus/chatgpt-cli > License: MIT > GitHub stars: 922 · forks: 61 --- ## Quick Use ```bash brew tap kardolus/chatgpt-cli && brew install chatgpt-cli export OPENAI_API_KEY="your_api_key" mkdir -p ~/.chatgpt-cli # enable history (README) chatgpt --help # MCP tool injection example (README): chatgpt --mcp "https://your-mcp-server.example.com" --mcp-tool "some-tool-name" --mcp-params '{"foo":"bar"}' ``` ## Intro chatgpt-cli 是带线程/历史的命令行助手,并内置 MCP client(工具调用 + 会话管理),适合把工具结果注入上下文后再提问;已验证 922★,更新于 2026-05-09。 **Best for:** 想在终端里对话、保留历史,并能调用 MCP 工具的开发者 **Works with:** 支持 macOS/Linux/Windows 二进制;通过 `OPENAI_API_KEY` 使用,并可通过 HTTP(S) 调用 MCP server(README) **Setup time:** 6-12 minutes ### Key facts (verified) - GitHub:922 stars · 61 forks;最近更新 2026-05-09。 - 许可证:MIT;作者头像与仓库链接均已通过 GitHub API 复核。 - README 中可对照的入口命令:`chatgpt --help`。 ## Main - 先打开历史:创建 `~/.chatgpt-cli` 后,CLI 会为每个 thread 自动维护滑动窗口式上下文(README)。 - 用 MCP 做工具增强提问:先注入工具结果,再继续追问,避免手动复制粘贴输出。 - 让 CLI 管理 MCP 会话:README 说明它会自动处理需要 `mcp-session-id` 的 HTTP(S) MCP server。 - 在 CI/受限环境用直链二进制:README 给出了按 OS/arch 的 `curl -L -o chatgpt ... && chmod +x` 安装方式。 ### Source-backed notes - README 说明 MCP 参数(`--mcp`、`--mcp-tool`、`--mcp-params`),并描述工具结果会以 `[MCP: ] ...` 注入上下文。 - README 提供 Homebrew 安装与多平台/多架构直链下载命令。 - README 写明创建 `~/.chatgpt-cli` 后会启用历史记录(保存在 `~/.chatgpt-cli/history/`)。 ### FAQ - **需要 API key 吗?**:需要;README 要求先设置 `OPENAI_API_KEY`。 - **怎么保留对话历史?**:创建 `~/.chatgpt-cli`;README 说明会把 history 存在 `~/.chatgpt-cli/history/`。 - **需要 `mcp-session-id` 的 MCP server 能用吗?**:README 表示 CLI 会自动为 HTTP(S) MCP server 管理会话 header。 ## Source & Thanks > Source: https://github.com/kardolus/chatgpt-cli > License: MIT > GitHub stars: 922 · forks: 61 --- Source: https://tokrepo.com/en/workflows/chatgpt-cli-multi-provider-chatgpt-cli-mcp Author: Script Depot