MCP vs CLI for AI agents
When an AI agent should use an MCP server and when a plain command-line tool does the job better, with the trade-offs on context, sign-in and safety.
Anthropic's Claude Code guide says that if a system has a CLI, that is usually the easiest way in. MCP is the open standard that lets AI apps such as Claude and ChatGPT connect to external systems, including from chat apps where there is no terminal.
The cost of MCP is context: most clients load every tool definition up front, though Claude Code defers them until needed. The cost of a CLI is that it works only where the agent can run commands.
Our advice: if your agent has a terminal and the service has a good CLI (git, GitHub's gh, a cloud CLI), use the CLI. Use an MCP server when there is no CLI, when you work in a chat app with no terminal, or when you want each person to sign in with their own account. To see how MCP tools work, read MCP tools explained; for MCP against skills, see MCP vs skills.
Good for
- Claude Code, Codex and Cursor users wiring up tools
- Teams deciding whether to build an MCP server or ship a CLI
- People who use Claude or ChatGPT in the browser and want them to reach their apps
Side by side
Our advice: use a CLI in a terminal agent when one exists. Use MCP for chat apps, for services with no CLI, and when each user should sign in as themselves.
| Option | MCP server | CLI tool |
|---|---|---|
| Where it runs | Local process or remote URL | Where the agent has a shell |
| Chat apps such as Claude and ChatGPT | Connect through MCP servers | Not applicable |
| Sign-in | OAuth per user for hosted servers | Your existing CLI login (for example gh) |
| Context cost | Most clients load all tool definitions up front; Claude Code defers them | Agent reads --help when it needs to |
| Inputs | JSON Schema | Flags, described by --help |
| Output limit in Claude Code | Warns above 10,000 tokens, cuts at 25,000 | Not applicable |
Which to pick
Our advice: default to the CLI when your agent runs in a terminal and a mature CLI exists, since the agent can use your existing login. Use an MCP server when there is no CLI, when you work in a chat app like Claude or ChatGPT, or when each person should sign in as themselves.
You can use both: keep the CLIs your team already trusts, and add MCP servers only for the services that lack one.
Best for
- CLI: git, GitHub, cloud and database tools in Claude Code or Codex
- MCP: Notion, Linear, Slack and other services with no good CLI
- MCP: the Claude app and ChatGPT, which connect through MCP
- MCP: teams where each person must sign in as themselves
Skip it if
- MCP: you connect many servers you rarely use, since most clients load every tool definition into each session
- CLI: your agent runs in a chat app with no shell
Related plugs
6
Notion MCPOfficialHostedOAuthNotion's hosted remote MCP server at mcp.notion.com. Sign in with OAuth and an AI client can search, read, create and update the pages and databases you can access. No local install.
GitHub MCP ServerOfficialHosted or LocalOAuthGitHub's official MCP server. Lets an AI assistant read code, manage issues and pull requests, check Actions runs and security alerts. Hosted at api.githubcopilot.com/mcp or run locally with Docker or a Go binary.
34.1K GitHub stars
LinearOfficialHostedOAuthFind and manage issues, projects, and documents in your Linear workspace.
SupabaseOfficialHosted or LocalOAuthMCP server for interacting with the Supabase platform
3K GitHub stars
Playwright MCPOfficialLocalPlaywright MCP server
38.9K GitHub stars
Context7OfficialHosted or LocalAPI keyUp-to-date docs for AI agents
64K GitHub stars
Questions
Is MCP better than a CLI for AI agents?
Not always. Anthropic's Claude Code guide says a CLI is usually the easiest way in when a system has one. MCP is the standard that chat apps such as Claude and ChatGPT use to connect to external systems.
Why do people say MCP wastes tokens?
Because most MCP clients load every tool definition into the model's context up front, and every result passes back through the model. In one example in Anthropic's November 2025 post on code execution with MCP, having the agent call tools from code cut usage from 150,000 tokens to 2,000. Claude Code now loads only tool names at the start and fetches full definitions when needed.
When should I use an MCP server instead of a CLI?
Our advice: use MCP when the service has no CLI, when you work in the Claude app or ChatGPT, or when a hosted server lets each person sign in with their own account. MCP tools also describe their inputs in a fixed format (JSON Schema) the agent reads before it calls them. See MCP tools explained.
When is a CLI the better choice?
Our advice: use a CLI when your agent runs in a terminal and the CLI is well known, like git or gh. Anthropic's Claude Code guide says that with gh installed and signed in, Claude opens pull requests and reads review comments without explanation, and that for a CLI it has not seen before, pointing it at --help is enough.
Is a CLI safer than an MCP server?
Neither is safer by default. The MCP security guide says local MCP servers may have direct access to your system and calls for sandboxing and consent requirements. Claude Code documents permission rules and a sandbox you can use to limit what the agent can run or reach. Our advice: give any token only the access it needs.
Can I use MCP servers and CLI tools together?
Yes. In Claude Code the agent runs CLIs through its shell and calls MCP servers you add. Turn off servers you are not using in the /mcp menu so they stop adding to every session. For MCP compared with skills, see MCP vs skills.
How do I add an MCP server to Claude Code?
Run claude mcp add --transport http <name> <url> for a hosted server, for example claude mcp add --transport http notion https://mcp.notion.com/mcp. For a local one, put the start command after --. See the Claude Code client page for config files and scopes.
Is there a limit on how much an MCP tool can return?
In Claude Code, yes. It warns when a tool returns more than 10,000 tokens and cuts output at 25,000 tokens by default; set MAX_MCP_OUTPUT_TOKENS to change the cap.
Sources
Docs, issue trackers and discussions this page is built from.
Show all 8Hide
- Claude Code best practices · code.claude.com
- MCP introduction · modelcontextprotocol.io
- Anthropic: Code execution with MCP · anthropic.com
- Claude Code MCP · code.claude.com
- MCP specification: tools · modelcontextprotocol.io
- Codex MCP · learn.chatgpt.com
- Connect and manage custom apps for Gemini Apps · support.google.com
- MCP security best practices · modelcontextprotocol.io