AI Skill Hub 强烈推荐:chatgpt-cli MCP工具 是一款优质的MCP工具。AI 综合评分 8.2 分,在同类工具中表现稳健。如果你正在寻找可靠的MCP工具解决方案,这是一个值得深入了解的选择。
支持多个AI提供商的强大命令行工具,集成ChatGPT、Azure等服务。采用MCP架构,支持Agent和自动化工作流,适合开发者、DevOps工程师和AI应用构建者快速集成大模型能力。
chatgpt-cli MCP工具 是一款遵循 MCP(Model Context Protocol)标准协议的 AI 工具扩展。通过 MCP 协议,它可以让 Claude、Cursor 等主流 AI 客户端直接访问和操作外部工具、数据源和服务,实现 AI 能力的无缝扩展。无论是文件操作、数据库查询还是 API 调用,都可以通过自然语言在 AI 对话中直接触发,极大提升生产效率。
支持多个AI提供商的强大命令行工具,集成ChatGPT、Azure等服务。采用MCP架构,支持Agent和自动化工作流,适合开发者、DevOps工程师和AI应用构建者快速集成大模型能力。
chatgpt-cli MCP工具 是一款遵循 MCP(Model Context Protocol)标准协议的 AI 工具扩展。通过 MCP 协议,它可以让 Claude、Cursor 等主流 AI 客户端直接访问和操作外部工具、数据源和服务,实现 AI 能力的无缝扩展。无论是文件操作、数据库查询还是 API 调用,都可以通过自然语言在 AI 对话中直接触发,极大提升生产效率。
# 方式一:通过 Claude Code CLI 一键安装
claude skill install https://github.com/kardolus/chatgpt-cli
# 方式二:手动配置 claude_desktop_config.json
{
"mcpServers": {
"chatgpt-cli-mcp--": {
"command": "npx",
"args": ["-y", "chatgpt-cli"]
}
}
}
# 配置文件位置
# macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
# Windows: %APPDATA%/Claude/claude_desktop_config.json
# 安装后在 Claude 对话中直接使用 # 示例: 用户: 请帮我用 chatgpt-cli MCP工具 执行以下任务... Claude: [自动调用 chatgpt-cli MCP工具 MCP 工具处理请求] # 查看可用工具列表 # 在 Claude 中输入:"列出所有可用的 MCP 工具"
// claude_desktop_config.json 配置示例
{
"mcpServers": {
"chatgpt-cli_mcp__": {
"command": "npx",
"args": ["-y", "chatgpt-cli"],
"env": {
// "API_KEY": "your-api-key-here"
}
}
}
}
// 保存后重启 Claude Desktop 生效
ChatGPT CLI is a powerful, multi-provider command-line interface for working with modern LLMs. It supports OpenAI, Azure, Perplexity, LLaMA, and more, and includes streaming, interactive chat, prompt files, image/audio I/O, MCP tool calls, and an experimental agent mode for multi-step tasks with safety and budget controls.

