Skip to content

ChatGPT CLI v1.9.0

Choose a tag to compare

@kardolus kardolus released this 03 Jan 15:50
· 71 commits to main since this release

New Features:

  • Provider‑agnostic MCP over HTTP(S):
    • The CLI now speaks Model Context Protocol (MCP) via JSON‑RPC over HTTP(S), without hardcoding providers.
    • New flags:
      • --mcp: MCP endpoint URL (e.g., http://127.0.0.1:8000/mcp)
      • --mcp-tool: Tool name to invoke on the MCP server
      • --mcp-header: Repeatable HTTP headers for auth/session (e.g., Authorization: Bearer …, Mcp-Session-Id: …)
      • --param / --params: Tool arguments (as key=value pairs or raw JSON)
    • MCP tool results are injected into the active thread as an assistant message prefixed with [MCP: ].
    • Supports both application/json and text/event-stream (SSE) responses, automatically parsing the first data frame.
    • JSON detected inside text blocks is pretty‑printed in the injected context for readability.
  • Local test MCP server:
    • Added a minimal HTTP test server under test/mcp/http to validate requests, headers, and SSE behavior.
  • Documentation:
    • README and docs updated with clear MCP usage examples, headers/auth guidance, and result handling.

Improvements:

  • Major client refactor for clarity and maintainability:
    • Split into focused files: debug.go, history.go, llm.go, media.go, mcp.go.
    • Introduced MCPTransport abstraction (HTTP implementation provided), enabling future transports.
    • Exported Client.Caller; added Client.WithTransport for custom MCP transports.
  • Debug experience:
    • Consistent cURL-style request logging and raw response logging across features.
  • README structure:
    • Clearer MCP sections: Overview, Examples, Headers and Authentication, How MCP Results Are Used.
  • Tooling and repo hygiene:
    • .gitignore now ignores common Python virtual env dirs (.venv/, venv/, env/).

Bug Fixes:

  • More robust MCP response handling:
    • Accepts both JSON and SSE MCP responses; provides helpful errors for invalid responses.
    • Normalizes session header spelling (mcp-session-id → Mcp-Session-Id) to avoid subtle header casing issues.
  • History handling stability:
    • Centralized and simplified history initialization and truncation logic, improving consistency across features.

Other Changes:

  • Breaking: Removed Apify‑specific integration and config
    • apify_api_key is removed from config and environment binding.
    • Old --mcp syntax (/@) and ParseMCPPlugin are removed in favor of generic HTTP MCP.
  • CLI defaults updated:
    • auto_create_new_thread: default is now false (was true).
    • track_token_usage: default is now false (was true).
  • Test suite:
    • Tests reorganized by domain (LLM, Media, History, MCP) with new transport mocks; added MCP transport tests.
  • Dependency updates:
    • cobra v1.10.2, gomega v1.38.3, ginkgo v2.25.3, x/net v0.48.0, x/sys v0.39.0, x/text v0.32.0, x/tools v0.39.0.

Upgrade Notes:

  • How to update:
    • Homebrew: brew upgrade chatgpt-cli
    • Direct download: Download the latest binaries for your OS from the releases page and replace your existing binary.
  • Breaking MCP changes:
    • Old: --mcp apify/user~actor[@Version] plus APIFY_API_KEY in config.
    • New: --mcp --mcp-tool [--mcp-header "Authorization: Bearer …"] [--mcp-header "Mcp-Session-Id: …"] [--param key=value | --params '{"key":"value"}']
    • Example:
      • chatgpt --mcp "https://mcp.apify.com/?tools=epctex/weather-scraper" --mcp-tool "epctex-slash-weather-scraper" --mcp-header "Authorization: Bearer $APIFY_API_KEY" --mcp-header "mcp-session-id: $MCP_SESSION_ID" --param locations='["Brooklyn, NY"]' "what should I wear today"
  • Config changes:
    • Remove apify_api_key from your config files; pass credentials via --mcp-header instead.
  • Behavior changes:
    • MCP context is stored as an assistant message (prefix [MCP: ]) instead of a function message.
    • MCP requires history tracking to be enabled; disable --omit-history if you plan to inject MCP context.
  • Defaults:
    • If you relied on auto-creating new threads or token usage tracking, re-enable via flags or config (set-auto-create-new-thread true, set-track-token-usage true).