# tkflyc-ai-cli [Health: Active]

**Category:** 💻 Developer Tools  
**Repository:** https://github.com/moerasermax/tkflyc-ai-cli  
**GitHub Stars:** 7  
**Views:** 0  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/tkflyc-ai-cli

## Description
Run Claude Code, Codex, Antigravity and any OpenAI-compatible API as MCP tools with background jobs — registry architecture, circuit breaker, honest return values

## Tools
Capabilities this server exposes over MCP:

- **run** — AI Agent Runner: Starts a Claude, Codex, Grok, Antigravity, or direct API agent job in the background and returns a PID immediately. Use list_processes and get_result to monitor progress. With capabilities, Codex uses read-only sandbox, --ignore-rules, and windows.sandbox=elevated on Windows; sandbox startup failure is reported as agentOutput.sandbox_warning even when the vendor exits 0.

• File ops: Create, read, (fuzzy) edit, move, copy, delete, list files, analyze/ocr images, file content analysis
• Code: Generate / analyse / refactor / fix
• Git: Stage ▸ commit ▸ push ▸ tag (any workflow)
• Terminal: Run any CLI cmd or open URLs
• Web search + summarise content on-the-fly
• Multi-step workflows & GitHub integration

**IMPORTANT**: This tool now returns immediately with a PID. Use other tools to check status and get results.
Claude, Codex, Grok and Windows Antigravity (ConPTY) jobs return a durable jobId, outlive the server, and can be recovered or adopted. POSIX Antigravity and direct-api jobs cannot be recovered or adopted.
For cost-aware dispatch (batching, duplicate jobs, polling, and agentOutput.usage), read the models tool's dispatchGuidance.

**Candidate models** — this is NOT an allowlist. claude is the routing catch-all, so a name that is
absent from this list may still run; call the models tool and read "modelListCaveat" before concluding
that a model is unsupported. Conversely, a name listed here may have been retired by the vendor.
"claude-ultra", "codex-ultra", "codex-ultracode", "agy-ultra", "fable", "sonnet", "sonnet[1m]", "opus", "opusplan", "haiku", "gpt-6.1-sol", "gpt-6-astra", "gpt-6-sol", "gpt-6-luna", "gpt-5.6-sol", "gpt-5.6-terra", "gpt-5.6-luna", "grok-4.7", "grok-4.7-build-fast", "grok-4.6", "grok-4.5", "agy", "agy-default", "gemini-3.1-pro-high", "gemini-3.8-flash-high", "or-<model>", "ds-<model>", "<provider>-<model>", "or-qwen/qwen3.7-plus", "nv-poolside/laguna-xs-2.1", "nv-nvidia/ising-calibration-1.5-31b", "nv-google/diffusiongemma-26b-a4b-it", "nv-meta/muse-glimmer-30b", "nv-nvidia/nemotron-3.5-lightning-30b-a3b", "nv-nvidia/nemotron-3-super-120b-a12b", "nv-nvidia/nemotron-3-nano-omni-30b-a3b-reasoning", "nv-openai/gpt-oss-20b", "nv-moonshotai/kimi-k3", "nv-google/gemma-4-31b-it", "nv-nvidia/nemotron-3-ultra-550b-a55b"

**Prompt input**: You must provide EITHER prompt (string) OR prompt_file (file path), but not both.

**Prompt tips**
1. Be concise, explicit & step-by-step for complex tasks.
2. Check process status with list_processes
3. Get results with get_result using the returned PID
4. Kill long-running processes with kill_process if needed

