A command-line interface (CLI) lets an agent invoke software operations through shell commands. Unlike an IDE-centered workflow, terminal processes can run unattended in scripts, cron jobs, Git hooks, and CI pipelines. section 5.3 section 9.5.1
For AI agents, a CLI can avoid the persistent context cost of an MCP server definition: the agent calls the command when needed and receives its result. That saves context space, but each call is roughly 200 ms slower than an MCP call. section 9.5.1
Choose direct CLI use or an MCP wrapper based on call frequency and output needs:
- Prefer the CLI for tools used once or twice per session, especially when their output is already concise and structured. section 9.5.1
- Consider an MCP wrapper for tools called ten or more times per session, or when input parsing and filtering large outputs can produce a controlled, token-efficient response. section 9.5.1
- Use unattended terminal agents for bounded, event-triggered work with crisp inputs and inexpensive output validation; their failures may otherwise go unnoticed. section 5.3
Recovering agent context
Replacing GitHub and Sentry MCP integrations with gh and sentry-cli calls recovered 25,000 tokens of context. The tradeoff was slower individual calls in exchange for removing persistent tool definitions. section 9.5.1
Table 9.6 Context Usage claude-sonnet-4-5
|
Source
|
Tokens
|
Share
|
|
System prompt
|
3,900 tokens
|
2%
|
|
MCP tools
|
58,400 tokens
|
29%
|
|
Memory files
|
1,200 tokens
|
1%
|
|
Messages
|
42,000 tokens
|
21%
|
|
Free space
|
94,500 tokens
|
47%
|
The context breakdown illustrates how MCP tool definitions can consume space otherwise available for code and conversation. section 9.5.1