Streaming mode: Real-time interaction with the GPT model. Query mode: Single input-output interactions with the GPT model. Interactive mode: The interactive mode allows for a more conversational experience with the model. Prints the token usage when combined with query mode. Thread-based context management: Enjoy seamless conversations with the GPT model with individualized context for each thread, much like your experience on the OpenAI website. Each unique thread has its own history, ensuring relevant and coherent responses across different chat instances. Sliding window history: To stay within token limits, the chat history automatically trims while still preserving the necessary context. The size of this window can be adjusted through the context-window setting. Custom context from any source: You can provide the GPT model with a custom context during conversation. This context can be piped in from any source, such as local files, standard input, or even another program. This flexibility allows the model to adapt to a wide range of conversational scenarios. Agent mode (ReAct + Plan/Execute): Run multi-step tasks that can think, act, and observe using tools like shell, file operations, and LLM reasoning. Supports both iterative ReAct loops and Plan/Execute workflows, with built-in budget limits (time, steps, tokens) and policy enforcement* (allowed tools, denied commands, workdir sandboxing) for safe-by-default automation. Web search: Allow compatible models (e.g. gpt-5+) to fetch live web data during a query. Enable with the web setting and tune results using web_context_size. MCP (Model Context Protocol) support: Call external MCP tools via HTTP(S) or STDIO, inject their results into the conversation context, and continue the prompt seamlessly. MCP session management: Built-in support for stateful MCP servers. The CLI automatically initializes sessions, attaches session identifiers, and renews them when they become invalid. Support for images: Upload an image or provide an image URL using the --image flag. Note that image support may not be available for all models. You can also pipe an image directly: pngpaste - | chatgpt "What is this photo?" Generate images: Use the --draw and --output flags to generate an image from a prompt (requires image-capable models like gpt-image-1). Edit images: Use the --draw flag with --image and --output to modify an existing image using a prompt ( e.g., "add sunglasses to the cat"). Supported formats: PNG, JPEG, and WebP. Audio support: You can upload audio files using the --audio flag to ask questions about spoken content. This feature is compatible only with audio-capable models like gpt-4o-audio-preview. Currently, only .mp3 and .wav formats are supported. Transcription support: You can also use the --transcribe flag to generate a transcript of the uploaded audio. This uses OpenAI’s transcription endpoint (compatible with models like gpt-4o-transcribe) and supports a wider range of formats, including .mp3, .mp4, .mpeg, .mpga, .m4a, .wav, and .webm. Text-to-speech support: Use the --speak and --output flags to convert text to speech (works with models like gpt-4o-mini-tts). If you have afplay installed (macOS), you can even chain playback like this:
Model listing: Access a list of available models using the chatgpt --speak "convert this to audio" --output test.mp3 && afplay test.mp3
-l or --list-models flag. * Advanced configuration options: The CLI supports a layered configuration system where settings can be specified through default values, a config.yaml file, and environment variables. For quick adjustments, various --set-<value> flags are provided. To verify your current settings, use the --config or -c flag.
1. Set the OPENAI_API_KEY environment variable to your ChatGPT secret key. To set the environment variable, you can add the following line to your shell profile (e.g., ~/.bashrc, ~/.zshrc, or ~/.bash_profile), replacing your_api_key with your actual key:
export OPENAI_API_KEY="your_api_key"
mkdir -p ~/.chatgpt-cli
Once this directory is in place, the CLI automatically manages the message history for each "thread" you converse with. The history operates like a sliding window, maintaining context up to a configurable token maximum. This ensures a balance between maintaining conversation context and achieving optimal performance.
By default, if a specific thread is not provided by the user, the CLI uses the default thread and stores the history at ~/.chatgpt-cli/history/default.json. You can find more details about how to configure the thread parameter in the Configuration section of this document.
chatgpt what is the capital of the Netherlands
-i or --interactive flag: chatgpt --interactive
If you want the CLI to automatically create a new thread for each session, ensure that the auto_create_new_thread configuration variable is set to true. This will create a unique thread identifier for each interactive session.
5. To use the pipe feature, create a text file containing some context. For example, create a file named context.txt with the following content:
Kya is a playful dog who loves swimming and playing fetch.
Then, use the pipe feature to provide this context to ChatGPT:
cat context.txt | chatgpt "What kind of toy would Kya enjoy?"
chatgpt --list-models
chatgpt --help
If for any reason you wish to uninstall the ChatGPT CLI application from your system, you can do so by following these steps:
The ChatGPT CLI adopts a four-tier configuration strategy, with different levels of precedence assigned to flags, environment variables, a config.yaml file, and default values, in that respective order:
1. Flags: Command-line flags have the highest precedence. Any value provided through a flag will override other configurations. 2. Environment Variables: If a setting is not specified by a flag, the corresponding environment variable (prefixed with the name field from the config) will be checked. 3. Config file (config.yaml): If neither a flag nor an environment variable is set, the value from the config.yaml file will be used. 4. Default Values: If no value is specified through flags, config.yaml, or environment variables, the CLI will fall back to its built-in default values.
| Variable | Description | Default |
|---|---|---|
name | The prefix for environment variable overrides. | 'openai' |
thread | The name of the current chat thread. Each unique thread name has its own context. | 'default' |
target | Load configuration from config._target_.yaml | '' |
omit_history | If true, the chat history will not be used to provide context for the GPT model. | false |
command_prompt | The command prompt in interactive mode. Should be single-quoted. | '[%datetime] [Q%counter]' |
output_prompt | The output prompt in interactive mode. Should be single-quoted. | '' |
command_prompt_color | The color of the command_prompt in interactive mode. Supported colors: "red", "green", "blue", "yellow", "magenta". | '' |
output_prompt_color | The color of the output_prompt in interactive mode. Supported colors: "red", "green", "blue", "yellow", "magenta". | '' |
auto_create_new_thread | If set to true, a new thread with a unique identifier (e.g., int_a1b2) will be created for each interactive session. If false, the CLI will use the thread specified by the thread parameter. | false |
auto_shell_title | If set to true, sets the title of the shell to the name of the current thread. | false |
track_token_usage | If set to true, displays the total token usage after each query in --query mode, helping you monitor API usage. | false |
debug | If set to true, prints the raw request and response data during API calls, useful for debugging. | false |
custom_headers | Add a map of custom headers to each http request | {} |
skip_tls_verify | If set to true, skips TLS certificate verification, allowing insecure HTTPS requests. | false |
http_timeout | HTTP client timeout in seconds. Set to 0 for no timeout, useful for slow or local models. | 60 |
multiline | If set to true, enables multiline input mode in interactive sessions. | false |
role_file | Path to a file that overrides the system role (role). | '' |
prompt | Path to a file that provides additional context before the query. | '' |
image | Local path or URL to an image used in the query. | '' |
audio | Path to an audio file (MP3/WAV) used as part of the query. | '' |
output | Path where synthesized audio is saved when using --speak. | '' |
transcribe | Enables transcription mode. This flags takes the path of an audio file. | false |
speak | If true, enables text-to-speech synthesis for the input query. | false |
draw | If true, generates an image from a prompt and saves it to the path specified by output. Requires image-capable models. | false |
web | Enable web search for supported models (e.g. gpt-5+). | false |
web_context_size | Controls how much context is retrieved during web search (low, medium, high). | low |
| Variable | Description | Default |
|---|---|---|
api_key | Your API key. | '' |
api_key_file | Load the API key from a file instead of the environment. Takes precedence over the environment variable. | '' |
auth_header | The header used for authorization in API requests. | 'Authorization' |
auth_token_prefix | The prefix to be added before the token in the auth_header. | 'Bearer ' |
completions_path | The API endpoint for completions. | '/v1/chat/completions' |
context_window | The memory limit for how much of the conversation can be remembered at one time. | 8192 |
effort | Sets the reasoning effort. Used by gpt-5 and o1-pro models. | 'low' |
frequency_penalty | Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far. | 0.0 |
image_edits_path | The API endpoint for image editing. | '/v1/images/edits' |
image_generations_path | The API endpoint for image generation. | '/v1/images/generations' |
max_tokens | The maximum number of tokens that can be used in a single API call. | 4096 |
model | The GPT model used by the application. | 'gpt-4o' |
models_path | The API endpoint for accessing model information. | '/v1/models' |
presence_penalty | Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far. | 0.0 |
responses_path | The API endpoint for responses. Used by o1-pro models. | '/v1/responses' |
role | The system role | 'You are a helpful assistant.' |
seed | Sets the seed for deterministic sampling (Beta). Repeated requests with the same seed and parameters aim to return the same result. | 0 |
speech_path | The API endpoint for text-to-speech synthesis. | '/v1/audio/speech' |
temperature | What sampling temperature to use, between 0 and 2. Higher values make the output more random; lower values make it more focused and deterministic. | 1.0 |
top_p | An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. | 1.0 |
transcriptions_path | The API endpoint for audio transcription requests. | '/v1/audio/transcriptions' |
url | The base URL for the OpenAI API. | 'https://api.openai.com' |
user_agent | The header used for the user agent in API requests. | 'chatgpt-cli' |
voice | The voice to use when generating audio with TTS models like gpt-4o-mini-tts. | 'nova' |
| Variable | Description | Default |
|---|---|---|
agent | Enable agent mode | false |
agent.mode | Strategy (react or plan) | react |
agent.work_dir | Working directory | . |
agent.max_iterations | Max ReAct iterations | 10 |
agent.max_steps | Max plan steps | 10 |
agent.max_wall_time | Max wall time (0 = unlimited) | 0 |
agent.max_shell_calls | Max shell calls (0 = unlimited) | 0 |
agent.max_llm_calls | Max LLM calls (0 = unlimited) | 10 |
agent.max_file_ops | Max file ops (0 = unlimited) | 0 |
agent.max_llm_tokens | Max LLM tokens (0 = unlimited) | 0 |
agent.allowed_tools | Allowed tools | see below |
agent.denied_shell_commands | Denied shell commands | see below |
agent.allowed_file_ops | Allowed file ops | see below |
agent.restrict_files_to_work_dir | Sandbox to workdir | true |
agent.write_plan_json | Write plan.json in plan mode | true |
agent.plan_json_path | Override plan.json path | "" |
agent.dry_run | No side effects | false |
You can also use flags, for example:
chatgpt "what files are here?" --agent --agent-work-dir /tmp #### Default Policy
allowed_tools: [shell, llm, files]
denied_shell_commands: [rm, sudo, dd, mkfs, shutdown, reboot]
allowed_file_ops: [read, write]
By default, ChatGPT CLI stores configuration and history files in the ~/.chatgpt-cli directory. However, you can easily override these locations by setting environment variables, allowing you to store configuration and history in custom directories.
| Environment Variable | Description | Default Location |
|---|---|---|
OPENAI_CONFIG_HOME | Overrides the default config directory path. | ~/.chatgpt-cli |
OPENAI_DATA_HOME | Overrides the default data directory path. | ~/.chatgpt-cli/history |
OPENAI_CACHE_HOME | Overrides the default cache directory path. | ~/.chatgpt-cli/cache |
To change the default configuration or data directories, set the appropriate environment variables:
export OPENAI_CONFIG_HOME="/custom/config/path"
export OPENAI_DATA_HOME="/custom/data/path"
export OPENAI_CACHE_HOME="/custom/cache/path"
If these environment variables are not set, the application defaults to ~/.chatgpt-cli for configuration files and ~ /.chatgpt-cli/history for history.
You can maintain multiple configuration files side by side and switch between them using the --target flag. This is especially useful if you use multiple LLM providers (like OpenAI, Perplexity, Azure, etc.) or have different contexts or workflows that require distinct settings.
How it Works
When you use the --target flag, the CLI loads a config file named:
config.<target>.yaml
For example:
chatgpt --target perplexity --config
This will load:
~/.chatgpt-cli/config.perplexity.yaml
If the --target flag is not provided, the CLI falls back to:
~/.chatgpt-cli/config.yaml
Example Setup
You can maintain the following structure:
~/.chatgpt-cli/
├── config.yaml # Default (e.g., OpenAI)
├── config.perplexity.yaml # Perplexity setup
├── config.azure.yaml # Azure-specific config
└── config.llama.yaml # LLaMA setup
Then switch between them like so:
chatgpt --target azure "Explain Azure's GPT model differences"
chatgpt --target perplexity "What are some good restaurants in the Red Hook area"
Or just use the default:
chatgpt "What's the capital of Sweden?"
CLI and Environment Interaction
The value of --target is never persisted — it must be explicitly passed for each run. The config file corresponding to the target is loaded before any environment variable overrides are applied. * Environment variables still follow the name: field inside the loaded config, so name: perplexity enables PERPLEXITY_API_KEY.
%date: The current date in the format YYYY-MM-DD.%time: The current time in the format HH:MM:SS.%datetime: The current date and time in the format YYYY-MM-DD HH:MM:SS.%counter: The total number of queries in the current session.%usage: The usage in total tokens used (only works in query mode).The defaults can be overridden by providing your own values in the user configuration file. The structure of this file mirrors that of the default configuration. For instance, to override the model and max_tokens parameters, your file might look like this:
model: gpt-3.5-turbo-16k
max_tokens: 4096
This alters the model to gpt-3.5-turbo-16k and adjusts max_tokens to 4096. All other options, such as url , completions_path, and models_path, can similarly be modified.
You can also add custom HTTP headers to all API requests. This is useful when working with proxies, API gateways, or services that require additional headers:
custom_headers:
X-Custom-Header: "custom-value"
X-API-Version: "v2"
X-Client-ID: "my-client-id"
If the user configuration file cannot be accessed or is missing, the application will resort to the default configuration.
Another way to adjust values without manually editing the configuration file is by using environment variables. The name attribute forms the prefix for these variables. As an example, the model can be modified using the OPENAI_MODEL environment variable. Similarly, to disable history during the execution of a command, use:
OPENAI_OMIT_HISTORY=true chatgpt what is the capital of Denmark?
This approach is especially beneficial for temporary changes or for testing varying configurations.
Moreover, you can use the --config or -c flag to view the present configuration. This handy feature allows users to swiftly verify their current settings without the need to manually inspect the configuration files.
chatgpt --config
Executing this command will display the active configuration, including any overrides instituted by environment variables or the user configuration file.
To facilitate convenient adjustments, the ChatGPT CLI provides flags for swiftly modifying the model, thread , context-window and max_tokens parameters in your user configured config.yaml. These flags are --set-model , --set-thread, --set-context-window and --set-max-tokens.
For instance, to update the model, use the following command:
chatgpt --set-model gpt-3.5-turbo-16k
This feature allows for rapid changes to key configuration parameters, optimizing your experience with the ChatGPT CLI.
For Azure, you need to configure these, or similar, value
name: azure
api_key: <your azure api key>
url: https://<your_resource>.openai.azure.com
completions_path: /openai/deployments/<your_deployment>/chat/completions?api-version=<your_api>
auth_header: api-key
auth_token_prefix: " "
You can set the API key either in the config.yaml file as shown above or export it as an environment variable:
export AZURE_API_KEY=<your_key>
For Perplexity, you will need something equivelent to the following values:
name: perplexity
api_key: <your perplexity api key>
model: sonar
url: https://api.perplexity.ai
You can set the API key either in the config.yaml file as shown above or export it as an environment variable:
export PERPLEXITY_API_KEY=<your_key>
You can set the API key either in the config.yaml file as shown above or export it as an environment variable:
export AZURE_API_KEY=<your_key>
I successfully tested 302.AI with the following values
name: ai302 # environment variables cannot start with numbers
api_key: <your 302.AI api key>
url: https://api.302.ai
You can set the API key either in the config.yaml file as shown above or export it as an environment variable:
export AI302_API_KEY=<your_key>
Atlas Cloud exposes an OpenAI-compatible API at https://api.atlascloud.ai/v1, giving access to 300+ models (DeepSeek, Llama, Qwen, and more) through a single endpoint. Because it speaks the OpenAI Chat Completions format, it works with ChatGPT CLI out of the box using the following values:
name: atlascloud
api_key: <your Atlas Cloud api key>
model: deepseek-ai/deepseek-v4-pro
url: https://api.atlascloud.ai/v1
You can set the API key either in the config.yaml file as shown above or export it as an environment variable:
export ATLASCLOUD_API_KEY=<your_key>
You can browse the full model catalog and create an API key from the Atlas Cloud dashboard.
业界领先的MCP CLI工具,Go语言实现保证性能,多提供商支持满足企业多元需求,生态活跃度高。
AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。
建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。
✅ MIT 协议 — 最宽松的开源协议之一,可自由商用、修改、分发,仅需保留版权声明。
总体来看,chatgpt-cli MCP工具 是一款质量优秀的MCP工具,在同类工具中具备一定竞争力。AI Skill Hub 将持续追踪其更新动态,建议收藏备用,结合自身场景选择合适时机引入使用。
| 原始名称 | chatgpt-cli |
| 原始描述 | 开源MCP工具:ChatGPT CLI is a powerful, multi-provider command-line interface for working wit。⭐923 · Go |
| Topics | MCPCLI工具多模型支持Agent框架Go语言 |
| GitHub | https://github.com/kardolus/chatgpt-cli |
| License | MIT |
| 语言 | Go |
收录时间:2026-05-18 · 更新时间:2026-05-19 · License:MIT · AI Skill Hub 不对第三方内容的准确性作法律背书。
选择 Agent 类型,复制安装指令后粘贴到对应客户端