- **adopt** — Only durable MCP jobs (Claude, Codex, Grok and Windows Antigravity/ConPTY) can be adopted; POSIX Antigravity, direct-api and CLI jobs cannot. Jobs in the same project directory are automatically adopted after the original dispatching session has ended; this tool is usually unnecessary. Use it manually for cross-project takeover. Jobs remain eligible throughout execution and for 30 minutes after completion, subject to store capacity limits. Omit pid and jobId to list eligible candidates with autoAdopt scope flags; a PID selects its latest job, and both selectors must agree.
- **list_processes** — List tracked AI agent processes with PID, agent and status. Running items include liveness (alive, elapsedSec, sinceLastOutputSec, stdoutBytes, stderrBytes, lastEvent, eventCount, hint), plus elapsedSec, sinceLastOutputSec and lastEvent at the item level. Terminal items include elapsedSec when the end time is known and have no liveness.
- **get_result** — Get the current output and status of an AI agent process by PID. Running results include liveness: alive, elapsedSec, sinceLastOutputSec, stdoutBytes, stderrBytes, lastEvent, eventCount and an English hint. Codex/Claude can emit nothing while reasoning; while liveness.alive is true, keep waiting or use peek for live events. Terminal results have no liveness. Defaults to a compact result shape; set verbose to true for full metadata and detailed parsed output. Compact results omit raw stdout/stderr while a job is running (use liveness, or peek for live events); a finished job without a parsed reply returns only the last 4096 characters, marked by stdoutTruncated/stderrTruncated. With verbose, durable job logs are capped at 8 MiB per stream and carry stdoutTruncated/stderrTruncated byte counts; oversized parsed replies carry agentOutputTruncated. Read disk logs for larger output.
- **wait** — Wait for AI agent processes and return an array of current results. Timeout is NOT an error: still-running items include timedOut: true and liveness (alive, elapsedSec, sinceLastOutputSec, stdoutBytes, stderrBytes, lastEvent, eventCount, hint). Use timeout <= 90 seconds and call repeatedly; do not abandon a PID while liveness.alive is true. Codex/Claude emit nothing while reasoning. Use peek to observe live messages and tool events. Terminal items have neither liveness nor timedOut. Unknown PIDs still cause an error. Defaults to compact result items; set verbose to true for full metadata and detailed parsed output. Compact results omit raw stdout/stderr while a job is running (use liveness, or peek for live events); a finished job without a parsed reply returns only the last 4096 characters, marked by stdoutTruncated/stderrTruncated. With verbose, durable job logs are capped at 8 MiB per stream and carry stdoutTruncated/stderrTruncated byte counts; oversized parsed replies carry agentOutputTruncated. Read disk logs for larger output.
- **peek** — One-shot short observation window for running child agents. Returns only natural-language message events, and optionally normalized tool_call events, observed during this call; not a history API, not gapless streaming, and not stdout/stderr tailing. Message extraction is supported for Codex, Claude, Grok, direct-api, and Antigravity. Tool calls exclude raw tool output.
- **kill_process** — Terminate a running AI agent process by PID.
- **cleanup_processes** — Remove all completed and failed processes from the process list to free up memory.
- **doctor** — Check supported AI CLI binary availability and path resolution. Does not verify login state or terms acceptance. Also reports the identity of this server itself — npm package name, version and repository — in the "server" field, which is the authoritative answer to "which project is this?".
- **models** — List candidate model names, model aliases, and dynamic backend discovery hints. Also reports the identity of this server itself (npm package, version, repository) in the "server" field. The per-agent arrays are NOT an allowlist: claude is the routing catch-all, so a name that is absent from them may still run — see the "modelListCaveat" field before concluding a model is unsupported.
- **set_config** — Update persisted user settings at the ai-cli config file. Changes take effect immediately for subsequent run calls; the MCP server does NOT need to be restarted.

Use alias_model to repoint a model alias (for example {"codex-ultra": "gpt-5.6-terra"}). Valid alias names: "claude-ultra", "codex-ultra", "codex-ultracode", "agy-ultra", "antigravity-ultra".

Use unset to drop overrides and fall back to the built-in defaults. Returns the same payload as the models tool so the effective state is visible right away.

Note: antigravity (agy) does accept model selection — the resolved name is normalized to an agy model id ("Gemini 3.1 Pro (High)" -> gemini-3.1-pro-high) and passed as --model. Only "agy" and "agy-default" pass nothing and fall back to the agy CLI's own default, so repointing agy-ultra to those two changes what is reported, not what runs.
- **query_usage** — Query remaining token/credit usage for AI CLI tools (Claude, Codex, Antigravity/agy). Results are cached for 120 seconds. Use refresh=true to force a fresh query.

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `npx` (confidence: high):

```json
"mcpServers": {
  "tkflyc-ai-cli": {
    "command": "npx",
    "args": ["-y","@tkflyc/ai-cli-mcp"]
  }
}
```

## Documentation

## What tkflyc-ai-cli does

tkflyc-ai-cli turns several AI backends into tools callable through MCP. Supported local command-line backends include Claude, Codex, Grok, and Windows Antigravity (`agy`). A separate `direct-api` path connects to OpenAI-compatible `/chat/completions` services, including hosted providers, local Ollama instances, and private gateways.

The server is designed around background execution rather than blocking a tool call until an agent finishes. A submitted job returns its process identifier immediately. Shared durable state is also available through the `ai-cli` command-line interface, allowing the MCP and CLI surfaces to observe the same work.

## How it works

The main workflow starts with `run`, which launches a backend job and returns its PID. Use `list_processes` to inspect known jobs, `peek` to view intermediate output, `wait` to wait for completion, and `get_result` to retrieve the final response. Finished jobs are retained for 30 minutes for the Claude, Codex, and Grok runners.

The direct API runner does not start a provider subprocess. It performs HTTP requests from the Node process and runs an agent loop in which the model can use `read_file`, `write_file`, and `bash`. Provider models are addressed with a provider prefix followed by the model name, such as `local-llama3.1` or `or-qwen/qwen3.7-plus`.

For transient HTTP failures, the direct API runner retries 429 and 5xx responses with exponential backoff and jitter. Retry behavior can be configured per provider, and retry events are written to stdout. Tool-loop limits also apply to direct API jobs; the default is 30 iterations, with supported values from 1 through 200.

## Setup and configuration

The package requires Node.js `^20.19.0 || >=22.12.0`. An npm-based installation can be registered with Claude using:

```bash
claude mcp add ai-cli -s user -- npx -y @tkflyc/ai-cli-mcp
```

A source checkout requires `npm install`, which builds the untracked `dist/` directory through the package's `prepare` script. Register the resulting server with Node:

```bash
claude mcp add ai-cli -s user -- node "/path/to/tkflyc-ai-cli/dist/server.js"
```

Direct API providers are configured in `~/.local/share/ai-cli/providers.json`. Set `AI_CLI_PROVIDERS_PATH` to use another file. Provider entries can define an API key, base URL, retry settings, `extra_body`, model-specific request fields, and `max_tool_loops`. OpenRouter and DashScope have built-in base URLs; other provider keys need their own `base_url`. The configuration is validated as a whole, so one invalid provider entry can prevent all providers from loading.

## Tools and capabilities

- Launch Claude, Codex, Grok, and Antigravity jobs through MCP.
- Call OpenAI-compatible HTTP endpoints without adding provider-specific code.
- Track background jobs with PIDs, process listing, output inspection, waiting, and result retrieval.
- Query model lists for supported backends, including Grok's cached or fallback model data.
- Configure retries for throttling and server-side failures.
- Run an agent loop with file-reading, file-writing, and shell-command tools through direct API models.

## Limitations and notes

The npm and npx installation paths do not self-update. Source-based auto-update depends on a clone containing `.git` and `package.json`; pin the package version in an npm command when reproducibility matters.

Direct API configuration rejects attempts to override core request fields such as `model`, `messages`, `stream`, `stream_options`, or `tools`. A job can finish with exit code 0 after reaching its tool-loop limit, so callers should inspect `agentOutput.finish_reason` for `tool_loop_limit` rather than relying only on process status.

The Grok backend requires one of its supported reasoning-effort values, and its execution errors are treated as failures even when the CLI exits with code 0.

_Full upstream README: https://allmcps.com/mcp/tkflyc-ai-cli/readme_

